# HG changeset patch # User Alexis S. L. Carvalho # Date 1164058363 7200 # Node ID 4c158de5f245f7ae6cfa4573927021022a60595a # Parent 4bafcf7aeb325f77ab0c61e43c8c1110ee7ee5cd qrefresh: fix handling of copies in the fast path diff -r 4bafcf7aeb32 -r 4c158de5f245 hgext/mq.py --- a/hgext/mq.py Mon Nov 20 19:32:42 2006 -0200 +++ b/hgext/mq.py Mon Nov 20 19:32:43 2006 -0200 @@ -989,6 +989,9 @@ # caching against the next repo.status call # mm, aa, dd, aa2, uu = repo.status(patchparent, tip)[:5] + changes = repo.changelog.read(tip) + man = repo.manifest.read(changes[0]) + aaa = aa[:] if opts.get('short'): filelist = mm + aa + dd else: @@ -1031,12 +1034,30 @@ opts=self.diffopts()) patchf.close() - changes = repo.changelog.read(tip) repo.dirstate.setparents(*cparents) - copies = [(f, repo.dirstate.copied(f)) for f in a] + copies = {} + for dst in a: + src = repo.dirstate.copied(dst) + if src is None: + continue + copies.setdefault(src, []).append(dst) repo.dirstate.update(a, 'a') - for dst, src in copies: - repo.dirstate.copy(src, dst) + # remember the copies between patchparent and tip + # this may be slow, so don't do it if we're not tracking copies + if self.diffopts().git: + for dst in aaa: + f = repo.file(dst) + src = f.renamed(man[dst]) + if src: + copies[src[0]] = copies.get(dst, []) + if dst in a: + copies[src[0]].append(dst) + # we can't copy a file created by the patch itself + if dst in copies: + del copies[dst] + for src, dsts in copies.iteritems(): + for dst in dsts: + repo.dirstate.copy(src, dst) repo.dirstate.update(r, 'r') # if the patch excludes a modified file, mark that file with mtime=0 # so status can see it. diff -r 4bafcf7aeb32 -r 4c158de5f245 tests/test-mq --- a/tests/test-mq Mon Nov 20 19:32:42 2006 -0200 +++ b/tests/test-mq Mon Nov 20 19:32:43 2006 -0200 @@ -227,6 +227,9 @@ hg qrefresh --git 2>&1 | grep -v 'saving bundle' cat .hg/patches/bar hg log -vC --template '{rev} {file_copies%filecopy}\n' -r . +hg qrefresh --git +cat .hg/patches/bar +hg log -vC --template '{rev} {file_copies%filecopy}\n' -r . echo hg up -C 1 @@ -238,3 +241,8 @@ hg qrefresh --git 2>&1 | grep -v 'saving bundle' cat .hg/patches/bar hg log -vC --template '{rev} {file_copies%filecopy}\n' -r . +hg mv quux fred +hg mv bleh barney +hg qrefresh --git +cat .hg/patches/bar +hg log -vC --template '{rev} {file_copies%filecopy}\n' -r . diff -r 4bafcf7aeb32 -r 4c158de5f245 tests/test-mq.out --- a/tests/test-mq.out Mon Nov 20 19:32:42 2006 -0200 +++ b/tests/test-mq.out Mon Nov 20 19:32:43 2006 -0200 @@ -222,6 +222,16 @@ rename from foo rename to baz 2 baz (foo) +diff --git a/bar b/bar +new file mode 100644 +--- /dev/null ++++ b/bar +@@ -0,0 +1,1 @@ ++bar +diff --git a/foo b/baz +rename from foo +rename to baz +2 baz (foo) 1 files updated, 0 files merged, 2 files removed, 0 files unresolved 2 files updated, 0 files merged, 1 files removed, 0 files unresolved @@ -244,3 +254,13 @@ @@ -0,0 +1,1 @@ +bar 3 bleh (foo) +diff --git a/foo b/barney +rename from foo +rename to barney +diff --git a/fred b/fred +new file mode 100644 +--- /dev/null ++++ b/fred +@@ -0,0 +1,1 @@ ++bar +3 barney (foo)