Mercurial > hg
changeset 3121:2ef0b3aae186
merge: simplify actions with helper function
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Sun, 17 Sep 2006 21:27:30 -0500 |
parents | 1c1e59aac82a |
children | da85145d4571 70e62df12704 |
files | mercurial/merge.py tests/test-merge7.out tests/test-up-local-change.out tests/test-update-reverse.out |
diffstat | 4 files changed, 25 insertions(+), 33 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/merge.py Sun Sep 17 21:11:26 2006 -0500 +++ b/mercurial/merge.py Sun Sep 17 21:27:30 2006 -0500 @@ -106,6 +106,10 @@ action = [] + def act(msg, f, m, *args): + ui.debug(" %s: %s -> %s\n" % (f, msg, m)) + action.append((f, m) + args) + # Filter manifests if partial: for f in m1.keys(): @@ -121,56 +125,44 @@ a = ma.get(f, nullid) # are both different from the ancestor? if not overwrite and n != a and m2[f] != a: - ui.debug(_(" %s versions differ, resolve\n") % f) - action.append((f, "m", fmerge(f), n[:20], m2[f])) + act("versions differ", f, "m", fmerge(f), n[:20], m2[f]) # are we clobbering? # is remote's version newer? # or are we going back in time and clean? elif overwrite or m2[f] != a or (backwards and not n[20:]): - ui.debug(_(" remote %s is newer, get\n") % f) - action.append((f, "g", m2.execf(f), m2[f])) + act("remote is newer", f, "g", m2.execf(f), m2[f]) # local is newer, not overwrite, check mode bits elif fmerge(f) != m1.execf(f): - ui.debug(_(" updating permissions for %s\n") % f) - action.append((f, "e", m2.execf(f))) + act("update permissions", f, "e", m2.execf(f)) # contents same, check mode bits elif m1.execf(f) != m2.execf(f): if overwrite or fmerge(f) != m1.execf(f): - ui.debug(_(" updating permissions for %s\n") % f) - action.append((f, "e", m2.execf(f))) + act("update permissions", f, "e", m2.execf(f)) del m2[f] elif f in ma: if n != ma[f] and not overwrite: if ui.prompt( (_(" local changed %s which remote deleted\n") % f) + _("(k)eep or (d)elete?"), _("[kd]"), _("k")) == _("d"): - action.append((f, "r")) + act("prompt delete", f, "r") else: - ui.debug(_("other deleted %s\n") % f) - action.append((f, "r")) + act("other deleted", f, "r") else: # file is created on branch or in working directory if (overwrite and n[20:] != "u") or (backwards and not n[20:]): - ui.debug(_("remote deleted %s, clobbering\n") % f) - action.append((f, "r")) - else: - ui.debug(_("local created %s, keeping\n") % f) + act("remote deleted", f, "r") for f, n in m2.iteritems(): if f in ma: if overwrite or backwards: - ui.debug(_("local deleted %s, recreating\n") % f) - action.append((f, "g", m2.execf(f), n)) + act("recreating", f, "g", m2.execf(f), n) elif n != ma[f]: if ui.prompt( (_("remote changed %s which local deleted\n") % f) + _("(k)eep or (d)elete?"), _("[kd]"), _("k")) == _("k"): - action.append((f, "g", m2.execf(f), n)) - else: - ui.debug(_("local deleted %s\n") % f) + act("prompt recreating", f, "g", m2.execf(f), n) else: - ui.debug(_("remote created %s\n") % f) - action.append((f, "g", m2.execf(f), n)) + act("remote created", f, "g", m2.execf(f), n) return action
--- a/tests/test-merge7.out Sun Sep 17 21:11:26 2006 -0500 +++ b/tests/test-merge7.out Sun Sep 17 21:27:30 2006 -0500 @@ -24,7 +24,7 @@ resolving manifests overwrite None branchmerge True partial False ancestor 451c744aabcc local a070d41e8360 remote faaea63e63a9 - test.txt versions differ, resolve + test.txt: versions differ -> m merging test.txt resolving test.txt file test.txt: my fc3148072371 other d40249267ae3 ancestor 8fe46a3eb557
--- a/tests/test-up-local-change.out Sun Sep 17 21:11:26 2006 -0500 +++ b/tests/test-up-local-change.out Sun Sep 17 21:27:30 2006 -0500 @@ -17,8 +17,8 @@ resolving manifests overwrite False branchmerge False partial False ancestor 33aaa84a386b local 802f095af299 remote 33aaa84a386b - a versions differ, resolve -remote created b + a: versions differ -> m + b: remote created -> g merging a resolving a file a: my b789fdd96dc2 other d730145abbf9 ancestor b789fdd96dc2 @@ -33,7 +33,7 @@ resolving manifests overwrite False branchmerge False partial False ancestor 802f095af299 local 33aaa84a386b remote 33aaa84a386b -remote deleted b, clobbering + b: remote deleted -> r removing b 0 files updated, 0 files merged, 1 files removed, 0 files unresolved changeset: 0:33aaa84a386b @@ -51,8 +51,8 @@ resolving manifests overwrite False branchmerge False partial False ancestor 33aaa84a386b local 802f095af299 remote 33aaa84a386b - a versions differ, resolve -remote created b + a: versions differ -> m + b: remote created -> g merging a resolving a file a: my b789fdd96dc2 other d730145abbf9 ancestor b789fdd96dc2 @@ -102,8 +102,8 @@ resolving manifests overwrite False branchmerge True partial False ancestor 802f095af299 local 030602aee63d remote 33aaa84a386b - a versions differ, resolve - b versions differ, resolve + a: versions differ -> m + b: versions differ -> m merging a resolving a file a: my d730145abbf9 other 13e0d5f949fa ancestor b789fdd96dc2
--- a/tests/test-update-reverse.out Sun Sep 17 21:11:26 2006 -0500 +++ b/tests/test-update-reverse.out Sun Sep 17 21:27:30 2006 -0500 @@ -42,9 +42,9 @@ resolving manifests overwrite True branchmerge False partial False ancestor ded32b0db104 local 221226fb2bd8 remote 537353581d3d -remote deleted side2, clobbering -remote deleted side1, clobbering -remote created main + side2: remote deleted -> r + side1: remote deleted -> r + main: remote created -> g getting main removing side1 removing side2