Patchwork [fix-for-default-bug] revset-filelog: handle hidden linkrev for file missing for head (issue4490)

login
register
mail settings
Submitter Pierre-Yves David
Date Jan. 6, 2015, 7:27 p.m.
Message ID <0aa285ba9d48ac26c4d4.1420572422@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/7338/
State Accepted
Commit 07a6faf939dc6f1342580a63463461f5b0d3b9f6
Headers show

Comments

Pierre-Yves David - Jan. 6, 2015, 7:27 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@fb.com>
# Date 1420572218 28800
#      Tue Jan 06 11:23:38 2015 -0800
# Node ID 0aa285ba9d48ac26c4d49730b2b2b271af1702f0
# Parent  d944492445fa0d0b9c164336afab68127080a1f3
revset-filelog: handle hidden linkrev for file missing for head (issue4490)

The fix for linkrev pointing to hidden revision was crashing when the file was
missing from head's manifest. We now properly handle this case.

(yes I feel silly)
Matt Mackall - Jan. 6, 2015, 8:47 p.m.
On Tue, 2015-01-06 at 11:27 -0800, Pierre-Yves David wrote:
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david@fb.com>
> # Date 1420572218 28800
> #      Tue Jan 06 11:23:38 2015 -0800
> # Node ID 0aa285ba9d48ac26c4d49730b2b2b271af1702f0
> # Parent  d944492445fa0d0b9c164336afab68127080a1f3
> revset-filelog: handle hidden linkrev for file missing for head (issue4490)

Queued for default, thanks.

Patch

diff --git a/mercurial/revset.py b/mercurial/revset.py
--- a/mercurial/revset.py
+++ b/mercurial/revset.py
@@ -835,12 +835,13 @@  def filelog(repo, subset, x):
                 #   and be in the other 'else' clause,
                 # - all versions of the revision are hidden.
                 if lowesthead is None:
                     lowesthead = {}
                     for h in repo.heads():
-                        fnode = repo[h].manifest()[f]
-                        lowesthead[fl.rev(fnode)] = h
+                        fnode = repo[h].manifest().get(f)
+                        if fnode is not None:
+                            lowesthead[fl.rev(fnode)] = h
                 headrev = lowesthead.get(fr)
                 if headrev is None:
                     # content is nowhere unfiltered
                     continue
                 rev = repo[headrev][f].introrev()
diff --git a/tests/test-log.t b/tests/test-log.t
--- a/tests/test-log.t
+++ b/tests/test-log.t
@@ -1742,5 +1742,61 @@  Even when a head revision is linkrev-sha
      date:        Thu Jan 01 00:00:00 1970 +0000
      summary:     content1
   
 
   $ cd ..
+
+Even when the file revision is missing from some head:
+
+  $ hg init issue4490
+  $ cd issue4490
+  $ echo '[experimental]' >> .hg/hgrc
+  $ echo 'evolution=createmarkers' >> .hg/hgrc
+  $ echo a > a
+  $ hg ci -Am0
+  adding a
+  $ echo b > b
+  $ hg ci -Am1
+  adding b
+  $ echo B > b
+  $ hg ci --amend -m 1
+  $ hg up 0
+  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
+  $ echo c > c
+  $ hg ci -Am2
+  adding c
+  created new head
+  $ hg up 'head() and not .'
+  1 files updated, 0 files merged, 1 files removed, 0 files unresolved
+  $ hg log -G
+  o  changeset:   4:db815d6d32e6
+  |  tag:         tip
+  |  parent:      0:f7b1eb17ad24
+  |  user:        test
+  |  date:        Thu Jan 01 00:00:00 1970 +0000
+  |  summary:     2
+  |
+  | @  changeset:   3:9bc8ce7f9356
+  |/   parent:      0:f7b1eb17ad24
+  |    user:        test
+  |    date:        Thu Jan 01 00:00:00 1970 +0000
+  |    summary:     1
+  |
+  o  changeset:   0:f7b1eb17ad24
+     user:        test
+     date:        Thu Jan 01 00:00:00 1970 +0000
+     summary:     0
+  
+  $ hg log -f -G b
+  @  changeset:   3:9bc8ce7f9356
+  |  parent:      0:f7b1eb17ad24
+  |  user:        test
+  |  date:        Thu Jan 01 00:00:00 1970 +0000
+  |  summary:     1
+  |
+  $ hg log -G b
+  @  changeset:   3:9bc8ce7f9356
+  |  parent:      0:f7b1eb17ad24
+  |  user:        test
+  |  date:        Thu Jan 01 00:00:00 1970 +0000
+  |  summary:     1
+  |