From patchwork Fri Jun 23 19:55:01 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [7,of,9] py3: define __bytes__ for basefilectx class From: Pulkit Goyal <7895pulkit@gmail.com> X-Patchwork-Id: 21650 Message-Id: <1f6a8f5e7fc775383302.1498247701@workspace> To: mercurial-devel@mercurial-scm.org Date: Sat, 24 Jun 2017 01:25:01 +0530 # HG changeset patch # User Pulkit Goyal <7895pulkit@gmail.com> # Date 1498081950 -19800 # Thu Jun 22 03:22:30 2017 +0530 # Node ID 1f6a8f5e7fc77538330217e1e0c361ef3d9014cb # Parent a1a4111876b69cb34fefcdf50c0ac70ea5ef704b py3: define __bytes__ for basefilectx class The implementation is shamely copied from the __str__ function diff --git a/mercurial/context.py b/mercurial/context.py --- a/mercurial/context.py +++ b/mercurial/context.py @@ -716,6 +716,12 @@ except error.LookupError: return "%s@???" % self.path() + def __bytes__(self): + try: + return "%s@%s" % (self.path(), self._changectx) + except error.LookupError: + return "%s@???" % self.path() + def __repr__(self): return "<%s %s>" % (type(self).__name__, str(self))