# HG changeset patch # User Martin von Zweigbergk # Date 1523044532 25200 # Node ID 9231148ea5999ecd08eecbe6ab7f5191e727937c # Parent bb8e93b332a7a944ba9a35a07903167af1bf34de context: convert to hex for error message only for 20-byte changeid Now that 20-byte strings unambiguously mean binary (or a bug), we can specialize the conversion to hex for that case. Differential Revision: https://phab.mercurial-scm.org/D3452 diff -r bb8e93b332a7 -r 9231148ea599 mercurial/context.py --- a/mercurial/context.py Fri Apr 06 12:59:17 2018 -0700 +++ b/mercurial/context.py Fri Apr 06 12:55:32 2018 -0700 @@ -10,7 +10,6 @@ import errno import filecmp import os -import re import stat from .i18n import _ @@ -51,8 +50,6 @@ propertycache = util.propertycache -nonascii = re.compile(br'[^\x21-\x7f]').search - class basectx(object): """A basectx object represents the common logic for its children: changectx: read-only context that is already present in the repo, @@ -420,6 +417,7 @@ and changeid in repo.unfiltered().dirstate.parents()): msg = _("working directory has unknown parent '%s'!") raise error.Abort(msg % short(changeid)) + changeid = hex(changeid) # for the error message elif len(changeid) == 40: try: @@ -432,11 +430,6 @@ pass # lookup failed - try: - if len(changeid) == 20 and nonascii(changeid): - changeid = hex(changeid) - except TypeError: - pass except (error.FilteredIndexError, error.FilteredLookupError): raise error.FilteredRepoLookupError(_("filtered revision '%s'") % changeid)