Mercurial > hg
changeset 35308:137a08d82232
transaction: build changes['revs'] as range instead of a set
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.
Differential Revision: https://phab.mercurial-scm.org/D1615
author | Joerg Sonnenberger <joerg@bec.de> |
---|---|
date | Fri, 08 Dec 2017 01:23:34 +0100 |
parents | 4caafe280488 |
children | d13526333835 |
files | mercurial/changelog.py mercurial/localrepo.py mercurial/obsutil.py mercurial/scmutil.py |
diffstat | 4 files changed, 10 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/changelog.py Wed Dec 06 16:43:07 2017 -0500 +++ b/mercurial/changelog.py Fri Dec 08 01:23:34 2017 +0100 @@ -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
--- a/mercurial/localrepo.py Wed Dec 06 16:43:07 2017 -0500 +++ b/mercurial/localrepo.py Fri Dec 08 01:23:34 2017 +0100 @@ -1275,7 +1275,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'] = {}
--- a/mercurial/obsutil.py Wed Dec 06 16:43:07 2017 -0500 +++ b/mercurial/obsutil.py Fri Dec 08 01:23:34 2017 +0100 @@ -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:
--- a/mercurial/scmutil.py Wed Dec 06 16:43:07 2017 -0500 +++ b/mercurial/scmutil.py Fri Dec 08 01:23:34 2017 +0100 @@ -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