# HG changeset patch # User Wagner Bruna # Date 2012-07-06 04:14:02 # Node ID 32b2e6d641e4281c8711f6c77f8ef56289120613 # Parent dd09bbd48646550a62122efe36b66cb08160e956 convert: make filemap renames consistently override revision renames When the source repository had a revision renaming "$new -> $old", but the filemap a "$old -> $new" rename, the converted revision could use either $new (deleting the file) or $old (keeping the file) when getting the file data, depending on the lexicographical order of those names. So the resulting revision would leave some files untouched (as expected), but delete others arbitrarely. diff --git a/hgext/convert/filemap.py b/hgext/convert/filemap.py --- a/hgext/convert/filemap.py +++ b/hgext/convert/filemap.py @@ -348,12 +348,13 @@ class filemap_source(converter_source): # original filename in the rev part of the return value. changes, copies = self.base.getchanges(rev) newnames = {} - files = [] + files = {} for f, r in changes: newf = self.filemapper(f) - if newf: - files.append((newf, (f, r))) + if newf and (newf != f or newf not in files): + files[newf] = (f, r) newnames[f] = newf + files = sorted(files.items()) ncopies = {} for c in copies: diff --git a/tests/test-convert-filemap.t b/tests/test-convert-filemap.t --- a/tests/test-convert-filemap.t +++ b/tests/test-convert-filemap.t @@ -375,3 +375,36 @@ exercise incremental conversion at the s | o 0 "addb" files: b + +filemap rename undoing revision rename + + $ hg init renameundo + $ cd renameundo + $ echo 1 > a + $ echo 1 > c + $ hg ci -qAm add + $ hg mv -q a b/a + $ hg mv -q c b/c + $ hg ci -qm rename + $ echo 2 > b/a + $ echo 2 > b/c + $ hg ci -qm modify + $ cd .. + + $ echo "rename b ." > renameundo.fmap + $ hg convert --filemap renameundo.fmap renameundo renameundo2 + initializing destination renameundo2 repository + scanning source... + sorting... + converting... + 2 add + 1 rename + filtering out empty revision + repository tip rolled back to revision 0 (undo commit) + 0 modify + $ glog -R renameundo2 + o 1 "modify" files: a c + | + o 0 "add" files: a c + +