diff mercurial/localrepo.py @ 39301:5763216ba311

transaction: remember original len(repo) instead of tracking added revs (API) It's silly to keep updating xrange(len(changelog), len(changelog) + 1) for each added revision. Instead, let's simply remember the first revision to be added. The test output slightly changed as the branch cache is also warmed up by stream clone, which seems more consistent. .. api:: ``tr.changes['revs']`` is replaced by ``tr.changes['origrepolen']`` which is the first revision number to be added.
author Yuya Nishihara <yuya@tcha.org>
date Sat, 25 Aug 2018 15:28:48 +0900
parents 7a9f15ed3b96
children 9198e41df6ef
line wrap: on
line diff
--- a/mercurial/localrepo.py	Sat Aug 25 15:19:43 2018 +0900
+++ b/mercurial/localrepo.py	Sat Aug 25 15:28:48 2018 +0900
@@ -1393,7 +1393,7 @@
                                      releasefn=releasefn,
                                      checkambigfiles=_cachedfiles,
                                      name=desc)
-        tr.changes['revs'] = pycompat.xrange(0, 0)
+        tr.changes['origrepolen'] = len(self)
         tr.changes['obsmarkers'] = set()
         tr.changes['phases'] = {}
         tr.changes['bookmarks'] = {}
@@ -1611,7 +1611,7 @@
             # later call to `destroyed` will refresh them.
             return
 
-        if tr is None or tr.changes['revs']:
+        if tr is None or tr.changes['origrepolen'] < len(self):
             # updating the unfiltered branchmap should refresh all the others,
             self.ui.debug('updating the branch cache\n')
             branchmap.updatecache(self.filtered('served'))