Patchwork [stable] graphmod: don't try to visit nullrev (issue3772)

login
register
mail settings
Submitter Bryan O'Sullivan
Date Jan. 22, 2013, 6:15 p.m.
Message ID <7ea2e6d23afc8a22d7f7.1358878532@australite.local>
Download mbox | patch
Permalink /patch/712/
State Superseded
Headers show

Comments

Bryan O'Sullivan - Jan. 22, 2013, 6:15 p.m.
# HG changeset patch
# User Bryan O'Sullivan <bryano@fb.com>
# Date 1358878516 28800
# Node ID 7ea2e6d23afc8a22d7f71822ea9efed94d18b2d4
# Parent  8c019d2fd7c03f073f7b879ccb87f3e2891bce8a
graphmod: don't try to visit nullrev (issue3772)
Augie Fackler - Jan. 22, 2013, 6:26 p.m.
LGTM, ship it.

On Tue, Jan 22, 2013 at 1:15 PM, Bryan O'Sullivan <bos@serpentine.com> wrote:
> # HG changeset patch
> # User Bryan O'Sullivan <bryano@fb.com>
> # Date 1358878516 28800
> # Node ID 7ea2e6d23afc8a22d7f71822ea9efed94d18b2d4
> # Parent  8c019d2fd7c03f073f7b879ccb87f3e2891bce8a
> graphmod: don't try to visit nullrev (issue3772)
>
> diff --git a/mercurial/graphmod.py b/mercurial/graphmod.py
> --- a/mercurial/graphmod.py
> +++ b/mercurial/graphmod.py
> @@ -181,7 +181,7 @@ def asciiedges(type, char, lines, seen,
>      ncols = len(seen)
>      nextseen = seen[:]
>      nextseen[nodeidx:nodeidx + 1] = newparents
> -    edges = [(nodeidx, nextseen.index(p)) for p in knownparents]
> +    edges = [(nodeidx, nextseen.index(p)) for p in knownparents if p != nullrev]
>
>      while len(newparents) > 2:
>          # ascii() only knows how to add or remove a single column between two
> diff --git a/tests/test-glog.t b/tests/test-glog.t
> --- a/tests/test-glog.t
> +++ b/tests/test-glog.t
> @@ -2109,4 +2109,17 @@ The almost-empty template should do some
>    o
>
>
> +issue3772
> +
> +  $ hg glog -r :null
> +  o  changeset:   0:f8035bb17114
> +  |  user:        test
> +  |  date:        Thu Jan 01 00:00:00 1970 +0000
> +  |  summary:     add a
> +  |
> +  o  changeset:   -1:000000000000
> +     user:
> +     date:        Thu Jan 01 00:00:00 1970 +0000
> +
> +
>    $ cd ..
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel
Sean Farley - Jan. 22, 2013, 6:45 p.m.
On Tue, Jan 22, 2013 at 12:26 PM, Augie Fackler <lists@durin42.com> wrote:
> LGTM, ship it.
>
> On Tue, Jan 22, 2013 at 1:15 PM, Bryan O'Sullivan <bos@serpentine.com> wrote:
>> # HG changeset patch
>> # User Bryan O'Sullivan <bryano@fb.com>
>> # Date 1358878516 28800
>> # Node ID 7ea2e6d23afc8a22d7f71822ea9efed94d18b2d4
>> # Parent  8c019d2fd7c03f073f7b879ccb87f3e2891bce8a
>> graphmod: don't try to visit nullrev (issue3772)
>>
>> diff --git a/mercurial/graphmod.py b/mercurial/graphmod.py
>> --- a/mercurial/graphmod.py
>> +++ b/mercurial/graphmod.py
>> @@ -181,7 +181,7 @@ def asciiedges(type, char, lines, seen,
>>      ncols = len(seen)
>>      nextseen = seen[:]
>>      nextseen[nodeidx:nodeidx + 1] = newparents
>> -    edges = [(nodeidx, nextseen.index(p)) for p in knownparents]
>> +    edges = [(nodeidx, nextseen.index(p)) for p in knownparents if p != nullrev]

On IRC, Kevin and Pierre-Yves were thinking that this is a bug in
'revrange' and that ":null" should return [-1] instead of [0,-1].
Thoughts?
Augie Fackler - Jan. 22, 2013, 6:47 p.m.
On Tue, Jan 22, 2013 at 1:45 PM, Sean Farley
<sean.michael.farley@gmail.com> wrote:
> On IRC, Kevin and Pierre-Yves were thinking that this is a bug in
> 'revrange' and that ":null" should return [-1] instead of [0,-1].
> Thoughts?


Interesting. I'm somewhat inclined to agree, as nothing is an ancestor of null.
Matt Mackall - Jan. 22, 2013, 7:01 p.m.
On Tue, 2013-01-22 at 13:47 -0500, Augie Fackler wrote:
> On Tue, Jan 22, 2013 at 1:45 PM, Sean Farley
> <sean.michael.farley@gmail.com> wrote:
> > On IRC, Kevin and Pierre-Yves were thinking that this is a bug in
> > 'revrange' and that ":null" should return [-1] instead of [0,-1].
> > Thoughts?
> 
> 
> Interesting. I'm somewhat inclined to agree, as nothing is an ancestor of null.

Agreed. This result is nonsense:

$ hg log -r :null
changeset:   0:9117c6561b0b
user:        mpm@selenic.com
date:        Tue May 03 13:16:10 2005 -0800
summary:     Add back links from file revisions to changeset revisions

changeset:   -1:000000000000
user:        
date:        Thu Jan 01 00:00:00 1970 +0000

As is this one, which is wrong in a different way:

$ hg log -r '(:null)'
changeset:   0:9117c6561b0b
user:        mpm@selenic.com
date:        Tue May 03 13:16:10 2005 -0800
summary:     Add back links from file revisions to changeset revisions
Matt Mackall - Jan. 22, 2013, 7:15 p.m.
On Tue, 2013-01-22 at 13:47 -0500, Augie Fackler wrote:
> On Tue, Jan 22, 2013 at 1:45 PM, Sean Farley
> <sean.michael.farley@gmail.com> wrote:
> > On IRC, Kevin and Pierre-Yves were thinking that this is a bug in
> > 'revrange' and that ":null" should return [-1] instead of [0,-1].
> > Thoughts?
> 
> 
> Interesting. I'm somewhat inclined to agree, as nothing is an ancestor of null.

Actually, this does the right thing:

hg log -r ::null

Note the double colon.

We've intrinsically defined :rev as 0:rev. And we also have a notion of
allowing x:y where x > y. Which means some of the results are 'correct'.
Perhaps we need to instead define it as '-1:rev and not -1'.

On the other hand, x:x should behave like x:

$ hg log -r 'null:null'
changeset:   -1:000000000000
user:        
date:        Thu Jan 01 00:00:00 1970 +0000

$ hg log -r '(null:null)'

Patch

diff --git a/mercurial/graphmod.py b/mercurial/graphmod.py
--- a/mercurial/graphmod.py
+++ b/mercurial/graphmod.py
@@ -181,7 +181,7 @@  def asciiedges(type, char, lines, seen, 
     ncols = len(seen)
     nextseen = seen[:]
     nextseen[nodeidx:nodeidx + 1] = newparents
-    edges = [(nodeidx, nextseen.index(p)) for p in knownparents]
+    edges = [(nodeidx, nextseen.index(p)) for p in knownparents if p != nullrev]
 
     while len(newparents) > 2:
         # ascii() only knows how to add or remove a single column between two
diff --git a/tests/test-glog.t b/tests/test-glog.t
--- a/tests/test-glog.t
+++ b/tests/test-glog.t
@@ -2109,4 +2109,17 @@  The almost-empty template should do some
   o
   
 
+issue3772
+
+  $ hg glog -r :null
+  o  changeset:   0:f8035bb17114
+  |  user:        test
+  |  date:        Thu Jan 01 00:00:00 1970 +0000
+  |  summary:     add a
+  |
+  o  changeset:   -1:000000000000
+     user:
+     date:        Thu Jan 01 00:00:00 1970 +0000
+  
+
   $ cd ..