Mercurial > public > mercurial-scm > hg-stable
diff mercurial/scmutil.py @ 20862:97b2f26dfc43
revpair: smartset compatibility
Since recent revset changes, revrange now return a smartset. This smart set
probably does not support indexing (_addset does not). This led to crash.
Instead when the smartset is ordered we use the `min` and `max` method of
smart set. Otherwise we turn is into a list and use indexing on it.
The tests have been updated to catch such regression.
author | Pierre-Yves David <pierre-yves.david@fb.com> |
---|---|
date | Thu, 20 Mar 2014 18:44:25 -0700 |
parents | f8e531a3a77c |
children | 6fb4c94ae300 |
line wrap: on
line diff
--- a/mercurial/scmutil.py Fri Mar 28 16:12:05 2014 -0700 +++ b/mercurial/scmutil.py Thu Mar 20 18:44:25 2014 -0700 @@ -470,13 +470,26 @@ l = revrange(repo, revs) - if len(l) == 0: + if not l: + first = second = None + elif l.isascending(): + first = l.min() + second = l.max() + elif l.isdescending(): + first = l.max() + second = l.min() + else: + l = list(l) + first = l[0] + second = l[-1] + + if first is None: raise util.Abort(_('empty revision range')) - if len(l) == 1 and len(revs) == 1 and _revrangesep not in revs[0]: - return repo.lookup(l[0]), None + if first == second and len(revs) == 1 and _revrangesep not in revs[0]: + return repo.lookup(first), None - return repo.lookup(l[0]), repo.lookup(l[-1]) + return repo.lookup(first), repo.lookup(second) _revrangesep = ':'