changeset 1419:2e4145e452cd

maps: add "lasthash" property to RevMap This is a part of the bigger plan to get rid of reading or writing rev_map directly without going through the RevMap class. The "lasthash" property will be used in updatemeta.
author Jun Wu <quark@fb.com>
date Mon, 23 May 2016 23:36:28 +0100
parents c161586a6b77
children 014c47a8e653
files hgsubversion/maps.py
diffstat 1 files changed, 7 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/hgsubversion/maps.py
+++ b/hgsubversion/maps.py
@@ -355,6 +355,13 @@ class RevMap(dict):
         check = lambda x: x[0][1] == branch and x[0][0] < rev.revnum
         return sorted(filter(check, self.iteritems()), reverse=True)
 
+    @property
+    def lasthash(self):
+        lines = list(self.readmapfile(self.meta.revmap_file))
+        if not lines:
+            return None
+        return bin(lines[-1].split(' ', 2)[1])
+
     def revhashes(self, revnum):
         for key, value in self.iteritems():
             if key[0] == revnum: