comparison mercurial/scmutil.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 f98d3c57906f
children 570fca90d556
comparison
equal deleted inserted replaced
39300:52e6171ec822 39301:5763216ba311
1616 1616
1617 if txmatch(_reportnewcssource): 1617 if txmatch(_reportnewcssource):
1618 @reportsummary 1618 @reportsummary
1619 def reportnewcs(repo, tr): 1619 def reportnewcs(repo, tr):
1620 """Report the range of new revisions pulled/unbundled.""" 1620 """Report the range of new revisions pulled/unbundled."""
1621 newrevs = tr.changes.get('revs', pycompat.xrange(0, 0)) 1621 origrepolen = tr.changes.get('origrepolen', len(repo))
1622 if not newrevs: 1622 if origrepolen >= len(repo):
1623 return 1623 return
1624 1624
1625 # Compute the bounds of new revisions' range, excluding obsoletes. 1625 # Compute the bounds of new revisions' range, excluding obsoletes.
1626 unfi = repo.unfiltered() 1626 unfi = repo.unfiltered()
1627 revs = unfi.revs('%ld and not obsolete()', newrevs) 1627 revs = unfi.revs('%d: and not obsolete()', origrepolen)
1628 if not revs: 1628 if not revs:
1629 # Got only obsoletes. 1629 # Got only obsoletes.
1630 return 1630 return
1631 minrev, maxrev = repo[revs.min()], repo[revs.max()] 1631 minrev, maxrev = repo[revs.min()], repo[revs.max()]
1632 1632
1639 @reportsummary 1639 @reportsummary
1640 def reportphasechanges(repo, tr): 1640 def reportphasechanges(repo, tr):
1641 """Report statistics of phase changes for changesets pre-existing 1641 """Report statistics of phase changes for changesets pre-existing
1642 pull/unbundle. 1642 pull/unbundle.
1643 """ 1643 """
1644 newrevs = tr.changes.get('revs', pycompat.xrange(0, 0)) 1644 origrepolen = tr.changes.get('origrepolen', len(repo))
1645 phasetracking = tr.changes.get('phases', {}) 1645 phasetracking = tr.changes.get('phases', {})
1646 if not phasetracking: 1646 if not phasetracking:
1647 return 1647 return
1648 published = [ 1648 published = [
1649 rev for rev, (old, new) in phasetracking.iteritems() 1649 rev for rev, (old, new) in phasetracking.iteritems()
1650 if new == phases.public and rev not in newrevs 1650 if new == phases.public and rev < origrepolen
1651 ] 1651 ]
1652 if not published: 1652 if not published:
1653 return 1653 return
1654 repo.ui.status(_('%d local changesets published\n') 1654 repo.ui.status(_('%d local changesets published\n')
1655 % len(published)) 1655 % len(published))