diff mercurial/obsutil.py @ 33154:4e30168d7939

obsutil: move the 'marker' class to the new modules We have a new 'obsutil' module now. We move high level utility there to bring 'obsolete.py' back to a more reasonable size.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Tue, 27 Jun 2017 01:51:40 +0200
parents 7017567ebdf2
children a14e2e7f7d1f
line wrap: on
line diff
--- a/mercurial/obsutil.py	Tue Jun 27 01:48:41 2017 +0200
+++ b/mercurial/obsutil.py	Tue Jun 27 01:51:40 2017 +0200
@@ -7,6 +7,47 @@
 
 from __future__ import absolute_import
 
+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 __hash__(self):
+        return hash(self._data)
+
+    def __eq__(self, other):
+        if type(other) != type(self):
+            return False
+        return self._data == other._data
+
+    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 parentnodes(self):
+        """Parents of the precursors (None if not recorded)"""
+        return self._data[5]
+
+    def metadata(self):
+        """Decoded metadata dictionary"""
+        return dict(self._data[3])
+
+    def date(self):
+        """Creation date as (unixtime, offset)"""
+        return self._data[4]
+
+    def flags(self):
+        """The flags field of the marker"""
+        return self._data[2]
+
 def closestpredecessors(repo, nodeid):
     """yield the list of next predecessors pointing on visible changectx nodes