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

login
register
mail settings
Submitter Sean Farley
Date Jan. 10, 2016, 10:25 p.m.
Message ID <380e64166d5ce201d6c6.1452464719@laptop.local>
Download mbox | patch
Permalink /patch/12648/
State Accepted
Delegated to: Yuya Nishihara
Headers show

Comments

Sean Farley - Jan. 10, 2016, 10:25 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 380e64166d5ce201d6c6215aeeeb8743f9faaa6f
# Parent  7c598947fbbd78b26989326c61345c6e46855bdc
unionrepo: fix wrong rev being checked in iscensored (issue5024)
Yuya Nishihara - Jan. 12, 2016, 2:18 p.m.
On Sun, 10 Jan 2016 14:25:19 -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 380e64166d5ce201d6c6215aeeeb8743f9faaa6f
> # Parent  7c598947fbbd78b26989326c61345c6e46855bdc
> unionrepo: fix wrong rev being checked in iscensored (issue5024)

Pushed to the clowncopter, thanks.

> +union repos should use the correct rev number (issue5024)
> +
> +  $ hg init a
> +  $ cd a
> +  $ echo a0 >> f
> +  $ hg ci -Aqm a0
> +  $ cd ..
> +  $ hg init b
> +  $ cd b
> +  $ echo b0 >> f
> +  $ hg ci -Aqm b0
> +  $ echo b1 >> f
> +  $ hg ci -qm b1
> +
> +"hg files -v" to call fctx.size() -> fctx.iscensored()
> +  $ hg files -R union:../a -r2 -v
> +           3   f

Changed it to union:b+a to work around msys issue.

Beyond the scope of this patch, it would be nice if this test actually checks
if iscensored() is working.

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
 
diff --git a/tests/test-unionrepo.t b/tests/test-unionrepo.t
--- a/tests/test-unionrepo.t
+++ b/tests/test-unionrepo.t
@@ -146,5 +146,23 @@  union repos can be cloned ... and clones
   4:9e6fb3e0b9da  repo2-2-merge
   3:c337dba826e7  repo2-1
   2:68c0685446a3  repo1-2
   1:8a58db72e69d  repo1-1
   0:f093fec0529b  repo1-0
+
+union repos should use the correct rev number (issue5024)
+
+  $ hg init a
+  $ cd a
+  $ echo a0 >> f
+  $ hg ci -Aqm a0
+  $ cd ..
+  $ hg init b
+  $ cd b
+  $ echo b0 >> f
+  $ hg ci -Aqm b0
+  $ echo b1 >> f
+  $ hg ci -qm b1
+
+"hg files -v" to call fctx.size() -> fctx.iscensored()
+  $ hg files -R union:../a -r2 -v
+           3   f