Details
Details
- Reviewers
indygreg yuja - Group Reviewers
hg-reviewers - Commits
- rHG981f328d6d16: py3: use b"%d" instead of str() to convert integers to bytes
Diff Detail
Diff Detail
- Repository
- rHG Mercurial
- Lint
Lint Skipped - Unit
Unit Tests Skipped
( )
indygreg | |
yuja |
hg-reviewers |
Lint Skipped |
Unit Tests Skipped |
Path | Packages | |||
---|---|---|---|---|
M | mercurial/context.py (2 lines) | |||
M | mercurial/revlog.py (2 lines) |
self._repo = repo | self._repo = repo | ||||
try: | try: | ||||
if isinstance(changeid, int): | if isinstance(changeid, int): | ||||
self._node = repo.changelog.node(changeid) | self._node = repo.changelog.node(changeid) | ||||
self._rev = changeid | self._rev = changeid | ||||
return | return | ||||
if not pycompat.ispy3 and isinstance(changeid, long): | if not pycompat.ispy3 and isinstance(changeid, long): | ||||
changeid = str(changeid) | changeid = "%d" % changeid | ||||
if changeid == 'null': | if changeid == 'null': | ||||
self._node = nullid | self._node = nullid | ||||
self._rev = nullrev | self._rev = nullrev | ||||
return | return | ||||
if changeid == 'tip': | if changeid == 'tip': | ||||
self._node = repo.changelog.tip() | self._node = repo.changelog.tip() | ||||
self._rev = repo.changelog.rev(self._node) | self._rev = repo.changelog.rev(self._node) | ||||
return | return |
node = id | node = id | ||||
self.rev(node) # quick search the index | self.rev(node) # quick search the index | ||||
return node | return node | ||||
except LookupError: | except LookupError: | ||||
pass # may be partial hex id | pass # may be partial hex id | ||||
try: | try: | ||||
# str(rev) | # str(rev) | ||||
rev = int(id) | rev = int(id) | ||||
if str(rev) != id: | if "%d" % rev != id: | ||||
raise ValueError | raise ValueError | ||||
if rev < 0: | if rev < 0: | ||||
rev = len(self) + rev | rev = len(self) + rev | ||||
if rev < 0 or rev >= len(self): | if rev < 0 or rev >= len(self): | ||||
raise ValueError | raise ValueError | ||||
return self.node(rev) | return self.node(rev) | ||||
except (ValueError, OverflowError): | except (ValueError, OverflowError): | ||||
pass | pass |