convert: handle closed branch heads in hg-hg conversion (issue2185)
authorMatt Mackall <mpm@selenic.com>
Sun, 25 Jul 2010 17:18:35 -0500
changeset 11673 a2f11188e2d2
parent 11672 dad185761392
child 11679 b5f61da929c8
convert: handle closed branch heads in hg-hg conversion (issue2185)
hgext/convert/filemap.py
hgext/convert/hg.py
tests/test-convert-hg-source
tests/test-convert-hg-source.out
--- a/hgext/convert/filemap.py	Sun Jul 25 17:10:32 2010 -0500
+++ b/hgext/convert/filemap.py	Sun Jul 25 17:18:35 2010 -0500
@@ -298,7 +298,9 @@
 
         self.origparents[rev] = parents
 
-        if len(mparents) < 2 and not self.wanted(rev, wp):
+        closed = 'close' in self.commits[rev].extra
+
+        if len(mparents) < 2 and not closed and not self.wanted(rev, wp):
             # We don't want this revision.
             # Update our state and tell the convert process to map this
             # revision to the same revision its parent as mapped to.
--- a/hgext/convert/hg.py	Sun Jul 25 17:10:32 2010 -0500
+++ b/hgext/convert/hg.py	Sun Jul 25 17:18:35 2010 -0500
@@ -175,7 +175,8 @@
         if self.filemapmode and nparents == 1:
             man = self.repo.manifest
             mnode = self.repo.changelog.read(bin(p2))[0]
-            if not man.cmp(m1node, man.revision(mnode)):
+            closed = 'close' in commit.extra
+            if not closed and not man.cmp(m1node, man.revision(mnode)):
                 self.ui.status(_("filtering out empty revision\n"))
                 self.repo.rollback()
                 return parent
--- a/tests/test-convert-hg-source	Sun Jul 25 17:10:32 2010 -0500
+++ b/tests/test-convert-hg-source	Sun Jul 25 17:18:35 2010 -0500
@@ -32,6 +32,10 @@
 chmod +x baz
 hg ci -m 'mark baz executable' -d '5 0'
 
+hg branch foo
+hg ci -m 'branch foo' -d '6 0'
+hg ci --close-branch -m 'close' -d '7 0'
+
 cd ..
 hg convert --datesort orig new 2>&1 | grep -v 'subversion python bindings could not be loaded'
 cd new
--- a/tests/test-convert-hg-source.out	Sun Jul 25 17:10:32 2010 -0500
+++ b/tests/test-convert-hg-source.out	Sun Jul 25 17:18:35 2010 -0500
@@ -7,16 +7,19 @@
 1 files updated, 1 files merged, 0 files removed, 0 files unresolved
 (branch merge, don't forget to commit)
 created new head
+marked working directory as branch foo
 initializing destination new repository
 scanning source...
 sorting...
 converting...
-5 add foo bar
-4 change foo
-3 make bar and baz copies of foo
-2 merge local copy
-1 merge remote copy
-0 mark baz executable
+7 add foo bar
+6 change foo
+5 make bar and baz copies of foo
+4 merge local copy
+3 merge remote copy
+2 mark baz executable
+1 branch foo
+0 close
 comparing with ../orig
 searching for changes
 no changes found