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

login
register
mail settings
Submitter phabricator
Date Dec. 8, 2017, 12:24 a.m.
Message ID <differential-rev-PHID-DREV-mikga6evy7ruhh2qdgtz-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/26061/
State Superseded
Headers show

Comments

phabricator - Dec. 8, 2017, 12:24 a.m.
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




To: joerg.sonnenberger, #hg-reviewers
Cc: mercurial-devel
phabricator - Dec. 8, 2017, 1:51 a.m.
quark accepted this revision.
quark added a comment.


  Very nice!

REPOSITORY
  rHG Mercurial

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

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

Patch

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