Mercurial > hg
comparison mercurial/changelog.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 | 0a5b20c107a6 |
children | b63dee7bd0d9 |
comparison
equal
deleted
inserted
replaced
39300:52e6171ec822 | 39301:5763216ba311 |
---|---|
543 | 543 |
544 This function exists because creating a changectx object | 544 This function exists because creating a changectx object |
545 just to access this is costly.""" | 545 just to access this is costly.""" |
546 extra = self.read(rev)[5] | 546 extra = self.read(rev)[5] |
547 return encoding.tolocal(extra.get("branch")), 'close' in extra | 547 return encoding.tolocal(extra.get("branch")), 'close' in extra |
548 | |
549 def _addrevision(self, node, rawtext, transaction, *args, **kwargs): | |
550 # overlay over the standard revlog._addrevision to track the new | |
551 # revision on the transaction. | |
552 rev = len(self) | |
553 node = super(changelog, self)._addrevision(node, rawtext, transaction, | |
554 *args, **kwargs) | |
555 revs = transaction.changes.get('revs') | |
556 if revs is not None: | |
557 if revs: | |
558 assert revs[-1] + 1 == rev | |
559 revs = pycompat.membershiprange(revs[0], rev + 1) | |
560 else: | |
561 revs = pycompat.membershiprange(rev, rev + 1) | |
562 transaction.changes['revs'] = revs | |
563 return node |