D1615: transaction: build changes['revs'] as range instead of a set.

joerg.sonnenberger (Joerg Sonnenberger) phabricator at mercurial-scm.org
Fri Dec 8 00:24:59 UTC 2017


joerg.sonnenberger created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  Revisions are added consecutively, so a range can easily represent them
  in the changes list. This saves around 45 Bytes / revision on 64bit
  platforms and reduces the memory footprint of issue5691 by 15MB.
  
  Don't copy changes['revs'] in getobsoleted. Ranges have a very efficient
  contains implementation already.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D1615

AFFECTED FILES
  mercurial/changelog.py
  mercurial/localrepo.py
  mercurial/obsutil.py
  mercurial/scmutil.py

CHANGE DETAILS

diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py
--- a/mercurial/scmutil.py
+++ b/mercurial/scmutil.py
@@ -1262,7 +1262,7 @@
         @reportsummary
         def reportnewcs(repo, tr):
             """Report the range of new revisions pulled/unbundled."""
-            newrevs = list(tr.changes.get('revs', set()))
+            newrevs = tr.changes.get('revs', xrange(0, 0))
             if not newrevs:
                 return
 
diff --git a/mercurial/obsutil.py b/mercurial/obsutil.py
--- a/mercurial/obsutil.py
+++ b/mercurial/obsutil.py
@@ -441,12 +441,12 @@
     public = phases.public
     addedmarkers = tr.changes.get('obsmarkers')
     addedrevs = tr.changes.get('revs')
-    seenrevs = set(addedrevs)
+    seenrevs = set()
     obsoleted = set()
     for mark in addedmarkers:
         node = mark[0]
         rev = torev(node)
-        if rev is None or rev in seenrevs:
+        if rev is None or rev in seenrevs or rev in addedrevs:
             continue
         seenrevs.add(rev)
         if phase(repo, rev) == public:
diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -1291,7 +1291,7 @@
                                      validator=validate,
                                      releasefn=releasefn,
                                      checkambigfiles=_cachedfiles)
-        tr.changes['revs'] = set()
+        tr.changes['revs'] = xrange(0, 0)
         tr.changes['obsmarkers'] = set()
         tr.changes['phases'] = {}
         tr.changes['bookmarks'] = {}
diff --git a/mercurial/changelog.py b/mercurial/changelog.py
--- a/mercurial/changelog.py
+++ b/mercurial/changelog.py
@@ -541,5 +541,10 @@
                                                    *args, **kwargs)
         revs = transaction.changes.get('revs')
         if revs is not None:
-            revs.add(rev)
+            if revs:
+                assert revs[-1] + 1 == rev
+                revs = xrange(revs[0], rev + 1)
+            else:
+                revs = xrange(rev, rev + 1)
+            transaction.changes['revs'] = revs
         return node



To: joerg.sonnenberger, #hg-reviewers
Cc: mercurial-devel


More information about the Mercurial-devel mailing list