Patchwork [5,of,5] bundle2: implement a basic __repr__ for bundle2 part

login
register
mail settings
Submitter Pierre-Yves David
Date Feb. 2, 2017, 4:21 p.m.
Message ID <c370b3f11fc3fcba0351.1486052495@nodosa.octopoid.net>
Download mbox | patch
Permalink /patch/18297/
State Accepted
Headers show

Comments

Pierre-Yves David - Feb. 2, 2017, 4:21 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@ens-lyon.org>
# Date 1486041588 -3600
#      Thu Feb 02 14:19:48 2017 +0100
# Node ID c370b3f11fc3fcba03516acbe46242cf672ccffd
# Parent  598c774d5b19faa5d924bfb73f997d02480b5e28
# EXP-Topic pushcleanup
bundle2: implement a basic __repr__ for bundle2 part

We display basic data as the part id and part type. This make debugging bundle2
related code friendlier.

Patch

diff -r 598c774d5b19 -r c370b3f11fc3 mercurial/bundle2.py
--- a/mercurial/bundle2.py	Thu Feb 02 11:03:41 2017 +0100
+++ b/mercurial/bundle2.py	Thu Feb 02 14:19:48 2017 +0100
@@ -862,6 +862,11 @@ 
         self._generated = None
         self.mandatory = mandatory
 
+    def __repr__(self):
+        cls = "%s.%s" % (self.__class__.__module__, self.__class__.__name__)
+        return ('<%s object at %x; id: %s; type: %s; mandatory: %s>'
+                % (cls, id(self), self.id, self.type, self.mandatory))
+
     def copy(self):
         """return a copy of the part