Bug 2185 - convert: data loss of closed branches with filemap
Summary: convert: data loss of closed branches with filemap
Status: RESOLVED FIXED
Alias: None
Product: Mercurial
Classification: Unclassified
Component: Mercurial (show other bugs)
Version: unspecified
Hardware: All All
: critical bug
Assignee: Bugzilla
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-05-11 11:37 UTC by laurensb
Modified: 2012-05-13 05:01 UTC (History)
4 users (show)

See Also:
Python Version: ---


Attachments
(34 bytes, application/octet-stream)
2010-06-09 10:00 UTC, Mark Booth
Details

Note You need to log in before you can comment on or make changes to this bug.
Description laurensb 2010-05-11 11:37 UTC
When using the convert extension to convert Hg to Hg and using filemap to
rename all files results in closed branches being lost during conversion.

Steps to reproduce:

$ echo "rename . test" > filemap
$ hg init close
$ cd close
$ touch a
$ hg add a
$ hg commit -m "Initial"
$ hg branch close
$ echo 1 >> a
$ hg commit -m "Branched"
$ hg commit --close-branch -m "Closing branch"
$ hg up default
$ echo 2 >> a
$ hg commit -m "2"
$ cd ..
$ hg convert --filemap filemap close

The initial repository has 4 commits, the converted repos only 3.

I believe this is an urgent bug because it causes a silent data loss.
Comment 1 Mark Booth 2010-06-09 10:00 UTC
I've just run through these steps again and confirmed that this is still
happening on version 1.5.4+48-3f1409082720

To summarise:
             close repo:       close-hg repo:
changeset:   3:ca7253831af9 -> 2:117322c80c3b
changeset:   2:e8459779a04d ->    missing
changeset:   1:207dde32e9fd -> 1:0929b4237156
changeset:   0:82a64b6b15fa -> 0:b3ec3982febe

The hg log of the close repo is:
----------------------------------------
changeset:   3:ca7253831af9
tag:         tip
parent:      0:82a64b6b15fa
user:        Mark Booth <mercurial@anang.com>
date:        Wed Jun 09 16:23:24 2010 +0100
summary:     2

changeset:   2:e8459779a04d
branch:      close
user:        Mark Booth <mercurial@anang.com>
date:        Wed Jun 09 16:22:59 2010 +0100
summary:     Closing branch

changeset:   1:207dde32e9fd
branch:      close
user:        Mark Booth <mercurial@anang.com>
date:        Wed Jun 09 16:22:38 2010 +0100
summary:     Branched

changeset:   0:82a64b6b15fa
user:        Mark Booth <mercurial@anang.com>
date:        Wed Jun 09 16:22:02 2010 +0100
summary:     Initial
----------------------------------------

But the hg log of the close-hg repo is:
----------------------------------------
changeset:   2:117322c80c3b
tag:         tip
parent:      0:b3ec3982febe
user:        Mark Booth <mercurial@anang.com>
date:        Wed Jun 09 16:23:24 2010 +0100
summary:     2

changeset:   1:0929b4237156
branch:      close
user:        Mark Booth <mercurial@anang.com>
date:        Wed Jun 09 16:22:38 2010 +0100
summary:     Branched

changeset:   0:b3ec3982febe
user:        Mark Booth <mercurial@anang.com>
date:        Wed Jun 09 16:22:02 2010 +0100
summary:     Initial
----------------------------------------
Comment 2 Matt Mackall 2010-07-23 14:52 UTC
Possible fix:

diff -r 817258259bc9 hgext/convert/filemap.py
--- a/hgext/convert/filemap.py	Thu Jul 22 08:24:56 2010 -0500
+++ b/hgext/convert/filemap.py	Fri Jul 23 15:52:03 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.
diff -r 817258259bc9 hgext/convert/hg.py
--- a/hgext/convert/hg.py	Thu Jul 22 08:24:56 2010 -0500
+++ b/hgext/convert/hg.py	Fri Jul 23 15:52:03 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
Comment 3 Patrick Mézard 2010-10-09 15:31 UTC
Another version of the fix was pushed two months ago:

http://hg.intevation.org/mercurial/crew/rev/a2f11188e2d2
Comment 4 Bugzilla 2012-05-12 09:09 UTC

--- Bug imported by bugzilla@serpentine.com 2012-05-12 09:09 EDT  ---

This bug was previously known as _bug_ 2185 at http://mercurial.selenic.com/bts/issue2185
Imported an attachment (id=1381)