Patchwork D1901: mq: fix up statusentry to be both repr()-able and bytes()-able

login
register
mail settings
Submitter phabricator
Date Jan. 18, 2018, 1:39 p.m.
Message ID <differential-rev-PHID-DREV-6ra4qik5r2omxx65ua6e-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/26889/
State Superseded
Headers show

Comments

phabricator - Jan. 18, 2018, 1:39 p.m.
durin42 created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D1901

AFFECTED FILES
  hgext/mq.py

CHANGE DETAILS




To: durin42, #hg-reviewers
Cc: mercurial-devel
phabricator - Jan. 18, 2018, 2:03 p.m.
yuja added a comment.


  If we make `statusentry` stringifiable, we can do
  
    __str__ = encoding.strmethod(__bytes__)

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D1901

To: durin42, #hg-reviewers
Cc: yuja, mercurial-devel

Patch

diff --git a/hgext/mq.py b/hgext/mq.py
--- a/hgext/mq.py
+++ b/hgext/mq.py
@@ -148,7 +148,11 @@ 
 class statusentry(object):
     def __init__(self, node, name):
         self.node, self.name = node, name
+
     def __repr__(self):
+        return pycompat.sysstr('%s:%s' % (hex(self.node), self.name))
+
+    def __bytes__(self):
         return hex(self.node) + ':' + self.name
 
 # The order of the headers in 'hg export' HG patches: