merge with crew

This commit is contained in:
Matt Mackall 2012-05-30 14:31:39 -05:00
commit b49b66c0f2
9 changed files with 92 additions and 33 deletions

View File

@ -177,19 +177,22 @@ def mergecopies(repo, c1, c2, ca):
"diverge" is a mapping of source name -> list of destination names
for divergent renames.
"renamedelete" is a mapping of source name -> list of destination
names for files deleted in c1 that were renamed in c2 or vice-versa.
"""
# avoid silly behavior for update from empty dir
if not c1 or not c2 or c1 == c2:
return {}, {}
return {}, {}, {}
# avoid silly behavior for parent -> working dir
if c2.node() is None and c1.node() == repo.dirstate.p1():
return repo.dirstate.copies(), {}
return repo.dirstate.copies(), {}, {}
limit = _findlimit(repo, c1.rev(), c2.rev())
if limit is None:
# no common ancestor, no copies
return {}, {}
return {}, {}, {}
m1 = c1.manifest()
m2 = c2.manifest()
ma = ca.manifest()
@ -283,26 +286,36 @@ def mergecopies(repo, c1, c2, ca):
for f in u2:
checkcopies(f, m2, m1)
renamedelete = {}
renamedelete2 = set()
diverge2 = set()
for of, fl in diverge.items():
if len(fl) == 1 or of in c2:
if len(fl) == 1 or of in c1 or of in c2:
del diverge[of] # not actually divergent, or not a rename
if of not in c1 and of not in c2:
# renamed on one side, deleted on the other side, but filter
# out files that have been renamed and then deleted
renamedelete[of] = [f for f in fl if f in c1 or f in c2]
renamedelete2.update(fl) # reverse map for below
else:
diverge2.update(fl) # reverse map for below
if fullcopy:
repo.ui.debug(" all copies found (* = to merge, ! = divergent):\n")
repo.ui.debug(" all copies found (* = to merge, ! = divergent, "
"% = renamed and deleted):\n")
for f in fullcopy:
note = ""
if f in copy:
note += "*"
if f in diverge2:
note += "!"
if f in renamedelete2:
note += "%"
repo.ui.debug(" %s -> %s %s\n" % (f, fullcopy[f], note))
del diverge2
if not fullcopy:
return copy, diverge
return copy, diverge, renamedelete
repo.ui.debug(" checking for directory renames\n")
@ -337,7 +350,7 @@ def mergecopies(repo, c1, c2, ca):
del d1, d2, invalid
if not dirmove:
return copy, diverge
return copy, diverge, renamedelete
for d in dirmove:
repo.ui.debug(" dir %s -> %s\n" % (d, dirmove[d]))
@ -354,4 +367,4 @@ def mergecopies(repo, c1, c2, ca):
repo.ui.debug(" file %s -> %s\n" % (f, copy[f]))
break
return copy, diverge
return copy, diverge, renamedelete

View File

@ -198,9 +198,11 @@ def manifestmerge(repo, p1, p2, pa, overwrite, partial):
elif pa == p2: # backwards
pa = p1.p1()
elif pa and repo.ui.configbool("merge", "followcopies", True):
copy, diverge = copies.mergecopies(repo, p1, p2, pa)
copy, diverge, renamedelete = copies.mergecopies(repo, p1, p2, pa)
for of, fl in diverge.iteritems():
act("divergent renames", "dr", of, fl)
for of, fl in renamedelete.iteritems():
act("rename and delete", "rd", of, fl)
repo.ui.note(_("resolving manifests\n"))
repo.ui.debug(" overwrite: %s, partial: %s\n"
@ -409,6 +411,12 @@ def applyupdates(repo, action, wctx, mctx, actx, overwrite):
"multiple times to:\n") % f)
for nf in fl:
repo.ui.warn(" %s\n" % nf)
elif m == "rd": # rename and delete
fl = a[2]
repo.ui.warn(_("note: possible conflict - %s was deleted "
"and renamed to:\n") % f)
for nf in fl:
repo.ui.warn(" %s\n" % nf)
elif m == "e": # exec
flags = a[2]
repo.wopener.audit(f)

View File

@ -24,7 +24,7 @@
unmatched files in other:
b
c
all copies found (* = to merge, ! = divergent):
all copies found (* = to merge, ! = divergent, % = renamed and deleted):
c -> a *
b -> a *
checking for directory renames

View File

@ -29,7 +29,7 @@ we get conflicts that shouldn't be there
searching for copies back to rev 1
unmatched files in other:
bar
all copies found (* = to merge, ! = divergent):
all copies found (* = to merge, ! = divergent, % = renamed and deleted):
bar -> foo *
checking for directory renames
resolving manifests

View File

@ -118,7 +118,7 @@ Graft out of order, skipping a merge and a duplicate
searching for copies back to rev 1
unmatched files in local:
b
all copies found (* = to merge, ! = divergent):
all copies found (* = to merge, ! = divergent, % = renamed and deleted):
b -> a *
checking for directory renames
resolving manifests

View File

@ -28,7 +28,7 @@ http://mercurial.selenic.com/bts/issue672
searching for copies back to rev 1
unmatched files in other:
1a
all copies found (* = to merge, ! = divergent):
all copies found (* = to merge, ! = divergent, % = renamed and deleted):
1a -> 1
checking for directory renames
resolving manifests
@ -59,7 +59,7 @@ http://mercurial.selenic.com/bts/issue672
searching for copies back to rev 1
unmatched files in local:
1a
all copies found (* = to merge, ! = divergent):
all copies found (* = to merge, ! = divergent, % = renamed and deleted):
1a -> 1 *
checking for directory renames
resolving manifests
@ -82,7 +82,7 @@ http://mercurial.selenic.com/bts/issue672
searching for copies back to rev 1
unmatched files in other:
1a
all copies found (* = to merge, ! = divergent):
all copies found (* = to merge, ! = divergent, % = renamed and deleted):
1a -> 1 *
checking for directory renames
resolving manifests

View File

@ -30,7 +30,7 @@
unmatched files in other:
b/a
b/b
all copies found (* = to merge, ! = divergent):
all copies found (* = to merge, ! = divergent, % = renamed and deleted):
b/a -> a/a
b/b -> a/b
checking for directory renames
@ -81,7 +81,7 @@
b/b
unmatched files in other:
a/c
all copies found (* = to merge, ! = divergent):
all copies found (* = to merge, ! = divergent, % = renamed and deleted):
b/a -> a/a
b/b -> a/b
checking for directory renames

View File

@ -28,7 +28,7 @@
unmatched files in other:
b
b2
all copies found (* = to merge, ! = divergent):
all copies found (* = to merge, ! = divergent, % = renamed and deleted):
c2 -> a2 !
b -> a *
b2 -> a2 !
@ -95,9 +95,6 @@ We'd rather not warn on divergent renames done in the same changeset (issue2113)
$ hg up c761c6948de0
1 files updated, 0 files merged, 2 files removed, 0 files unresolved
$ hg up
note: possible conflict - b was renamed multiple times to:
b3
b4
2 files updated, 0 files merged, 1 files removed, 0 files unresolved
Check for issue2642
@ -126,6 +123,8 @@ Check for issue2642
$ cat f2
c0
$ cd ..
Check for issue2089
$ hg init repo2089
@ -155,3 +154,42 @@ Check for issue2089
$ cat f2
c2
$ cd ..
Check for issue3074
$ hg init repo3074
$ cd repo3074
$ echo foo > file
$ hg add file
$ hg commit -m "added file"
$ hg mv file newfile
$ hg commit -m "renamed file"
$ hg update 0
1 files updated, 0 files merged, 1 files removed, 0 files unresolved
$ hg rm file
$ hg commit -m "deleted file"
created new head
$ hg merge --debug
searching for copies back to rev 1
unmatched files in other:
newfile
all copies found (* = to merge, ! = divergent, % = renamed and deleted):
newfile -> file %
checking for directory renames
file: rename and delete -> rd
resolving manifests
overwrite: False, partial: False
ancestor: 19d7f95df299, local: 0084274f6b67+, remote: 5d32493049f0
newfile: remote created -> g
updating: file 1/2 files (50.00%)
note: possible conflict - file was deleted and renamed to:
newfile
updating: newfile 2/2 files (100.00%)
getting newfile
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
(branch merge, don't forget to commit)
$ hg status
M newfile
$ cd ..

View File

@ -80,7 +80,7 @@ $4 = expected result
searching for copies back to rev 1
unmatched files in other:
b
all copies found (* = to merge, ! = divergent):
all copies found (* = to merge, ! = divergent, % = renamed and deleted):
b -> a *
checking for directory renames
resolving manifests
@ -115,7 +115,7 @@ $4 = expected result
searching for copies back to rev 1
unmatched files in local:
b
all copies found (* = to merge, ! = divergent):
all copies found (* = to merge, ! = divergent, % = renamed and deleted):
b -> a *
checking for directory renames
resolving manifests
@ -153,7 +153,7 @@ $4 = expected result
searching for copies back to rev 1
unmatched files in other:
b
all copies found (* = to merge, ! = divergent):
all copies found (* = to merge, ! = divergent, % = renamed and deleted):
b -> a *
checking for directory renames
resolving manifests
@ -188,7 +188,7 @@ $4 = expected result
searching for copies back to rev 1
unmatched files in local:
b
all copies found (* = to merge, ! = divergent):
all copies found (* = to merge, ! = divergent, % = renamed and deleted):
b -> a *
checking for directory renames
resolving manifests
@ -222,7 +222,7 @@ $4 = expected result
searching for copies back to rev 1
unmatched files in other:
b
all copies found (* = to merge, ! = divergent):
all copies found (* = to merge, ! = divergent, % = renamed and deleted):
b -> a
checking for directory renames
resolving manifests
@ -252,7 +252,7 @@ $4 = expected result
searching for copies back to rev 1
unmatched files in local:
b
all copies found (* = to merge, ! = divergent):
all copies found (* = to merge, ! = divergent, % = renamed and deleted):
b -> a
checking for directory renames
resolving manifests
@ -279,7 +279,7 @@ $4 = expected result
searching for copies back to rev 1
unmatched files in other:
b
all copies found (* = to merge, ! = divergent):
all copies found (* = to merge, ! = divergent, % = renamed and deleted):
b -> a
checking for directory renames
resolving manifests
@ -311,7 +311,7 @@ $4 = expected result
searching for copies back to rev 1
unmatched files in local:
b
all copies found (* = to merge, ! = divergent):
all copies found (* = to merge, ! = divergent, % = renamed and deleted):
b -> a
checking for directory renames
resolving manifests
@ -369,7 +369,7 @@ m "um a c" "um x c" " " "10 do merge with no ancestor"
b
unmatched files in other:
c
all copies found (* = to merge, ! = divergent):
all copies found (* = to merge, ! = divergent, % = renamed and deleted):
c -> a !
b -> a !
checking for directory renames
@ -648,7 +648,7 @@ m "um a c" "um x c" " " "10 do merge with no ancestor"
searching for copies back to rev 1
unmatched files in other:
b
all copies found (* = to merge, ! = divergent):
all copies found (* = to merge, ! = divergent, % = renamed and deleted):
b -> a *
checking for directory renames
resolving manifests
@ -682,7 +682,7 @@ m "um a c" "um x c" " " "10 do merge with no ancestor"
searching for copies back to rev 1
unmatched files in local:
b
all copies found (* = to merge, ! = divergent):
all copies found (* = to merge, ! = divergent, % = renamed and deleted):
b -> a *
checking for directory renames
resolving manifests
@ -720,7 +720,7 @@ m "nm a b" "um x a" " " "22 get a, keep b"
b
unmatched files in other:
c
all copies found (* = to merge, ! = divergent):
all copies found (* = to merge, ! = divergent, % = renamed and deleted):
b -> a *
checking for directory renames
resolving manifests