context: clarify that only one attempt is made to interpret changeid
We can now tell what type of revision specifier we have just by
looking at it (we no longer attempt to interpret it in one way after
the other -- that's now in scmutil.revsymbol()). Let's clarify this in
the code by swithing to if/elif.
Differential Revision: https://phab.mercurial-scm.org/D3451
--- a/mercurial/context.py Fri Apr 06 12:45:08 2018 -0700
+++ b/mercurial/context.py Fri Apr 06 12:59:17 2018 -0700
@@ -389,22 +389,22 @@
self._node = repo.changelog.node(changeid)
self._rev = changeid
return
- if changeid == 'null':
+ elif changeid == 'null':
self._node = nullid
self._rev = nullrev
return
- if changeid == 'tip':
+ elif changeid == 'tip':
self._node = repo.changelog.tip()
self._rev = repo.changelog.rev(self._node)
return
- if (changeid == '.'
- or repo.local() and changeid == repo.dirstate.p1()):
+ elif (changeid == '.'
+ or repo.local() and changeid == repo.dirstate.p1()):
# this is a hack to delay/avoid loading obsmarkers
# when we know that '.' won't be hidden
self._node = repo.dirstate.p1()
self._rev = repo.unfiltered().changelog.rev(self._node)
return
- if len(changeid) == 20:
+ elif len(changeid) == 20:
try:
self._node = changeid
self._rev = repo.changelog.rev(changeid)
@@ -421,7 +421,7 @@
msg = _("working directory has unknown parent '%s'!")
raise error.Abort(msg % short(changeid))
- if len(changeid) == 40:
+ elif len(changeid) == 40:
try:
self._node = bin(changeid)
self._rev = repo.changelog.rev(self._node)