hg merge preview
Mads Kiilerich
mads at kiilerich.com
Wed Aug 31 23:04:57 UTC 2011
Peter Toft wrote, On 08/31/2011 11:42 PM:
>
> Can you see a "simple" way of identifying the other relevant files in
> this example (B.txt and C.txt):
>
> User A:
>
> echo " " >> A.txt
>
> echo " " >> B.txt
>
> hg commit -m "bla from A"
>
> hg push
>
> User B:
>
> echo "x" >> A.txt
>
> echo " " >> C.txt
>
> hg commit -m "bla bla from b"
>
> hg pull
>
> Now user B can use "hg preview `hg heads | head -n 1 | grep changeset
> | cut -d: -f 2`" to get the problematic merge-conflict A.txt found,
> but what about the B.txt and C.txt which differ in the two heads -
> albeit they can merge clean.
>
Merges in Mercurial are based on the DAG of the individual files, so if
the file only has been changed in one branch then there is no branching
of that file and nothing to merge at all. Or put slightly different: If
the merge is fully resolved in the manifest merge then there is no need
for any file merge.
> Ideas? :)
>
Ok, you asked for merge preview so you got an answer that focused on the
merge and the 'real' conflicts.
A preview of a merge can however also be seen as: What has been changed
in the branch I'm about to merge with since it branched out from the
current branch.
$ hg init
$ touch {A,B,C}.txt
$ hg ci -Aqm0
User A:
$ echo " " >> A.txt
$ echo " " >> B.txt
$ hg commit -m "bla from A" # 1
User B:
$ hg up -qr0
$ echo "x" >> A.txt
$ echo " " >> C.txt
$ hg commit -qm "bla bla from b" # 2
What changes will B (.) get from merging with A (1):
$ hg status --rev 'ancestor(.,1):1'
M A.txt
M B.txt
$ hg diff --stat -r 'ancestor(.,1):1'
A.txt | 1 +
B.txt | 1 +
2 files changed, 2 insertions(+), 0 deletions(-)
$ hg up -qr1
What changes will A (.) get from merging with B (2):
$ hg status --rev 'ancestor(.,2):2'
M A.txt
M C.txt
$ hg diff --stat -r 'ancestor(.,2):2'
A.txt | 1 +
C.txt | 1 +
2 files changed, 2 insertions(+), 0 deletions(-)
It seems like most people don't care much about merge previews. Merges
are often less scary in Mercurial than in 'old' VCSs, and it is often
much simpler to just try to do the merge, review it, re-resolve (hg
resolve) if parts of it wasn't resolved correctly, or drop it (hg up -C)
to forget about it and perhaps start over.
/Mads
More information about the Mercurial
mailing list