Patchwork [2,of,2,stable] convert: fix bad conversion of copies when hg.startrev is specified

login
register
mail settings
Submitter Mads Kiilerich
Date July 18, 2013, 11:43 p.m.
Message ID <f816b7fcf9fe1104c7bc.1374191005@mk-desktop>
Download mbox | patch
Permalink /patch/1933/
State Accepted
Commit 948df0f10ec13a837079e835481900d7da904244
Headers show

Comments

Mads Kiilerich - July 18, 2013, 11:43 p.m.
# HG changeset patch
# User Mads Kiilerich <madski@unity3d.com>
# Date 1374190857 -7200
#      Fri Jul 19 01:40:57 2013 +0200
# Branch stable
# Node ID f816b7fcf9fe1104c7bcb1c5a1cd287bd5162e6f
# Parent  0486fd0e7557afc12d88ee6ee4d0689683165c43
convert: fix bad conversion of copies when hg.startrev is specified

The 'copynode' was looked up in self.keep as if it was a changeset node. It is
however a filelog node, and self.keep would thus fail if it actually looked at
its parameter ... which it only did if a startrev was specified.

Instead we now don't check the copy node - we don't have to. It must have been
copied from one of the parents, and we already check whether one of the parents
have the copy source.

We could perhaps use linkrev to see if the corresponding changeset was
converted ... but that would sometimes be wrong.

The existing test of this was wrong - now it is better, but it seems like it
exposes a 'log' issue.
Matt Mackall - July 19, 2013, 12:04 a.m.
On Fri, 2013-07-19 at 01:43 +0200, Mads Kiilerich wrote:
> # HG changeset patch
> # User Mads Kiilerich <madski@unity3d.com>
> # Date 1374190857 -7200
> #      Fri Jul 19 01:40:57 2013 +0200
> # Branch stable
> # Node ID f816b7fcf9fe1104c7bcb1c5a1cd287bd5162e6f
> # Parent  0486fd0e7557afc12d88ee6ee4d0689683165c43
> convert: fix bad conversion of copies when hg.startrev is specified

Queued for default, which will become stable in the next few hours.

Patch

diff --git a/hgext/convert/hg.py b/hgext/convert/hg.py
--- a/hgext/convert/hg.py
+++ b/hgext/convert/hg.py
@@ -316,8 +316,8 @@ 
             if name in self.ignored:
                 continue
             try:
-                copysource, copynode = ctx.filectx(name).renamed()
-                if copysource in self.ignored or not self.keep(copynode):
+                copysource, _copynode = ctx.filectx(name).renamed()
+                if copysource in self.ignored:
                     continue
                 # Ignore copy sources not in parent revisions
                 found = False
diff --git a/tests/test-convert-hg-startrev.t b/tests/test-convert-hg-startrev.t
--- a/tests/test-convert-hg-startrev.t
+++ b/tests/test-convert-hg-startrev.t
@@ -120,16 +120,26 @@ 
 
 Check copy preservation
 
+  $ hg st -C --change 2 e
+  M e
+  $ hg st -C --change 1 e
+  A e
+    a
+  $ hg st -C --change 0 a
+  A a
+
+(It seems like a bug in log that the following doesn't show rev 1.)
+
   $ hg log --follow --copies e
-  changeset:   2:60633ee11cfa
+  changeset:   2:82bbac3d2cf4
   user:        test
   date:        Thu Jan 01 00:00:04 1970 +0000
   summary:     4: merge 2 and 3
   
-  changeset:   1:d56e8baefff8
+  changeset:   0:23c3be426dce
   user:        test
-  date:        Thu Jan 01 00:00:02 1970 +0000
-  summary:     2: copy e from a, change b
+  date:        Thu Jan 01 00:00:01 1970 +0000
+  summary:     1: add c, move f to d
   
 Check copy removal on missing parent