[PATCH 1 of 1 STABLE] patch: separate reverse copy data (issue1959)
Wagner Bruna
wagner.bruna+mercurial at gmail.com
Thu Feb 11 07:18:55 CST 2010
# HG changeset patch
# User Wagner Bruna <wbruna at softwareexpress.com.br>
# Date 1265891706 7200
# Branch stable
# Node ID f7ccdc84f006f213416d44b1543441f920aa39c5
# Parent b8801b58bbd8fe42571e52c0ba8646bb59077efb
patch: separate reverse copy data (issue1959)
diff --git a/mercurial/patch.py b/mercurial/patch.py
--- a/mercurial/patch.py
+++ b/mercurial/patch.py
@@ -1264,8 +1264,7 @@
if opts.git:
copy, diverge = copies.copies(repo, ctx1, ctx2, repo[nullid])
copy = copy.copy()
- for k, v in copy.items():
- copy[v] = k
+ copyto = dict([(v, k) for k, v in copy.items()])
gone = set()
gitmode = {'l': '120000', 'x': '100755', '': '100644'}
@@ -1283,8 +1282,11 @@
if opts.git:
if f in added:
mode = gitmode[ctx2.flags(f)]
- if f in copy:
- a = copy[f]
+ if f in copy or f in copyto:
+ if f in copy:
+ a = copy[f]
+ else:
+ a = copyto[f]
omode = gitmode[man1.flags(a)]
_addmodehdr(header, omode, mode)
if a in removed and a not in gone:
@@ -1301,7 +1303,9 @@
dodiff = 'binary'
elif f in removed:
# have we already reported a copy above?
- if f in copy and copy[f] in added and copy[copy[f]] == f:
+ if f in copy and copy[f] in added and copyto[copy[f]] == f:
+ dodiff = False
+ elif f in copyto and copyto[f] in added and copy[copyto[f]] == f:
dodiff = False
else:
header.append('deleted file mode %s\n' %
diff --git a/tests/test-rename b/tests/test-rename
--- a/tests/test-rename
+++ b/tests/test-rename
@@ -210,6 +210,13 @@
hg status -C
hg update -C
+echo '# overwriting with renames (issue1959)'
+hg rename d1/a d1/c
+hg rename d1/b d1/a
+hg status -C
+hg diff --git
+hg update -C
+
echo "# check illegal path components"
hg rename d1/d11/a1 .hg/foo
diff --git a/tests/test-rename.out b/tests/test-rename.out
--- a/tests/test-rename.out
+++ b/tests/test-rename.out
@@ -300,6 +300,19 @@
# idempotent renames (d1/b -> d1/bb followed by d1/bb -> d1/b)
M d1/b
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+# overwriting with renames (issue1959)
+A d1/a
+ d1/b
+A d1/c
+ d1/a
+R d1/b
+diff --git a/d1/b b/d1/a
+rename from d1/b
+rename to d1/a
+diff --git a/d1/a b/d1/c
+copy from d1/a
+copy to d1/c
+2 files updated, 0 files merged, 1 files removed, 0 files unresolved
# check illegal path components
abort: path contains illegal component: .hg/foo
abort: ../foo not under root
More information about the Mercurial-devel
mailing list