obsolete: helper class to access obsolete marker data
authorPierre-Yves.David@ens-lyon.org
Thu, 07 Jun 2012 19:19:58 +0200
changeset 17072 517af63ba382
parent 17071 11f26e2669aa
child 17073 3a79a5682af1
obsolete: helper class to access obsolete marker data
mercurial/obsolete.py
--- a/mercurial/obsolete.py	Thu Jun 07 19:15:23 2012 +0200
+++ b/mercurial/obsolete.py	Thu Jun 07 19:19:58 2012 +0200
@@ -120,6 +120,34 @@
             d[key] = value
     return d
 
+class marker(object):
+    """Wrap obsolete marker raw data"""
+
+    def __init__(self, repo, data):
+        # the repo argument will be used to create changectx in later version
+        self._repo = repo
+        self._data = data
+        self._decodedmeta = None
+
+    def precnode(self):
+        """Precursor changeset node identifier"""
+        return self._data[0]
+
+    def succnodes(self):
+        """List of successor changesets node identifiers"""
+        return self._data[1]
+
+    def metadata(self):
+        """Decoded metadata dictionary"""
+        if self._decodedmeta is None:
+            self._decodedmeta = decodemeta(self._data[3])
+        return self._decodedmeta
+
+    def date(self):
+        """Creation date as (unixtime, offset)"""
+        parts = self.metadata()['date'].split(' ')
+        return (float(parts[0]), int(parts[1]))
+
 class obsstore(object):
     """Store obsolete markers