mercurial/crew
changeset 10466:d1f209bb9564 stable
patch: separate reverse copy data (issue1959)
| author | Wagner Bruna <wbruna@softwareexpress.com.br> |
|---|---|
| date | Thu Feb 11 11:22:57 2010 -0200 (5 months ago) |
| parents | 5d7e84e7ac6d |
| children | 16c68fd720ab |
| files | mercurial/patch.py tests/test-rename tests/test-rename.out |
line diff
1.1 --- a/mercurial/patch.py 1.2 +++ b/mercurial/patch.py 1.3 @@ -1436,8 +1436,6 @@ 1.4 if opts.git or opts.upgrade: 1.5 copy = copies.copies(repo, ctx1, ctx2, repo[nullid])[0] 1.6 copy = copy.copy() 1.7 - for k, v in copy.items(): 1.8 - copy[v] = k 1.9 1.10 difffn = lambda opts, losedata: trydiff(repo, revs, ctx1, ctx2, 1.11 modified, added, removed, copy, getfilectx, opts, losedata) 1.12 @@ -1467,6 +1465,8 @@ 1.13 gone = set() 1.14 gitmode = {'l': '120000', 'x': '100755', '': '100644'} 1.15 1.16 + copyto = dict([(v, k) for k, v in copy.items()]) 1.17 + 1.18 if opts.git: 1.19 revs = None 1.20 1.21 @@ -1483,9 +1483,12 @@ 1.22 if opts.git or losedatafn: 1.23 if f in added: 1.24 mode = gitmode[ctx2.flags(f)] 1.25 - if f in copy: 1.26 + if f in copy or f in copyto: 1.27 if opts.git: 1.28 - a = copy[f] 1.29 + if f in copy: 1.30 + a = copy[f] 1.31 + else: 1.32 + a = copyto[f] 1.33 omode = gitmode[man1.flags(a)] 1.34 _addmodehdr(header, omode, mode) 1.35 if a in removed and a not in gone: 1.36 @@ -1514,7 +1517,9 @@ 1.37 elif f in removed: 1.38 if opts.git: 1.39 # have we already reported a copy above? 1.40 - if f in copy and copy[f] in added and copy[copy[f]] == f: 1.41 + if f in copy and copy[f] in added and copyto[copy[f]] == f: 1.42 + dodiff = False 1.43 + elif f in copyto and copyto[f] in added and copy[copyto[f]] == f: 1.44 dodiff = False 1.45 else: 1.46 header.append('deleted file mode %s\n' %
2.1 --- a/tests/test-rename 2.2 +++ b/tests/test-rename 2.3 @@ -210,6 +210,13 @@ 2.4 hg status -C 2.5 hg update -C 2.6 2.7 +echo '# overwriting with renames (issue1959)' 2.8 +hg rename d1/a d1/c 2.9 +hg rename d1/b d1/a 2.10 +hg status -C 2.11 +hg diff --git 2.12 +hg update -C 2.13 + 2.14 echo "# check illegal path components" 2.15 2.16 hg rename d1/d11/a1 .hg/foo
3.1 --- a/tests/test-rename.out 3.2 +++ b/tests/test-rename.out 3.3 @@ -300,6 +300,19 @@ 3.4 # idempotent renames (d1/b -> d1/bb followed by d1/bb -> d1/b) 3.5 M d1/b 3.6 1 files updated, 0 files merged, 0 files removed, 0 files unresolved 3.7 +# overwriting with renames (issue1959) 3.8 +A d1/a 3.9 + d1/b 3.10 +A d1/c 3.11 + d1/a 3.12 +R d1/b 3.13 +diff --git a/d1/b b/d1/a 3.14 +rename from d1/b 3.15 +rename to d1/a 3.16 +diff --git a/d1/a b/d1/c 3.17 +copy from d1/a 3.18 +copy to d1/c 3.19 +2 files updated, 0 files merged, 1 files removed, 0 files unresolved 3.20 # check illegal path components 3.21 abort: path contains illegal component: .hg/foo 3.22 abort: ../foo not under root
