Patchwork [STABLE] bundlerepo: disable filtering of changelog while constructing revision text

login
register
mail settings
Submitter Yuya Nishihara
Date April 29, 2015, 2:41 p.m.
Message ID <73b0e11a9cb8fea9b4f0.1430318473@mimosa>
Download mbox | patch
Permalink /patch/8815/
State Accepted
Commit 995003a324da67242e5c4e9afa18fe9d335f9985
Headers show

Comments

Yuya Nishihara - April 29, 2015, 2:41 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1430304457 -32400
#      Wed Apr 29 19:47:37 2015 +0900
# Branch stable
# Node ID 73b0e11a9cb8fea9b4f0a4ce4267409e8f2054cd
# Parent  cc497780eaf9c191564c64b40ca549f706c62724
bundlerepo: disable filtering of changelog while constructing revision text

This avoids the following error that happened if base revision of bundle file
was hidden. bundlerevlog needs it to construct revision texts from bundle
content as revlog.revision() does.

  File "mercurial/context.py", line 485, in _changeset
    return self._repo.changelog.read(self.rev())
  File "mercurial/changelog.py", line 319, in read
    text = self.revision(node)
  File "mercurial/bundlerepo.py", line 124, in revision
    text = self.baserevision(iterrev)
  File "mercurial/bundlerepo.py", line 160, in baserevision
    return changelog.changelog.revision(self, nodeorrev)
  File "mercurial/revlog.py", line 1041, in revision
    node = self.node(rev)
  File "mercurial/changelog.py", line 211, in node
    raise error.FilteredIndexError(rev)
  mercurial.error.FilteredIndexError: 1
Pierre-Yves David - April 29, 2015, 9:17 p.m.
On 04/29/2015 07:41 AM, Yuya Nishihara wrote:
> # HG changeset patch
> # User Yuya Nishihara <yuya@tcha.org>
> # Date 1430304457 -32400
> #      Wed Apr 29 19:47:37 2015 +0900
> # Branch stable
> # Node ID 73b0e11a9cb8fea9b4f0a4ce4267409e8f2054cd
> # Parent  cc497780eaf9c191564c64b40ca549f706c62724
> bundlerepo: disable filtering of changelog while constructing revision text
>
> This avoids the following error that happened if base revision of bundle file
> was hidden. bundlerevlog needs it to construct revision texts from bundle
> content as revlog.revision() does.
>
>    File "mercurial/context.py", line 485, in _changeset
>      return self._repo.changelog.read(self.rev())
>    File "mercurial/changelog.py", line 319, in read
>      text = self.revision(node)
>    File "mercurial/bundlerepo.py", line 124, in revision
>      text = self.baserevision(iterrev)
>    File "mercurial/bundlerepo.py", line 160, in baserevision
>      return changelog.changelog.revision(self, nodeorrev)
>    File "mercurial/revlog.py", line 1041, in revision
>      node = self.node(rev)
>    File "mercurial/changelog.py", line 211, in node
>      raise error.FilteredIndexError(rev)
>    mercurial.error.FilteredIndexError: 1

The issue is real and the fix seems to be working, but it cross my eyes 
a bit.

 From what I understand, baserevision will never be called it the 
