Details
Details
- Reviewers
- None
- Group Reviewers
hg-reviewers - Commits
- rHGe9ee540af434: scmutil: make revpair() return context objects (API)
Diff Detail
Diff Detail
- Repository
- rHG Mercurial
- Lint
Lint Skipped - Unit
Unit Tests Skipped
hg-reviewers |
Lint Skipped |
Unit Tests Skipped |
Path | Packages | |||
---|---|---|---|---|
M | mercurial/scmutil.py (9 lines) |
Status | Author | Revision | |
---|---|---|---|
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz |
raise error.Abort(_('empty revision set')) | raise error.Abort(_('empty revision set')) | ||||
return repo[l.last()] | return repo[l.last()] | ||||
def _pairspec(revspec): | def _pairspec(revspec): | ||||
tree = revsetlang.parse(revspec) | tree = revsetlang.parse(revspec) | ||||
return tree and tree[0] in ('range', 'rangepre', 'rangepost', 'rangeall') | return tree and tree[0] in ('range', 'rangepre', 'rangepost', 'rangeall') | ||||
def revpairnodes(repo, revs): | def revpairnodes(repo, revs): | ||||
return revpair(repo, revs) | ctx1, ctx2 = revpair(repo, revs) | ||||
return ctx1.node(), ctx2.node() | |||||
def revpair(repo, revs): | def revpair(repo, revs): | ||||
if not revs: | if not revs: | ||||
return repo.dirstate.p1(), None | return repo['.'], repo[None] | ||||
l = revrange(repo, revs) | l = revrange(repo, revs) | ||||
if not l: | if not l: | ||||
first = second = None | first = second = None | ||||
elif l.isascending(): | elif l.isascending(): | ||||
first = l.min() | first = l.min() | ||||
second = l.max() | second = l.max() | ||||
elif l.isdescending(): | elif l.isdescending(): | ||||
first = l.max() | first = l.max() | ||||
second = l.min() | second = l.min() | ||||
else: | else: | ||||
first = l.first() | first = l.first() | ||||
second = l.last() | second = l.last() | ||||
if first is None: | if first is None: | ||||
raise error.Abort(_('empty revision range')) | raise error.Abort(_('empty revision range')) | ||||
if (first == second and len(revs) >= 2 | if (first == second and len(revs) >= 2 | ||||
and not all(revrange(repo, [r]) for r in revs)): | and not all(revrange(repo, [r]) for r in revs)): | ||||
raise error.Abort(_('empty revision on one side of range')) | raise error.Abort(_('empty revision on one side of range')) | ||||
# if top-level is range expression, the result must always be a pair | # if top-level is range expression, the result must always be a pair | ||||
if first == second and len(revs) == 1 and not _pairspec(revs[0]): | if first == second and len(revs) == 1 and not _pairspec(revs[0]): | ||||
return repo.lookup(first), None | return repo[first], repo[None] | ||||
return repo.lookup(first), repo.lookup(second) | return repo[first], repo[second] | ||||
def revrange(repo, specs, localalias=None): | def revrange(repo, specs, localalias=None): | ||||
"""Execute 1 to many revsets and return the union. | """Execute 1 to many revsets and return the union. | ||||
This is the preferred mechanism for executing revsets using user-specified | This is the preferred mechanism for executing revsets using user-specified | ||||
config options, such as revset aliases. | config options, such as revset aliases. | ||||
The revsets specified by ``specs`` will be executed via a chained ``OR`` | The revsets specified by ``specs`` will be executed via a chained ``OR`` |