Details
Details
- Reviewers
indygreg Alphare - Group Reviewers
hg-reviewers - Commits
- rHGc5e1cc0b4c77: core: don't hard-code node length
Diff Detail
Diff Detail
- Repository
- rHG Mercurial
- Branch
- default
- Lint
No Linters Available - Unit
No Unit Test Coverage
indygreg | |
Alphare |
hg-reviewers |
No Linters Available |
No Unit Test Coverage |
Path | Packages | |||
---|---|---|---|---|
M | mercurial/localrepo.py (2 lines) | |||
M | mercurial/revlog.py (2 lines) |
Commit | Parents | Author | Summary | Date |
---|---|---|---|---|
b6424f1c1123 | 2c2757376c6e | Joerg Sonnenberger | Apr 29 2021, 9:19 PM |
Status | Author | Revision | |
---|---|---|---|
Closed | joerg.sonnenberger | ||
Closed | joerg.sonnenberger |
if isinstance(changeid, int): | if isinstance(changeid, int): | ||||
node = self.changelog.node(changeid) | node = self.changelog.node(changeid) | ||||
rev = changeid | rev = changeid | ||||
elif changeid == b'.': | elif changeid == b'.': | ||||
# this is a hack to delay/avoid loading obsmarkers | # this is a hack to delay/avoid loading obsmarkers | ||||
# when we know that '.' won't be hidden | # when we know that '.' won't be hidden | ||||
node = self.dirstate.p1() | node = self.dirstate.p1() | ||||
rev = self.unfiltered().changelog.rev(node) | rev = self.unfiltered().changelog.rev(node) | ||||
elif len(changeid) == 20: | elif len(changeid) == self.nodeconstants.nodelen: | ||||
try: | try: | ||||
node = changeid | node = changeid | ||||
rev = self.changelog.rev(changeid) | rev = self.changelog.rev(changeid) | ||||
except error.FilteredLookupError: | except error.FilteredLookupError: | ||||
changeid = hex(changeid) # for the error message | changeid = hex(changeid) # for the error message | ||||
raise | raise | ||||
except LookupError: | except LookupError: | ||||
# check if it might have come from damaged dirstate | # check if it might have come from damaged dirstate |
# choose a consistent winner when there's a tie | # choose a consistent winner when there's a tie | ||||
return min(map(self.node, ancs)) | return min(map(self.node, ancs)) | ||||
return self.nullid | return self.nullid | ||||
def _match(self, id): | def _match(self, id): | ||||
if isinstance(id, int): | if isinstance(id, int): | ||||
# rev | # rev | ||||
return self.node(id) | return self.node(id) | ||||
if len(id) == 20: | if len(id) == self.nodeconstants.nodelen: | ||||
# possibly a binary node | # possibly a binary node | ||||
# odds of a binary node being all hex in ASCII are 1 in 10**25 | # odds of a binary node being all hex in ASCII are 1 in 10**25 | ||||
try: | try: | ||||
node = id | node = id | ||||
self.rev(node) # quick search the index | self.rev(node) # quick search the index | ||||
return node | return node | ||||
except error.LookupError: | except error.LookupError: | ||||
pass # may be partial hex id | pass # may be partial hex id |