mercurial/branchmap.py
changeset 23863 669106fc5bb1
parent 23862 7aa1405528a3
child 23877 7cc77030c557
--- a/mercurial/branchmap.py	Wed Jan 14 01:15:26 2015 +0100
+++ b/mercurial/branchmap.py	Wed Jan 14 01:15:26 2015 +0100
@@ -431,8 +431,7 @@
 
         start = self._rbcrevslen * _rbcrecsize
         if start != len(self._rbcrevs):
-            self._rbcrevslen = min(len(repo.changelog),
-                                   len(self._rbcrevs) // _rbcrecsize)
+            revs = min(len(repo.changelog), len(self._rbcrevs) // _rbcrecsize)
             try:
                 f = repo.vfs.open(_rbcrevs, 'ab')
                 # The position after open(x, 'a') is implementation defined-
@@ -442,10 +441,11 @@
                     repo.ui.debug("truncating %s to %s\n" % (_rbcrevs, start))
                     f.seek(start)
                     f.truncate()
-                end = self._rbcrevslen * _rbcrecsize
+                end = revs * _rbcrecsize
                 f.write(self._rbcrevs[start:end])
                 f.close()
             except (IOError, OSError, util.Abort), inst:
                 repo.ui.debug("couldn't write revision branch cache: %s\n" %
                               inst)
                 return
+            self._rbcrevslen = revs