Patchwork linkrev: use the right manifest content when adjusting linrev (issue4499)

login
register
mail settings
Submitter Pierre-Yves David
Date Jan. 15, 2015, 1:26 a.m.
Message ID <ab44a72d59209a4b2158.1421285201@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/7463/
State Accepted
Headers show

Comments

Pierre-Yves David - Jan. 15, 2015, 1:26 a.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@fb.com>
# Date 1421284869 28800
#      Wed Jan 14 17:21:09 2015 -0800
# Node ID ab44a72d59209a4b21581a7f7f8de777fa69aea8
# Parent  6c44cef5baa231dbfa311475f56f60b2dc4a7b4d
linkrev: use the right manifest content when adjusting linrev (issue4499)

When the manifest revision is stored as a delta against a non-parent revision,
'_adjustlinkrev' could miss some file update because it was using the delta
only. We now use the 'fastread' method that uses the delta only when it makes
sense.

A test showcasing on the of possible issue have been added.
Matt Mackall - Jan. 15, 2015, 1:35 a.m.
On Wed, 2015-01-14 at 17:26 -0800, Pierre-Yves David wrote:
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david@fb.com>
> # Date 1421284869 28800
> #      Wed Jan 14 17:21:09 2015 -0800
> # Node ID ab44a72d59209a4b21581a7f7f8de777fa69aea8
> # Parent  6c44cef5baa231dbfa311475f56f60b2dc4a7b4d
> linkrev: use the right manifest content when adjusting linrev (issue4499)

Queued for default, thanks.

Patch

diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -47,11 +47,11 @@  def _adjustlinkrev(repo, path, filelog, 
         for a in anc:
             ac = cl.read(a) # get changeset data (we avoid object creation).
             if path in ac[3]: # checking the 'files' field.
                 # The file has been touched, check if the content is similar
                 # to the one we search for.
-                if fnode == ma.readdelta(ac[0]).get(path):
+                if fnode == ma.readfast(ac[0]).get(path):
                     return a
         # In theory, we should never get out of that loop without a result. But
         # if manifest uses a buggy file revision (not children of the one it
         # replaces) we could. Such a buggy situation will likely result is crash
         # somewhere else at to some point.
diff --git a/tests/test-log.t b/tests/test-log.t
--- a/tests/test-log.t
+++ b/tests/test-log.t
@@ -1840,5 +1840,64 @@  Even when the file revision is missing f
   |  parent:      0:f7b1eb17ad24
   |  user:        test
   |  date:        Thu Jan 01 00:00:00 1970 +0000
   |  summary:     1
   |
+  $ cd ..
+
+Check proper report when the manifest changes but not the file issue4499
+------------------------------------------------------------------------
+
+  $ hg init issue4499
+  $ cd issue4499
+  $ for f in A B C D F E G H I J K L M N O P Q R S T U; do
+  >     echo 1 > $f;
+  >     hg add $f;
+  > done
+  $ hg commit -m 'A1B1C1'
+  $ echo 2 > A
+  $ echo 2 > B
+  $ echo 2 > C
+  $ hg commit -m 'A2B2C2'
+  $ hg up 0
+  3 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ echo 3 > A
+  $ echo 2 > B
+  $ echo 2 > C
+  $ hg commit -m 'A3B2C2'
+  created new head
+
+  $ hg log -G
+  @  changeset:   2:fe5fc3d0eb17
+  |  tag:         tip
+  |  parent:      0:abf4f0e38563
+  |  user:        test
+  |  date:        Thu Jan 01 00:00:00 1970 +0000
+  |  summary:     A3B2C2
+  |
+  | o  changeset:   1:07dcc6b312c0
+  |/   user:        test
+  |    date:        Thu Jan 01 00:00:00 1970 +0000
+  |    summary:     A2B2C2
+  |
+  o  changeset:   0:abf4f0e38563
+     user:        test
+     date:        Thu Jan 01 00:00:00 1970 +0000
+     summary:     A1B1C1
+  
+
+Log -f on B should reports current changesets
+
+  $ hg log -fG B
+  @  changeset:   2:fe5fc3d0eb17
+  |  tag:         tip
+  |  parent:      0:abf4f0e38563
+  |  user:        test
+  |  date:        Thu Jan 01 00:00:00 1970 +0000
+  |  summary:     A3B2C2
+  |
+  o  changeset:   0:abf4f0e38563
+     user:        test
+     date:        Thu Jan 01 00:00:00 1970 +0000
+     summary:     A1B1C1
+  
+  $ cd ..