Your Search Results

    Reverting Changesets With File Moves/Renames

    この記事はまだ日本語に翻訳されていません。MDN の翻訳はボランティアによって行われています。是非 MDN に登録し、私たちの力になって下さい。

    Normally backing out a changeset in Mercurial is as simple as:

    $ hg backout <var>revision</var>
    $ hg merge
    $ hg commit

    Mercurial has a bug, however, when the revision being backed out contains file renames (moves). The backout will record the change as an add/remove, instead of a rename to the old location. Instead of using hg backout for these changes, use the following procedure instead.

    Note: Benjamin Smedberg is more than happy to perform complex backouts, if these instructions are confusing or terrifying.

    These instructions assume you're trying to back out revision X, and that the parent of X is XPARENT:

    Preparation: Install and enable the move-fixup extension:

    Clone http://hg.mozilla.org/users/bsmedber...com/move-fixup or download http://hg.mozilla.org/users/bsmedber...p/movefixup.py

    Enable movefixup in your Mercurial configuration file ~/.hgrc:

    [extensions]
    movefixup = <var>/path/to/</var>movefixup.py
    

    Step 1: update to revision X

    $ hg up X
    

    Step 2: revert to revision BADPARENT

    $ hg revert -a -r XPARENT
    

    Step 3: Find and fix file moves

    $ hg status -ar # -ar shows only files that were added or removed
    A oldfilename
    R newfilename
    
    $ hg movefixup newfilename oldfilename
    

    Step 4: Check your work

    Before committing, read a diff-style git to make sure that file was renamed correctly. The diff should say something like:

    diff --git a/newfilename b/oldfilename
    rename from newfilename
    rename to oldfilename
    

    Step 5: Commit

    Commit your backout changeset, and merge forward as necessary.

    Document Tags and Contributors

    タグ:
    Contributors to this page: Benjamin Smedberg
    最終更新者: Benjamin Smedberg,