Patchwork [stable] unionrepo: fix wrong rev being checked in iscensored (issue5024)

login
register
mail settings
Submitter Sean Farley
Date Jan. 8, 2016, 6:10 p.m.
Message ID <258348d91ba9fd91adec.1452276628@laptop.office.atlassian.com>
Download mbox | patch
Permalink /patch/12604/
State Superseded
Commit bf86e3e87123a397f75733bc2a7f033d7a0b035a
Headers show

Comments

Sean Farley - Jan. 8, 2016, 6:10 p.m.
# HG changeset patch
# User Sean Farley <sean@farley.io>
# Date 1452106915 28800
#      Wed Jan 06 11:01:55 2016 -0800
# Branch stable
# Node ID 258348d91ba9fd91adecd9cb5c3333816dc2f76d
# Parent  7c598947fbbd78b26989326c61345c6e46855bdc
unionrepo: fix wrong rev being checked in iscensored (issue5024)
Yuya Nishihara - Jan. 9, 2016, 8:51 a.m.
On Fri, 08 Jan 2016 10:10:28 -0800, Sean Farley wrote:
> # HG changeset patch
> # User Sean Farley <sean@farley.io>
> # Date 1452106915 28800
> #      Wed Jan 06 11:01:55 2016 -0800
> # Branch stable
> # Node ID 258348d91ba9fd91adecd9cb5c3333816dc2f76d
> # Parent  7c598947fbbd78b26989326c61345c6e46855bdc
> unionrepo: fix wrong rev being checked in iscensored (issue5024)
> 
> diff --git a/mercurial/unionrepo.py b/mercurial/unionrepo.py
> --- a/mercurial/unionrepo.py
> +++ b/mercurial/unionrepo.py
> @@ -180,11 +180,12 @@ class unionfilelog(unionrevlog, filelog.
>  
>      def iscensored(self, rev):
>          """Check if a revision is censored."""
>          if rev <= self.repotiprev:
>              return filelog.filelog.iscensored(self, rev)
> -        return self.revlog2.iscensored(rev)
> +        node = self.node(rev)
> +        return self.revlog2.iscensored(self.revlog2.rev(node))

Looks good, but can you add a test? ™
Sean Farley - Jan. 10, 2016, 1:03 a.m.
Yuya Nishihara <yuya@tcha.org> writes:

> On Fri, 08 Jan 2016 10:10:28 -0800, Sean Farley wrote:
>> # HG changeset patch
>> # User Sean Farley <sean@farley.io>
>> # Date 1452106915 28800
>> #      Wed Jan 06 11:01:55 2016 -0800
>> # Branch stable
>> # Node ID 258348d91ba9fd91adecd9cb5c3333816dc2f76d
>> # Parent  7c598947fbbd78b26989326c61345c6e46855bdc
>> unionrepo: fix wrong rev being checked in iscensored (issue5024)
>> 
>> diff --git a/mercurial/unionrepo.py b/mercurial/unionrepo.py
>> --- a/mercurial/unionrepo.py
>> +++ b/mercurial/unionrepo.py
>> @@ -180,11 +180,12 @@ class unionfilelog(unionrevlog, filelog.
>>  
>>      def iscensored(self, rev):
>>          """Check if a revision is censored."""
>>          if rev <= self.repotiprev:
>>              return filelog.filelog.iscensored(self, rev)
>> -        return self.revlog2.iscensored(rev)
>> +        node = self.node(rev)
>> +        return self.revlog2.iscensored(self.revlog2.rev(node))
>
> Looks good, but can you add a test? ™

Sadly, I couldn't reproduce it simply. Could anyone help?
Yuya Nishihara - Jan. 10, 2016, 7:18 a.m.
On Sat, 09 Jan 2016 17:03:58 -0800, Sean Farley wrote:
> Yuya Nishihara <yuya@tcha.org> writes:
> > On Fri, 08 Jan 2016 10:10:28 -0800, Sean Farley wrote:
> >> # HG changeset patch
> >> # User Sean Farley <sean@farley.io>
> >> # Date 1452106915 28800
> >> #      Wed Jan 06 11:01:55 2016 -0800
> >> # Branch stable
> >> # Node ID 258348d91ba9fd91adecd9cb5c3333816dc2f76d
> >> # Parent  7c598947fbbd78b26989326c61345c6e46855bdc
> >> unionrepo: fix wrong rev being checked in iscensored (issue5024)
> >> 
> >> diff --git a/mercurial/unionrepo.py b/mercurial/unionrepo.py
> >> --- a/mercurial/unionrepo.py
> >> +++ b/mercurial/unionrepo.py
> >> @@ -180,11 +180,12 @@ class unionfilelog(unionrevlog, filelog.
> >>  
> >>      def iscensored(self, rev):
> >>          """Check if a revision is censored."""
> >>          if rev <= self.repotiprev:
> >>              return filelog.filelog.iscensored(self, rev)
> >> -        return self.revlog2.iscensored(rev)
> >> +        node = self.node(rev)
> >> +        return self.revlog2.iscensored(self.revlog2.rev(node))
> >
> > Looks good, but can you add a test? ™
> 
> Sadly, I couldn't reproduce it simply. Could anyone help?

Got it.

hg init a
cd a
echo a0 >> f
hg ci -Am a0
cd ..

# +2 revisions to exceed index boundary
hg init b
cd b
echo b0 >> f
hg ci -Am b0
echo b1 >> f
hg ci -m b1

# "hg files -v" to call fctx.size() -> fctx.iscensored()
hg files -R union:../a -r2 -v
Sean Farley - Jan. 10, 2016, 10:25 p.m.
Yuya Nishihara <yuya@tcha.org> writes:

> On Sat, 09 Jan 2016 17:03:58 -0800, Sean Farley wrote:
>> Yuya Nishihara <yuya@tcha.org> writes:
>> > On Fri, 08 Jan 2016 10:10:28 -0800, Sean Farley wrote:
>> >> # HG changeset patch
>> >> # User Sean Farley <sean@farley.io>
>> >> # Date 1452106915 28800
>> >> #      Wed Jan 06 11:01:55 2016 -0800
>> >> # Branch stable
>> >> # Node ID 258348d91ba9fd91adecd9cb5c3333816dc2f76d
>> >> # Parent  7c598947fbbd78b26989326c61345c6e46855bdc
>> >> unionrepo: fix wrong rev being checked in iscensored (issue5024)
>> >> 
>> >> diff --git a/mercurial/unionrepo.py b/mercurial/unionrepo.py
>> >> --- a/mercurial/unionrepo.py
>> >> +++ b/mercurial/unionrepo.py
>> >> @@ -180,11 +180,12 @@ class unionfilelog(unionrevlog, filelog.
>> >>  
>> >>      def iscensored(self, rev):
>> >>          """Check if a revision is censored."""
>> >>          if rev <= self.repotiprev:
>> >>              return filelog.filelog.iscensored(self, rev)
>> >> -        return self.revlog2.iscensored(rev)
>> >> +        node = self.node(rev)
>> >> +        return self.revlog2.iscensored(self.revlog2.rev(node))
>> >
>> > Looks good, but can you add a test? ™
>> 
>> Sadly, I couldn't reproduce it simply. Could anyone help?
>
> Got it.
>
> hg init a
> cd a
> echo a0 >> f
> hg ci -Am a0
> cd ..
>
> # +2 revisions to exceed index boundary
> hg init b
> cd b
> echo b0 >> f
> hg ci -Am b0
> echo b1 >> f
> hg ci -m b1
>
> # "hg files -v" to call fctx.size() -> fctx.iscensored()
> hg files -R union:../a -r2 -v

Awesome! Many thanks :-)

Patch

diff --git a/mercurial/unionrepo.py b/mercurial/unionrepo.py
--- a/mercurial/unionrepo.py
+++ b/mercurial/unionrepo.py
@@ -180,11 +180,12 @@  class unionfilelog(unionrevlog, filelog.
 
     def iscensored(self, rev):
         """Check if a revision is censored."""
         if rev <= self.repotiprev:
             return filelog.filelog.iscensored(self, rev)
-        return self.revlog2.iscensored(rev)
+        node = self.node(rev)
+        return self.revlog2.iscensored(self.revlog2.rev(node))
 
 class unionpeer(localrepo.localpeer):
     def canpush(self):
         return False