How do I check for potential merge/rebase conflicts in Mercurial?

后端 未结 3 745
甜味超标
甜味超标 2020-12-17 16:30

Is there a simple way to check if a merge/rebase will yield file conflicts, without actually performing the merge/rebase?

I want to be able to decide whether to:

3条回答
  •  有刺的猬
    2020-12-17 17:26

    You can see if two changesets, REV1 and REV2, affect any of the same files doing something like:

    (hg status --change REV1 --no-status ; hg status --change REV2 --no-status) | sort | uniq --repeated
    

    If that has any output then the same file is touched in both revisions.

    That could easily be made a shell script like:

    #!/bin/sh
    (hg status --change $1 --no-status ; hg status --change $2 --no-status) | sort | uniq --repeated
    

    which could be run as any of these:

    ./find_overlaps c8f7e56536ab d9e2268e20b9
    ./find_overlaps 1 33
    

    If you really wanted to get fancy you could tweak the script to automatically run merge or rebase depending on whether or not any lines were found.

    If you're on windows my god help you. :)

提交回复
热议问题