revision is in the repository already. So, there there is alway a chain 
to apply (so the bypass of filtering for revision X will never be used 
for accessing revision X text itself?

I would be happier if we could just call the unfiltered changelog, but 
this seems impractical.

So the change seems okay to me, I'll let Matt queue it.
Matt Mackall - April 29, 2015, 9:24 p.m.
On Wed, 2015-04-29 at 14:17 -0700, Pierre-Yves David wrote:
> 
> On 04/29/2015 07:41 AM, Yuya Nishihara wrote:
> > # HG changeset patch
> > # User Yuya Nishihara <yuya@tcha.org>
> > # Date 1430304457 -32400
> > #      Wed Apr 29 19:47:37 2015 +0900
> > # Branch stable
> > # Node ID 73b0e11a9cb8fea9b4f0a4ce4267409e8f2054cd
> > # Parent  cc497780eaf9c191564c64b40ca549f706c62724
> > bundlerepo: disable filtering of changelog while constructing revision text
> >
> > This avoids the following error that happened if base revision of bundle file
> > was hidden. bundlerevlog needs it to construct revision texts from bundle
> > content as revlog.revision() does.
> >
> >    File "mercurial/context.py", line 485, in _changeset
> >      return self._repo.changelog.read(self.rev())
> >    File "mercurial/changelog.py", line 319, in read
> >      text = self.revision(node)
> >    File "mercurial/bundlerepo.py", line 124, in revision
> >      text = self.baserevision(iterrev)
> >    File "mercurial/bundlerepo.py", line 160, in baserevision
> >      return changelog.changelog.revision(self, nodeorrev)
> >    File "mercurial/revlog.py", line 1041, in revision
> >      node = self.node(rev)
> >    File "mercurial/changelog.py", line 211, in node
> >      raise error.FilteredIndexError(rev)
> >    mercurial.error.FilteredIndexError: 1
> 
> The issue is real and the fix seems to be working, but it cross my eyes 
> a bit.
> 
>  From what I understand, baserevision will never be called it the 
> revision is in the repository already. So, there there is alway a chain 
> to apply (so the bypass of filtering for revision X will never be used 
> for accessing revision X text itself?
> 
> I would be happier if we could just call the unfiltered changelog, but 
> this seems impractical.
> 
> So the change seems okay to me, I'll let Matt queue it.

Queued, thanks guys!

Patch

diff --git a/mercurial/bundlerepo.py b/mercurial/bundlerepo.py
--- a/mercurial/bundlerepo.py
+++ b/mercurial/bundlerepo.py
@@ -157,7 +157,15 @@  class bundlechangelog(bundlerevlog, chan
         # Although changelog doesn't override 'revision' method, some extensions
         # may replace this class with another that does. Same story with
         # manifest and filelog classes.
-        return changelog.changelog.revision(self, nodeorrev)
+
+        # This bypasses filtering on changelog.node() and rev() because we need
+        # revision text of the bundle base even if it is hidden.
+        oldfilter = self.filteredrevs
+        try:
+            self.filteredrevs = ()
+            return changelog.changelog.revision(self, nodeorrev)
+        finally:
+            self.filteredrevs = oldfilter
 
 class bundlemanifest(bundlerevlog, manifest.manifest):
     def __init__(self, opener, bundle, linkmapper):
diff --git a/tests/test-obsolete.t b/tests/test-obsolete.t
--- a/tests/test-obsolete.t
+++ b/tests/test-obsolete.t
@@ -789,6 +789,62 @@  Test that removing a local tag does not 
   visible                            0:193e9254ce7e
   tip                                0:193e9254ce7e
 
+Test bundle overlay onto hidden revision
+
+  $ cd ..
+  $ hg init repo-bundleoverlay
+  $ cd repo-bundleoverlay
+  $ echo "A" > foo
+  $ hg ci -Am "A"
+  adding foo
+  $ echo "B" >> foo
+  $ hg ci -m "B"
+  $ hg up 0
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ echo "C" >> foo
+  $ hg ci -m "C"
+  created new head
+  $ hg log -G
+  @  2:c186d7714947 (draft) [tip ] C
+  |
+  | o  1:44526ebb0f98 (draft) [ ] B
+  |/
+  o  0:4b34ecfb0d56 (draft) [ ] A
+  
+
+  $ hg clone -r1 . ../other-bundleoverlay
+  adding changesets
+  adding manifests
+  adding file changes
+  added 2 changesets with 2 changes to 1 files
+  updating to branch default
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ cd ../other-bundleoverlay
+  $ echo "B+" >> foo
+  $ hg ci --amend -m "B+"
+  $ hg log -G --hidden
+  @  3:b7d587542d40 (draft) [tip ] B+
+  |
+  | x  2:eb95e9297e18 (draft) [ ] temporary amend commit for 44526ebb0f98
+  | |
+  | x  1:44526ebb0f98 (draft) [ ] B
+  |/
+  o  0:4b34ecfb0d56 (draft) [ ] A
+  
+
+  $ hg incoming ../repo-bundleoverlay --bundle ../bundleoverlay.hg
+  comparing with ../repo-bundleoverlay
+  searching for changes
+  1:44526ebb0f98 (draft) [ ] B
+  2:c186d7714947 (draft) [tip ] C
+  $ hg log -G -R ../bundleoverlay.hg
+  o  4:c186d7714947 (draft) [tip ] C
+  |
+  | @  3:b7d587542d40 (draft) [ ] B+
+  |/
+  o  0:4b34ecfb0d56 (draft) [ ] A
+  
+
 #if serve
 
 Test issue 4506