Patchwork bundlerepo: properly hidden revision in bundle (issue4945)

login
register
mail settings
Submitter Pierre-Yves David
Date Feb. 22, 2016, 5:45 p.m.
Message ID <c3f0732d8bfcda5c430b.1456163102@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/13300/
State Accepted
Headers show

Comments

Pierre-Yves David - Feb. 22, 2016, 5:45 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@fb.com>
# Date 1456162540 -3600
#      Mon Feb 22 18:35:40 2016 +0100
# Node ID c3f0732d8bfcda5c430b5bf0fc21e22580fa8bbc
# Parent  28e1694ca60056d609ae2c8e0ad5cb2891416ea3
# Available At http://hg.netv6.net/marmoute-wip/mercurial/
#              hg pull http://hg.netv6.net/marmoute-wip/mercurial/ -r c3f0732d8bfc
bundlerepo: properly hidden revision in bundle (issue4945)

The bundlerepository have to do some special magic to handle linkrev of the
bundled filerev. That logic was done from a repoview and obsolescence marker
affecting bundled changeset could lead to a crash. We now ensure we operate on
unfiltered repository.
Sean Farley - Feb. 22, 2016, 9:52 p.m.
Pierre-Yves David <pierre-yves.david@ens-lyon.org> writes:

> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david@fb.com>
> # Date 1456162540 -3600
> #      Mon Feb 22 18:35:40 2016 +0100
> # Node ID c3f0732d8bfcda5c430b5bf0fc21e22580fa8bbc
> # Parent  28e1694ca60056d609ae2c8e0ad5cb2891416ea3
> # Available At http://hg.netv6.net/marmoute-wip/mercurial/
> #              hg pull http://hg.netv6.net/marmoute-wip/mercurial/ -r c3f0732d8bfc
> bundlerepo: properly hidden revision in bundle (issue4945)
>
> The bundlerepository have to do some special magic to handle linkrev of the
> bundled filerev. That logic was done from a repoview and obsolescence marker
> affecting bundled changeset could lead to a crash. We now ensure we operate on
> unfiltered repository.
>
> diff --git a/mercurial/bundlerepo.py b/mercurial/bundlerepo.py
> --- a/mercurial/bundlerepo.py
> +++ b/mercurial/bundlerepo.py
> @@ -360,11 +360,12 @@ class bundlerepository(localrepo.localre
>                      if not c:
>                          break
>  
>          if f in self.bundlefilespos:
>              self.bundle.seek(self.bundlefilespos[f])
> -            return bundlefilelog(self.svfs, f, self.bundle, self.changelog.rev)
> +            linkmapper = self.unfiltered().changelog.rev
> +            return bundlefilelog(self.svfs, f, self.bundle, linkmapper)

Would this logic also be the same to fix issue5070?
http://bz.mercurial-scm.org/show_bug.cgi?id=5070
Pierre-Yves David - Feb. 22, 2016, 10:17 p.m.
On 02/22/2016 10:52 PM, Sean Farley wrote:
>
> Pierre-Yves David <pierre-yves.david@ens-lyon.org> writes:
>
>> # HG changeset patch
>> # User Pierre-Yves David <pierre-yves.david@fb.com>
>> # Date 1456162540 -3600
>> #      Mon Feb 22 18:35:40 2016 +0100
>> # Node ID c3f0732d8bfcda5c430b5bf0fc21e22580fa8bbc
>> # Parent  28e1694ca60056d609ae2c8e0ad5cb2891416ea3
>> # Available At http://hg.netv6.net/marmoute-wip/mercurial/
>> #              hg pull http://hg.netv6.net/marmoute-wip/mercurial/ -r c3f0732d8bfc
>> bundlerepo: properly hidden revision in bundle (issue4945)
>>
>> The bundlerepository have to do some special magic to handle linkrev of the
>> bundled filerev. That logic was done from a repoview and obsolescence marker
>> affecting bundled changeset could lead to a crash. We now ensure we operate on
>> unfiltered repository.
>>
>> diff --git a/mercurial/bundlerepo.py b/mercurial/bundlerepo.py
>> --- a/mercurial/bundlerepo.py
>> +++ b/mercurial/bundlerepo.py
>> @@ -360,11 +360,12 @@ class bundlerepository(localrepo.localre
>>                       if not c:
>>                           break
>>
>>           if f in self.bundlefilespos:
>>               self.bundle.seek(self.bundlefilespos[f])
>> -            return bundlefilelog(self.svfs, f, self.bundle, self.changelog.rev)
>> +            linkmapper = self.unfiltered().changelog.rev
>> +            return bundlefilelog(self.svfs, f, self.bundle, linkmapper)
>
> Would this logic also be the same to fix issue5070?
> http://bz.mercurial-scm.org/show_bug.cgi?id=5070

Probably. do you have a traceback handy?
Sean Farley - Feb. 22, 2016, 10:19 p.m.
Pierre-Yves David <pierre-yves.david@ens-lyon.org> writes:

> On 02/22/2016 10:52 PM, Sean Farley wrote:
>>
>> Pierre-Yves David <pierre-yves.david@ens-lyon.org> writes:
>>
>>> # HG changeset patch
>>> # User Pierre-Yves David <pierre-yves.david@fb.com>
>>> # Date 1456162540 -3600
>>> #      Mon Feb 22 18:35:40 2016 +0100
>>> # Node ID c3f0732d8bfcda5c430b5bf0fc21e22580fa8bbc
>>> # Parent  28e1694ca60056d609ae2c8e0ad5cb2891416ea3
>>> # Available At http://hg.netv6.net/marmoute-wip/mercurial/
>>> #              hg pull http://hg.netv6.net/marmoute-wip/mercurial/ -r c3f0732d8bfc
>>> bundlerepo: properly hidden revision in bundle (issue4945)
>>>
>>> The bundlerepository have to do some special magic to handle linkrev of the
>>> bundled filerev. That logic was done from a repoview and obsolescence marker
>>> affecting bundled changeset could lead to a crash. We now ensure we operate on
>>> unfiltered repository.
>>>
>>> diff --git a/mercurial/bundlerepo.py b/mercurial/bundlerepo.py
>>> --- a/mercurial/bundlerepo.py
>>> +++ b/mercurial/bundlerepo.py
>>> @@ -360,11 +360,12 @@ class bundlerepository(localrepo.localre
>>>                       if not c:
>>>                           break
>>>
>>>           if f in self.bundlefilespos:
>>>               self.bundle.seek(self.bundlefilespos[f])
>>> -            return bundlefilelog(self.svfs, f, self.bundle, self.changelog.rev)
>>> +            linkmapper = self.unfiltered().changelog.rev
>>> +            return bundlefilelog(self.svfs, f, self.bundle, linkmapper)
>>
>> Would this logic also be the same to fix issue5070?
>> http://bz.mercurial-scm.org/show_bug.cgi?id=5070
>
> Probably. do you have a traceback handy?

From the script on the issue (I'll update the report with this output):

./script.py
P1 hidden: False
P2 hidden: False
CMP:
Traceback (most recent call last):
  File "./script.py", line 20, in <module>
    print "CMP:", fctx.cmp(p2.filectx(f))
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/mercurial/context.py", line 792, in cmp
    if (fctx._filerev is None
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/mercurial/util.py", line 723, in __get__
    result = self.func(obj)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/mercurial/context.py", line 688, in _filerev
    return self._filelog.rev(self._filenode)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/mercurial/util.py", line 723, in __get__
    result = self.func(obj)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/mercurial/context.py", line 663, in _filelog
    return self._repo.file(self._path)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/mercurial/unionrepo.py", line 221, in file
    self._clrev, self)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/mercurial/unionrepo.py", line 173, in __init__
    linkmapper)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/mercurial/unionrepo.py", line 60, in __init__
    link = linkmapper(linkrev)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/mercurial/unionrepo.py", line 209, in _clrev
    return self.changelog.rev(node)
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/mercurial/changelog.py", line 212, in rev
    _('filtered node'))
mercurial.error.FilteredLookupError: 00changelog.i@edcc273ded511a1e48b49133b020eaf7a625cf2a: filtered node
Pierre-Yves David - Feb. 22, 2016, 10:22 p.m.
On 02/22/2016 11:19 PM, Sean Farley wrote:
>
> Pierre-Yves David <pierre-yves.david@ens-lyon.org> writes:
>
>> On 02/22/2016 10:52 PM, Sean Farley wrote:
>>>
>>> Pierre-Yves David <pierre-yves.david@ens-lyon.org> writes:
>>>
>>>> # HG changeset patch
>>>> # User Pierre-Yves David <pierre-yves.david@fb.com>
>>>> # Date 1456162540 -3600
>>>> #      Mon Feb 22 18:35:40 2016 +0100
>>>> # Node ID c3f0732d8bfcda5c430b5bf0fc21e22580fa8bbc
>>>> # Parent  28e1694ca60056d609ae2c8e0ad5cb2891416ea3
>>>> # Available At http://hg.netv6.net/marmoute-wip/mercurial/
>>>> #              hg pull http://hg.netv6.net/marmoute-wip/mercurial/ -r c3f0732d8bfc
>>>> bundlerepo: properly hidden revision in bundle (issue4945)
>>>>
>>>> The bundlerepository have to do some special magic to handle linkrev of the
>>>> bundled filerev. That logic was done from a repoview and obsolescence marker
>>>> affecting bundled changeset could lead to a crash. We now ensure we operate on
>>>> unfiltered repository.
>>>>
>>>> diff --git a/mercurial/bundlerepo.py b/mercurial/bundlerepo.py
>>>> --- a/mercurial/bundlerepo.py
>>>> +++ b/mercurial/bundlerepo.py
>>>> @@ -360,11 +360,12 @@ class bundlerepository(localrepo.localre
>>>>                        if not c:
>>>>                            break
>>>>
>>>>            if f in self.bundlefilespos:
>>>>                self.bundle.seek(self.bundlefilespos[f])
>>>> -            return bundlefilelog(self.svfs, f, self.bundle, self.changelog.rev)
>>>> +            linkmapper = self.unfiltered().changelog.rev
>>>> +            return bundlefilelog(self.svfs, f, self.bundle, linkmapper)
>>>
>>> Would this logic also be the same to fix issue5070?
>>> http://bz.mercurial-scm.org/show_bug.cgi?id=5070
>>
>> Probably. do you have a traceback handy?
>
>  From the script on the issue (I'll update the report with this output):
>
> ./script.py
> P1 hidden: False
> P2 hidden: False
> CMP:
> Traceback (most recent call last):
>    File "./script.py", line 20, in <module>
>      print "CMP:", fctx.cmp(p2.filectx(f))
>    File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/mercurial/context.py", line 792, in cmp
>      if (fctx._filerev is None
>    File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/mercurial/util.py", line 723, in __get__
>      result = self.func(obj)
>    File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/mercurial/context.py", line 688, in _filerev
>      return self._filelog.rev(self._filenode)
>    File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/mercurial/util.py", line 723, in __get__
>      result = self.func(obj)
>    File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/mercurial/context.py", line 663, in _filelog
>      return self._repo.file(self._path)
>    File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/mercurial/unionrepo.py", line 221, in file
>      self._clrev, self)
>    File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/mercurial/unionrepo.py", line 173, in __init__
>      linkmapper)
>    File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/mercurial/unionrepo.py", line 60, in __init__
>      link = linkmapper(linkrev)
>    File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/mercurial/unionrepo.py", line 209, in _clrev
>      return self.changelog.rev(node)
>    File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/mercurial/changelog.py", line 212, in rev
>      _('filtered node'))
> mercurial.error.FilteredLookupError: 00changelog.i@edcc273ded511a1e48b49133b020eaf7a625cf2a: filtered node

Yes, this look like exactly the same issue.
Augie Fackler - Feb. 22, 2016, 11:08 p.m.
On Mon, Feb 22, 2016 at 06:45:02PM +0100, Pierre-Yves David wrote:
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david@fb.com>
> # Date 1456162540 -3600
> #      Mon Feb 22 18:35:40 2016 +0100
> # Node ID c3f0732d8bfcda5c430b5bf0fc21e22580fa8bbc
> # Parent  28e1694ca60056d609ae2c8e0ad5cb2891416ea3
> # Available At http://hg.netv6.net/marmoute-wip/mercurial/
> #              hg pull http://hg.netv6.net/marmoute-wip/mercurial/ -r c3f0732d8bfc
> bundlerepo: properly hidden revision in bundle (issue4945)

Sometimes filtering is a lovecraftian horror. I think this is one of
those times.

Queued.

> The bundlerepository have to do some special magic to handle linkrev of the
> bundled filerev. That logic was done from a repoview and obsolescence marker
> affecting bundled changeset could lead to a crash. We now ensure we operate on
> unfiltered repository.
>
> diff --git a/mercurial/bundlerepo.py b/mercurial/bundlerepo.py
> --- a/mercurial/bundlerepo.py
> +++ b/mercurial/bundlerepo.py
> @@ -360,11 +360,12 @@ class bundlerepository(localrepo.localre
>                      if not c:
>                          break
>
>          if f in self.bundlefilespos:
>              self.bundle.seek(self.bundlefilespos[f])
> -            return bundlefilelog(self.svfs, f, self.bundle, self.changelog.rev)
> +            linkmapper = self.unfiltered().changelog.rev
> +            return bundlefilelog(self.svfs, f, self.bundle, linkmapper)
>          else:
>              return filelog.filelog(self.svfs, f)
>
>      def close(self):
>          """Close assigned bundle file immediately."""
> diff --git a/tests/test-obsolete.t b/tests/test-obsolete.t
> --- a/tests/test-obsolete.t
> +++ b/tests/test-obsolete.t
> @@ -1004,7 +1004,76 @@ bookmarks change
>    $ hg log -r 13bedc178fce
>    abort: hidden revision '13bedc178fce'!
>    (use --hidden to access hidden revisions)
>    [255]
>
> +Test ability to pull changeset with locally applying obsolescence markers
> +(issue4945)
>
> +  $ cd ..
> +  $ hg init issue4845
> +  $ cd issue4845
>
> +  $ echo foo > f0
> +  $ hg add f0
> +  $ hg ci -m '0'
> +  $ echo foo > f1
> +  $ hg add f1
> +  $ hg ci -m '1'
> +  $ echo foo > f2
> +  $ hg add f2
> +  $ hg ci -m '2'
> +
> +  $ echo bar > f2
> +  $ hg commit --amend --config experimetnal.evolution=createmarkers
> +  $ hg log -G
> +  @  4:b0551702f918 (draft) [tip ] 2
> +  |
> +  o  1:e016b03fd86f (draft) [ ] 1
> +  |
> +  o  0:a78f55e5508c (draft) [ ] 0
> +
> +  $ hg log -G --hidden
> +  @  4:b0551702f918 (draft) [tip ] 2
> +  |
> +  | x  3:f27abbcc1f77 (draft) [ ] temporary amend commit for e008cf283490
> +  | |
> +  | x  2:e008cf283490 (draft) [ ] 2
> +  |/
> +  o  1:e016b03fd86f (draft) [ ] 1
> +  |
> +  o  0:a78f55e5508c (draft) [ ] 0
> +
> +
> +  $ hg strip -r 1 --config extensions.strip=
> +  0 files updated, 0 files merged, 2 files removed, 0 files unresolved
> +  saved backup bundle to $TESTTMP/tmpe/issue4845/.hg/strip-backup/e016b03fd86f-c41c6bcc-backup.hg (glob)
> +  $ hg log -G
> +  @  0:a78f55e5508c (draft) [tip ] 0
> +
> +  $ hg log -G --hidden
> +  @  0:a78f55e5508c (draft) [tip ] 0
> +
> +
> +  $ hg pull .hg/strip-backup/*
> +  pulling from .hg/strip-backup/e016b03fd86f-c41c6bcc-backup.hg
> +  searching for changes
> +  adding changesets
> +  adding manifests
> +  adding file changes
> +  added 2 changesets with 2 changes to 2 files
> +  (run 'hg update' to get a working copy)
> +  $ hg log -G
> +  o  2:b0551702f918 (draft) [tip ] 2
> +  |
> +  o  1:e016b03fd86f (draft) [ ] 1
> +  |
> +  @  0:a78f55e5508c (draft) [ ] 0
> +
> +  $ hg log -G --hidden
> +  o  2:b0551702f918 (draft) [tip ] 2
> +  |
> +  o  1:e016b03fd86f (draft) [ ] 1
> +  |
> +  @  0:a78f55e5508c (draft) [ ] 0
> +
> +
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Patch

diff --git a/mercurial/bundlerepo.py b/mercurial/bundlerepo.py
--- a/mercurial/bundlerepo.py
+++ b/mercurial/bundlerepo.py
@@ -360,11 +360,12 @@  class bundlerepository(localrepo.localre
                     if not c:
                         break
 
         if f in self.bundlefilespos:
             self.bundle.seek(self.bundlefilespos[f])
-            return bundlefilelog(self.svfs, f, self.bundle, self.changelog.rev)
+            linkmapper = self.unfiltered().changelog.rev
+            return bundlefilelog(self.svfs, f, self.bundle, linkmapper)
         else:
             return filelog.filelog(self.svfs, f)
 
     def close(self):
         """Close assigned bundle file immediately."""
diff --git a/tests/test-obsolete.t b/tests/test-obsolete.t
--- a/tests/test-obsolete.t
+++ b/tests/test-obsolete.t
@@ -1004,7 +1004,76 @@  bookmarks change
   $ hg log -r 13bedc178fce
   abort: hidden revision '13bedc178fce'!
   (use --hidden to access hidden revisions)
   [255]
 
+Test ability to pull changeset with locally applying obsolescence markers
+(issue4945)
 
+  $ cd ..
+  $ hg init issue4845
+  $ cd issue4845
 
+  $ echo foo > f0
+  $ hg add f0
+  $ hg ci -m '0'
+  $ echo foo > f1
+  $ hg add f1
+  $ hg ci -m '1'
+  $ echo foo > f2
+  $ hg add f2
+  $ hg ci -m '2'
+
+  $ echo bar > f2
+  $ hg commit --amend --config experimetnal.evolution=createmarkers
+  $ hg log -G
+  @  4:b0551702f918 (draft) [tip ] 2
+  |
+  o  1:e016b03fd86f (draft) [ ] 1
+  |
+  o  0:a78f55e5508c (draft) [ ] 0
+  
+  $ hg log -G --hidden
+  @  4:b0551702f918 (draft) [tip ] 2
+  |
+  | x  3:f27abbcc1f77 (draft) [ ] temporary amend commit for e008cf283490
+  | |
+  | x  2:e008cf283490 (draft) [ ] 2
+  |/
+  o  1:e016b03fd86f (draft) [ ] 1
+  |
+  o  0:a78f55e5508c (draft) [ ] 0
+  
+
+  $ hg strip -r 1 --config extensions.strip=
+  0 files updated, 0 files merged, 2 files removed, 0 files unresolved
+  saved backup bundle to $TESTTMP/tmpe/issue4845/.hg/strip-backup/e016b03fd86f-c41c6bcc-backup.hg (glob)
+  $ hg log -G
+  @  0:a78f55e5508c (draft) [tip ] 0
+  
+  $ hg log -G --hidden
+  @  0:a78f55e5508c (draft) [tip ] 0
+  
+
+  $ hg pull .hg/strip-backup/*
+  pulling from .hg/strip-backup/e016b03fd86f-c41c6bcc-backup.hg
+  searching for changes
+  adding changesets
+  adding manifests
+  adding file changes
+  added 2 changesets with 2 changes to 2 files
+  (run 'hg update' to get a working copy)
+  $ hg log -G
+  o  2:b0551702f918 (draft) [tip ] 2
+  |
+  o  1:e016b03fd86f (draft) [ ] 1
+  |
+  @  0:a78f55e5508c (draft) [ ] 0
+  
+  $ hg log -G --hidden
+  o  2:b0551702f918 (draft) [tip ] 2
+  |
+  o  1:e016b03fd86f (draft) [ ] 1
+  |
+  @  0:a78f55e5508c (draft) [ ] 0
+  
+