obsolete: have _readmarkers return the format version
authorPierre-Yves David <pierre-yves.david@fb.com>
Mon, 25 Aug 2014 16:51:51 +0200
changeset 22332 13e22358e9d2
parent 22331 b130b241718e
child 22333 5bf18f8ca89d
obsolete: have _readmarkers return the format version readmarkers is not returning the version of the format it read from. This will let callers know about the format and allow them to preserve it.
mercurial/obsolete.py
--- a/mercurial/obsolete.py	Mon Aug 25 16:16:01 2014 +0200
+++ b/mercurial/obsolete.py	Mon Aug 25 16:51:51 2014 +0200
@@ -145,7 +145,7 @@
     if diskversion not in formats:
         raise util.Abort(_('parsing obsolete marker: unknown version %r')
                          % diskversion)
-    return formats[diskversion][0](data, off)
+    return diskversion, formats[diskversion][0](data, off)
 
 def _fm0readmarkers(data, off=0):
     """Read and enumerate markers from raw data in format version 0"""
@@ -312,7 +312,8 @@
         self.sopener = sopener
         data = sopener.tryread('obsstore')
         if data:
-            self._load(_readmarkers(data))
+            version, markers = _readmarkers(data)
+            self._load(markers)
 
     def __iter__(self):
         return iter(self._all)
@@ -396,7 +397,7 @@
         """merge a binary stream of markers inside the obsstore
 
         Returns the number of new markers added."""
-        markers = _readmarkers(data)
+        version, markers = _readmarkers(data)
         return self.add(transaction, markers)
 
     def _load(self, markers):