Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/localrepo.py @ 13783:c196352d935b
changegroup: fold progress meter into callbacks
progress meters now start at 1 rather than 0
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Mon, 28 Mar 2011 11:18:56 -0500 |
parents | 9131724c3f4b |
children | f1e639c71a2b |
comparison
equal
deleted
inserted
replaced
13782:9131724c3f4b | 13783:c196352d935b |
---|---|
1529 def gengroup(): | 1529 def gengroup(): |
1530 # The set of changed files starts empty. | 1530 # The set of changed files starts empty. |
1531 changedfiles = set() | 1531 changedfiles = set() |
1532 | 1532 |
1533 collect = changegroup.collector(cl, mfs, changedfiles) | 1533 collect = changegroup.collector(cl, mfs, changedfiles) |
1534 count = [0] | |
1534 def clookup(x): | 1535 def clookup(x): |
1535 collect(x) | 1536 collect(x) |
1537 count[0] += 1 | |
1538 self.ui.progress(_('bundling'), count[0], unit=_('changesets')) | |
1536 return x | 1539 return x |
1537 | 1540 |
1538 # Create a changenode group generator that will call our functions | 1541 # Create a changenode group generator that will call our functions |
1539 # back to lookup the owning changenode and collect information. | 1542 # back to lookup the owning changenode and collect information. |
1540 group = cl.group(csets, clookup) | 1543 for chunk in cl.group(csets, clookup): |
1541 for count, chunk in enumerate(group): | |
1542 yield chunk | 1544 yield chunk |
1543 # revlog.group yields three entries per node, so | 1545 changecount = count[0] |
1544 # dividing by 3 gives an approximation of how many | |
1545 # nodes have been processed. | |
1546 self.ui.progress(_('bundling'), count / 3, | |
1547 unit=_('changesets')) | |
1548 changecount = count / 3 | |
1549 efiles = len(changedfiles) | 1546 efiles = len(changedfiles) |
1550 self.ui.progress(_('bundling'), None) | 1547 self.ui.progress(_('bundling'), None) |
1551 | 1548 |
1552 prune(mf, mfs) | 1549 prune(mf, mfs) |
1553 # Create a generator for the manifestnodes that calls our lookup | 1550 # Create a generator for the manifestnodes that calls our lookup |
1554 # and data collection functions back. | 1551 # and data collection functions back. |
1555 fcollect = filenode_collector(changedfiles) | 1552 fcollect = filenode_collector(changedfiles) |
1553 count = [0] | |
1556 def mlookup(x): | 1554 def mlookup(x): |
1557 fcollect(x) | 1555 fcollect(x) |
1556 count[0] += 1 | |
1557 self.ui.progress(_('bundling'), count[0], | |
1558 unit=_('manifests'), total=changecount) | |
1558 return mfs[x] | 1559 return mfs[x] |
1559 | 1560 |
1560 group = mf.group(sorted(mfs, key=mf.rev), mlookup) | 1561 for chunk in mf.group(sorted(mfs, key=mf.rev), mlookup): |
1561 for count, chunk in enumerate(group): | |
1562 yield chunk | 1562 yield chunk |
1563 # see above comment for why we divide by 3 | |
1564 self.ui.progress(_('bundling'), count / 3, | |
1565 unit=_('manifests'), total=changecount) | |
1566 self.ui.progress(_('bundling'), None) | 1563 self.ui.progress(_('bundling'), None) |
1567 | 1564 |
1568 mfs.clear() | 1565 mfs.clear() |
1569 | 1566 |
1570 # Go through all our files in order sorted by name. | 1567 # Go through all our files in order sorted by name. |
1583 yield fname | 1580 yield fname |
1584 # Create a group generator and only pass in a changenode | 1581 # Create a group generator and only pass in a changenode |
1585 # lookup function as we need to collect no information | 1582 # lookup function as we need to collect no information |
1586 # from filenodes. | 1583 # from filenodes. |
1587 def flookup(x): | 1584 def flookup(x): |
1588 return missingfnodes[x] | |
1589 | |
1590 group = filerevlog.group( | |
1591 sorted(missingfnodes, key=filerevlog.rev), | |
1592 flookup) | |
1593 for chunk in group: | |
1594 # even though we print the same progress on | 1585 # even though we print the same progress on |
1595 # most loop iterations, put the progress call | 1586 # most loop iterations, put the progress call |
1596 # here so that time estimates (if any) can be updated | 1587 # here so that time estimates (if any) can be updated |
1597 self.ui.progress( | 1588 self.ui.progress( |
1598 _('bundling'), idx, item=fname, | 1589 _('bundling'), idx, item=fname, |
1599 unit=_('files'), total=efiles) | 1590 unit=_('files'), total=efiles) |
1591 return missingfnodes[x] | |
1592 | |
1593 for chunk in filerevlog.group( | |
1594 sorted(missingfnodes, key=filerevlog.rev), flookup): | |
1600 yield chunk | 1595 yield chunk |
1601 # Signal that no more groups are left. | 1596 # Signal that no more groups are left. |
1602 yield changegroup.closechunk() | 1597 yield changegroup.closechunk() |
1603 self.ui.progress(_('bundling'), None) | 1598 self.ui.progress(_('bundling'), None) |
1604 | 1599 |
1642 # construct a list of all changed files | 1637 # construct a list of all changed files |
1643 changedfiles = set() | 1638 changedfiles = set() |
1644 mmfs = {} | 1639 mmfs = {} |
1645 | 1640 |
1646 collect = changegroup.collector(cl, mmfs, changedfiles) | 1641 collect = changegroup.collector(cl, mmfs, changedfiles) |
1642 count = [0] | |
1647 def clookup(x): | 1643 def clookup(x): |
1644 count[0] += 1 | |
1645 self.ui.progress(_('bundling'), count[0], unit=_('changesets')) | |
1648 collect(x) | 1646 collect(x) |
1649 return x | 1647 return x |
1650 | 1648 |
1651 for count, chunk in enumerate(cl.group(nodes, clookup)): | 1649 for chunk in cl.group(nodes, clookup): |
1652 # revlog.group yields three entries per node, so | |
1653 # dividing by 3 gives an approximation of how many | |
1654 # nodes have been processed. | |
1655 self.ui.progress(_('bundling'), count / 3, unit=_('changesets')) | |
1656 yield chunk | 1650 yield chunk |
1657 efiles = len(changedfiles) | 1651 efiles = len(changedfiles) |
1658 changecount = count / 3 | 1652 changecount = count[0] |
1659 self.ui.progress(_('bundling'), None) | 1653 self.ui.progress(_('bundling'), None) |
1660 | 1654 |
1661 mnfst = self.manifest | 1655 mnfst = self.manifest |
1662 nodeiter = gennodelst(mnfst) | 1656 nodeiter = gennodelst(mnfst) |
1663 mfunc = lookuplinkrev_func(mnfst) | 1657 mfunc = lookuplinkrev_func(mnfst) |
1658 count = [0] | |
1664 def mlookup(x): | 1659 def mlookup(x): |
1660 count[0] += 1 | |
1661 self.ui.progress(_('bundling'), count[0], | |
1662 unit=_('manifests'), total=changecount) | |
1665 return mfunc(x) | 1663 return mfunc(x) |
1666 | 1664 |
1667 for count, chunk in enumerate(mnfst.group(nodeiter, mlookup)): | 1665 for chunk in mnfst.group(nodeiter, mlookup): |
1668 # see above comment for why we divide by 3 | |
1669 self.ui.progress(_('bundling'), count / 3, | |
1670 unit=_('manifests'), total=changecount) | |
1671 yield chunk | 1666 yield chunk |
1672 self.ui.progress(_('bundling'), None) | 1667 self.ui.progress(_('bundling'), None) |
1673 | 1668 |
1674 for idx, fname in enumerate(sorted(changedfiles)): | 1669 for idx, fname in enumerate(sorted(changedfiles)): |
1675 filerevlog = self.file(fname) | 1670 filerevlog = self.file(fname) |
1680 if nodeiter: | 1675 if nodeiter: |
1681 yield changegroup.chunkheader(len(fname)) | 1676 yield changegroup.chunkheader(len(fname)) |
1682 yield fname | 1677 yield fname |
1683 ffunc = lookuplinkrev_func(filerevlog) | 1678 ffunc = lookuplinkrev_func(filerevlog) |
1684 def flookup(x): | 1679 def flookup(x): |
1685 return ffunc(x) | |
1686 | |
1687 for chunk in filerevlog.group(nodeiter, flookup): | |
1688 self.ui.progress( | 1680 self.ui.progress( |
1689 _('bundling'), idx, item=fname, | 1681 _('bundling'), idx, item=fname, |
1690 total=efiles, unit=_('files')) | 1682 total=efiles, unit=_('files')) |
1683 return ffunc(x) | |
1684 | |
1685 for chunk in filerevlog.group(nodeiter, flookup): | |
1691 yield chunk | 1686 yield chunk |
1692 self.ui.progress(_('bundling'), None) | 1687 self.ui.progress(_('bundling'), None) |
1693 | 1688 |
1694 yield changegroup.closechunk() | 1689 yield changegroup.closechunk() |
1695 | 1690 |