Showing renames in hg status?

前端 未结 2 452
生来不讨喜
生来不讨喜 2021-02-01 16:15

I know that Mercurial can track renames of files, but how do I get it to show me renames instead of adds/removes when I do hg status? For instance, instead

2条回答
  •  闹比i
    闹比i (楼主)
    2021-02-01 16:53

    There are several ways to do this.

    Before you commit, you can use hg diff --git to show what was renamed:

    $ hg diff --git
    diff --git a/theTest.txt b/aTest.txt
    rename from theTest.txt
    rename to aTest.txt
    

    Note that this only works if you used hg mv, hg rename, or mv and hg addremove --similarity 100.

    After you commit, you can still use hg diff, but you'll have to specify the change using -r:

    $ hg diff -r 0 -r 1 --git
    diff --git a/test.txt b/theTest.txt
    rename from test.txt
    rename to theTest.txt
    

    For both hg status and hg log, use the -C command-line flag to see the source that a file was copied from.

    $ hg status -C
    A aTest.txt
      theTest.txt
    R theTest.txt
    

    The line just below aTest.txt indicates the source it was copied from (theTest.txt).

    $ hg log -v -C
    changeset:   1:4d7b42489d9f
    tag:         tip
    user:        jhurne
    date:        Tue Apr 20 20:57:07 2010 -0400
    files:       test.txt theTest.txt
    copies:      theTest.txt (test.txt)
    description:
    Renamed test.txt
    

    You can see the files that were affected (test.txt and theTest.txt), and that "theTest.txt" was copied from test.txt.

提交回复
热议问题