Mercurial - see list of files that need to be manually merged?

前端 未结 4 2258
遥遥无期
遥遥无期 2021-02-18 13:21

Is there a Mercurial command you can use after an hg pull to see a list of all files that will be need to be manually merged (ie: that have conflicts) when doing an

4条回答
  •  遇见更好的自我
    2021-02-18 13:56

    You can use the --rev option of hg stat with a pair of revisions to see what file differences exist between the two. See below for a slightly verbose but detailed example:

    First we start by making a new repository:

    [gkeramidas /tmp]$ hg init foo
    [gkeramidas /tmp]$ cd foo
    

    Then add a single file called foo.txt to the new repository:

    [gkeramidas /tmp/foo]$ echo foo > foo.txt
    [gkeramidas /tmp/foo]$ hg commit -Am 'add foo'
    adding foo.txt
    [gkeramidas /tmp/foo]$ hg glog
    @  0[tip]   b7ac7bd864b7   2011-01-30 18:11 -0800   gkeramidas
         add foo
    

    Now add a second file, called bar.txt as revision 1:

    [gkeramidas /tmp/foo]$ echo bar > bar.txt
    [gkeramidas /tmp/foo]$ hg commit -Am 'add bar'
    adding bar.txt
    

    Go back to revision 0, and add a third file, on a different head. This is done to simulate a pull from someone else who had cloned the same repository at its starting revision:

    [gkeramidas /tmp/foo]$ hg up -C 0
    0 files updated, 0 files merged, 1 files removed, 0 files unresolved
    [gkeramidas /tmp/foo]$ echo koko > koko.txt
    [gkeramidas /tmp/foo]$ hg commit -Am 'add koko'
    adding koko.txt
    created new head
    [gkeramidas /tmp/foo]$ hg glog
    @  2[tip]:0   e5d80abdcb06   2011-01-30 18:12 -0800   gkeramidas
    |    add koko
    |
    | o  1   a2d0d0e66ce4   2011-01-30 18:12 -0800   gkeramidas
    |/     add bar
    |
    o  0   b7ac7bd864b7   2011-01-30 18:11 -0800   gkeramidas
         add foo
    

    Now you can use hg stat to see what file differences exist between any pair of revisions, e.g. the changes from rev 0 to rev 1 added 'bar.txt' to the file list:

    [gkeramidas /tmp/foo]$ hg stat --rev 0:1
    A bar.txt
    

    The changes from rev 0 to rev2 added 'koko.txt' to the file list:

    [gkeramidas /tmp/foo]$ hg stat --rev 0:2
    A koko.txt
    

    But more interestingly, the changes from rev 1 to rev 2 involve two file manifest changes. (1) 'koko.txt' was added in rev 2, and (2) 'bar.txt' exists in rev 1 but is missing from rev 2, so it shows as a 'removed' file:

    [gkeramidas /tmp/foo]$ hg stat --rev 1:2
    A koko.txt
    R bar.txt
    

提交回复
热议问题