From patchwork Sun Mar 12 17:59:12 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [4, of, 9, py3, v3] context: implement both __bytes__ and __str__ for Python 3 From: Augie Fackler X-Patchwork-Id: 19193 Message-Id: To: mercurial-devel@mercurial-scm.org Date: Sun, 12 Mar 2017 13:59:12 -0400 # HG changeset patch # User Augie Fackler # Date 1489283860 18000 # Sat Mar 11 20:57:40 2017 -0500 # Node ID beead9d5be6f5fe44de55d277462e52284584819 # Parent c4a50c84504fe6eaae95915f401e9d6826e4d19f context: implement both __bytes__ and __str__ for Python 3 They're very similar, for obvious reasons. diff --git a/mercurial/context.py b/mercurial/context.py --- a/mercurial/context.py +++ b/mercurial/context.py @@ -65,6 +65,12 @@ class basectx(object): return o def __str__(self): + r = short(self.node()) + if pycompat.ispy3: + return r.decode('ascii') + return r + + def __bytes__(self): return short(self.node()) def __int__(self):