Mercurial > public > mercurial-scm > hg
comparison mercurial/localrepo.py @ 13782:9131724c3f4b
changegroup: combine infocollect and lookup callbacks
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Mon, 28 Mar 2011 11:18:56 -0500 |
parents | 7abab875e647 |
children | c196352d935b |
comparison
equal
deleted
inserted
replaced
13781:66c54d2ebe72 | 13782:9131724c3f4b |
---|---|
1527 # Now that we have all theses utility functions to help out and | 1527 # Now that we have all theses utility functions to help out and |
1528 # logically divide up the task, generate the group. | 1528 # logically divide up the task, generate the group. |
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 collect = changegroup.collector(cl, mfs, changedfiles) | 1533 collect = changegroup.collector(cl, mfs, changedfiles) |
1534 def clookup(x): | |
1535 collect(x) | |
1536 return x | |
1533 | 1537 |
1534 # Create a changenode group generator that will call our functions | 1538 # Create a changenode group generator that will call our functions |
1535 # back to lookup the owning changenode and collect information. | 1539 # back to lookup the owning changenode and collect information. |
1536 group = cl.group(csets, lambda x: x, collect) | 1540 group = cl.group(csets, clookup) |
1537 for count, chunk in enumerate(group): | 1541 for count, chunk in enumerate(group): |
1538 yield chunk | 1542 yield chunk |
1539 # revlog.group yields three entries per node, so | 1543 # revlog.group yields three entries per node, so |
1540 # dividing by 3 gives an approximation of how many | 1544 # dividing by 3 gives an approximation of how many |
1541 # nodes have been processed. | 1545 # nodes have been processed. |
1546 self.ui.progress(_('bundling'), None) | 1550 self.ui.progress(_('bundling'), None) |
1547 | 1551 |
1548 prune(mf, mfs) | 1552 prune(mf, mfs) |
1549 # Create a generator for the manifestnodes that calls our lookup | 1553 # Create a generator for the manifestnodes that calls our lookup |
1550 # and data collection functions back. | 1554 # and data collection functions back. |
1551 group = mf.group(sorted(mfs, key=mf.rev), | 1555 fcollect = filenode_collector(changedfiles) |
1552 lambda mnode: mfs[mnode], | 1556 def mlookup(x): |
1553 filenode_collector(changedfiles)) | 1557 fcollect(x) |
1558 return mfs[x] | |
1559 | |
1560 group = mf.group(sorted(mfs, key=mf.rev), mlookup) | |
1554 for count, chunk in enumerate(group): | 1561 for count, chunk in enumerate(group): |
1555 yield chunk | 1562 yield chunk |
1556 # see above comment for why we divide by 3 | 1563 # see above comment for why we divide by 3 |
1557 self.ui.progress(_('bundling'), count / 3, | 1564 self.ui.progress(_('bundling'), count / 3, |
1558 unit=_('manifests'), total=changecount) | 1565 unit=_('manifests'), total=changecount) |
1575 yield changegroup.chunkheader(len(fname)) | 1582 yield changegroup.chunkheader(len(fname)) |
1576 yield fname | 1583 yield fname |
1577 # Create a group generator and only pass in a changenode | 1584 # Create a group generator and only pass in a changenode |
1578 # lookup function as we need to collect no information | 1585 # lookup function as we need to collect no information |
1579 # from filenodes. | 1586 # from filenodes. |
1587 def flookup(x): | |
1588 return missingfnodes[x] | |
1589 | |
1580 group = filerevlog.group( | 1590 group = filerevlog.group( |
1581 sorted(missingfnodes, key=filerevlog.rev), | 1591 sorted(missingfnodes, key=filerevlog.rev), |
1582 lambda fnode: missingfnodes[fnode]) | 1592 flookup) |
1583 for chunk in group: | 1593 for chunk in group: |
1584 # even though we print the same progress on | 1594 # even though we print the same progress on |
1585 # most loop iterations, put the progress call | 1595 # most loop iterations, put the progress call |
1586 # here so that time estimates (if any) can be updated | 1596 # here so that time estimates (if any) can be updated |
1587 self.ui.progress( | 1597 self.ui.progress( |
1630 def gengroup(): | 1640 def gengroup(): |
1631 '''yield a sequence of changegroup chunks (strings)''' | 1641 '''yield a sequence of changegroup chunks (strings)''' |
1632 # construct a list of all changed files | 1642 # construct a list of all changed files |
1633 changedfiles = set() | 1643 changedfiles = set() |
1634 mmfs = {} | 1644 mmfs = {} |
1645 | |
1635 collect = changegroup.collector(cl, mmfs, changedfiles) | 1646 collect = changegroup.collector(cl, mmfs, changedfiles) |
1636 | 1647 def clookup(x): |
1637 for count, chunk in enumerate(cl.group(nodes, lambda x: x, collect)): | 1648 collect(x) |
1649 return x | |
1650 | |
1651 for count, chunk in enumerate(cl.group(nodes, clookup)): | |
1638 # revlog.group yields three entries per node, so | 1652 # revlog.group yields three entries per node, so |
1639 # dividing by 3 gives an approximation of how many | 1653 # dividing by 3 gives an approximation of how many |
1640 # nodes have been processed. | 1654 # nodes have been processed. |
1641 self.ui.progress(_('bundling'), count / 3, unit=_('changesets')) | 1655 self.ui.progress(_('bundling'), count / 3, unit=_('changesets')) |
1642 yield chunk | 1656 yield chunk |
1644 changecount = count / 3 | 1658 changecount = count / 3 |
1645 self.ui.progress(_('bundling'), None) | 1659 self.ui.progress(_('bundling'), None) |
1646 | 1660 |
1647 mnfst = self.manifest | 1661 mnfst = self.manifest |
1648 nodeiter = gennodelst(mnfst) | 1662 nodeiter = gennodelst(mnfst) |
1649 for count, chunk in enumerate(mnfst.group(nodeiter, | 1663 mfunc = lookuplinkrev_func(mnfst) |
1650 lookuplinkrev_func(mnfst))): | 1664 def mlookup(x): |
1665 return mfunc(x) | |
1666 | |
1667 for count, chunk in enumerate(mnfst.group(nodeiter, mlookup)): | |
1651 # see above comment for why we divide by 3 | 1668 # see above comment for why we divide by 3 |
1652 self.ui.progress(_('bundling'), count / 3, | 1669 self.ui.progress(_('bundling'), count / 3, |
1653 unit=_('manifests'), total=changecount) | 1670 unit=_('manifests'), total=changecount) |
1654 yield chunk | 1671 yield chunk |
1655 self.ui.progress(_('bundling'), None) | 1672 self.ui.progress(_('bundling'), None) |
1661 nodeiter = gennodelst(filerevlog) | 1678 nodeiter = gennodelst(filerevlog) |
1662 nodeiter = list(nodeiter) | 1679 nodeiter = list(nodeiter) |
1663 if nodeiter: | 1680 if nodeiter: |
1664 yield changegroup.chunkheader(len(fname)) | 1681 yield changegroup.chunkheader(len(fname)) |
1665 yield fname | 1682 yield fname |
1666 lookup = lookuplinkrev_func(filerevlog) | 1683 ffunc = lookuplinkrev_func(filerevlog) |
1667 for chunk in filerevlog.group(nodeiter, lookup): | 1684 def flookup(x): |
1685 return ffunc(x) | |
1686 | |
1687 for chunk in filerevlog.group(nodeiter, flookup): | |
1668 self.ui.progress( | 1688 self.ui.progress( |
1669 _('bundling'), idx, item=fname, | 1689 _('bundling'), idx, item=fname, |
1670 total=efiles, unit=_('files')) | 1690 total=efiles, unit=_('files')) |
1671 yield chunk | 1691 yield chunk |
1672 self.ui.progress(_('bundling'), None) | 1692 self.ui.progress(_('bundling'), None) |