Patchwork [09,of,41] basefilectx: move __repr__ from filectx

mail settings
Submitter Sean Farley
Date Aug. 12, 2013, 4:27 p.m.
Message ID <df530f9dbdc05968658a.1376324825@laptop.local>
Download mbox | patch
Permalink /patch/2135/
State Accepted
Commit e86a594ab11f82bcca8e987c7dc6fd2653379d7b
Headers show


Sean Farley - Aug. 12, 2013, 4:27 p.m.
# HG changeset patch
# User Sean Farley <>
# Date 1376279214 18000
#      Sun Aug 11 22:46:54 2013 -0500
# Node ID df530f9dbdc05968658a2ec706ecfc24ca79612e
# Parent  964844d64ef8fdb02cc5330f70a1acab158fdfb7
basefilectx: move __repr__ from filectx

We change the hardcoded 'filectx' to instead use type(self).__name__ so that objects that
inherit from basefilectx in the future will be able to use the same representation.


diff --git a/mercurial/ b/mercurial/
--- a/mercurial/
+++ b/mercurial/
@@ -456,10 +456,13 @@ 
             return False
     def __str__(self):
         return "%s@%s" % (self.path(), short(self.node()))
+    def __repr__(self):
+        return "<%s %s>" % (type(self).__name__, str(self))
 class filectx(basefilectx):
     """A filecontext object makes access to data related to a particular
        filerevision convenient."""
     def __init__(self, repo, path, changeid=None, fileid=None,
                  filelog=None, changectx=None):
@@ -505,13 +508,10 @@ 
             # Linkrevs have several serious troubles with filtering that are
             # complicated to solve. Proper handling of the issue here should be
             # considered when solving linkrev issue are on the table.
             return changectx(self._repo.unfiltered(), self._changeid)
-    def __repr__(self):
-        return "<filectx %s>" % str(self)
     def __hash__(self):
             return hash((self._path, self._filenode))
         except AttributeError:
             return id(self)