Bug 5609 - revsingle behavior changed
Summary: revsingle behavior changed
Status: RESOLVED FIXED
Alias: None
Product: Mercurial
Classification: Unclassified
Component: revset (show other bugs)
Version: default branch
Hardware: PC Linux
: wish bug
Assignee: Bugzilla
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-06-27 09:54 UTC by Boris Feld
Modified: 2017-10-16 04:50 UTC (History)
3 users (show)

See Also:
Python Version: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Boris Feld 2017-06-27 09:54 UTC
The behavior of scmutil.revsingle seems to have changed in default branch.

Here is a reproduction scenario using annotate:

Setup:
    hg init test
    cd test
    touch ROOT
    hg commit -A -m ROOT
    echo "A" > A
    hg commit -A -m "A"

Repro:
    hg annotate -r "0::" A

The expected output is:
    1: A

The current output is:
    abort: A: no such file in rev c19fb0feaa37

Not all commands using revsingle seems affected.

I've bisected the problem to d83b189aef83 ( dagop: change revdescendants() to include all root revisions).

I tried debugging the issue by printing "l.last()" value in revsingle:

    diff -r d83b189aef83 mercurial/scmutil.py
    --- a/mercurial/scmutil.py      Tue Jun 20 22:26:52 2017 +0900
    +++ b/mercurial/scmutil.py      Tue Jun 27 15:43:25 2017 +0200
    @@ -404,6 +404,7 @@
         l = revrange(repo, [revspec])
         if not l:
             raise error.Abort(_('empty revision set'))
    +    print("Last", l.last())
         return repo[l.last()]
     
     def _pairspec(revspec):

But after adding the print, the reproduction script stops failing. Even stranger, printing "l.last()" value several times shows that the incorrect value is only here the first time:

    diff -r d83b189aef83 mercurial/scmutil.py
    --- a/mercurial/scmutil.py      Tue Jun 20 22:26:52 2017 +0900
    +++ b/mercurial/scmutil.py      Tue Jun 27 15:45:22 2017 +0200
    @@ -404,6 +404,9 @@
         l = revrange(repo, [revspec])
         if not l:
             raise error.Abort(_('empty revision set'))
    +    print("Last", l.last())
    +    print("Last", l.last())
    +    print("Last", l.last())
         return repo[l.last()]
     
     def _pairspec(revspec):

And here is the annotate call:

    ('Last', 0)
    ('Last', 1)
    ('Last', 1)
    1: A

Here is the reproduction script as a .t file:

  $ hg init test
  $ cd test
  $ touch ROOT
  $ hg commit -A -m ROOT
  adding ROOT
  $ echo "A" > A
  $ hg commit -A -m "A"
  adding A
  $ hg annotate -r "0::" A
  1: A

(fails with the example at the top)
Comment 1 Yuya Nishihara 2017-06-27 10:37 UTC
I found a typo in smartset.py.
Comment 2 HG Bot 2017-10-04 17:51 UTC
Fixed by https://mercurial-scm.org/repo/hg/rev/247bae545061
Yuya Nishihara <yuya@tcha.org>
smartset: fix generatorset.last() to not return the first element (issue5609)

(please test the fix)
Comment 3 Bugzilla 2017-10-15 00:00 UTC
Bug was set to TESTING for 10 days, resolving
Comment 4 Boris Feld 2017-10-16 04:50 UTC
It's working, thank you