Mercurial > hg
comparison mercurial/localrepo.py @ 13788:307c72686eb0
changegroup: fold linkrev helper into lookup functions
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Mon, 28 Mar 2011 11:18:56 -0500 |
parents | 5333c87f6048 |
children | 43b5fe18ea6c |
comparison
equal
deleted
inserted
replaced
13787:5333c87f6048 | 13788:307c72686eb0 |
---|---|
1608 def gennodelst(log): | 1608 def gennodelst(log): |
1609 for r in log: | 1609 for r in log: |
1610 if log.linkrev(r) in revset: | 1610 if log.linkrev(r) in revset: |
1611 yield log.node(r) | 1611 yield log.node(r) |
1612 | 1612 |
1613 def lookuplinkrev_func(revlog): | |
1614 def lookuplinkrev(n): | |
1615 return cl.node(revlog.linkrev(revlog.rev(n))) | |
1616 return lookuplinkrev | |
1617 | |
1618 def gengroup(): | 1613 def gengroup(): |
1619 '''yield a sequence of changegroup chunks (strings)''' | 1614 '''yield a sequence of changegroup chunks (strings)''' |
1620 # construct a list of all changed files | 1615 # construct a list of all changed files |
1621 changedfiles = set() | 1616 changedfiles = set() |
1622 mmfs = {} | 1617 mmfs = {} |
1636 changecount = count[0] | 1631 changecount = count[0] |
1637 self.ui.progress(_('bundling'), None) | 1632 self.ui.progress(_('bundling'), None) |
1638 | 1633 |
1639 mnfst = self.manifest | 1634 mnfst = self.manifest |
1640 nodeiter = gennodelst(mnfst) | 1635 nodeiter = gennodelst(mnfst) |
1641 mfunc = lookuplinkrev_func(mnfst) | |
1642 count = [0] | 1636 count = [0] |
1643 def mlookup(revlog, x): | 1637 def mlookup(revlog, x): |
1644 count[0] += 1 | 1638 count[0] += 1 |
1645 self.ui.progress(_('bundling'), count[0], | 1639 self.ui.progress(_('bundling'), count[0], |
1646 unit=_('manifests'), total=changecount) | 1640 unit=_('manifests'), total=changecount) |
1647 return mfunc(x) | 1641 return cl.node(revlog.linkrev(revlog.rev(x))) |
1648 | 1642 |
1649 for chunk in mnfst.group(nodeiter, mlookup): | 1643 for chunk in mnfst.group(nodeiter, mlookup): |
1650 yield chunk | 1644 yield chunk |
1651 self.ui.progress(_('bundling'), None) | 1645 self.ui.progress(_('bundling'), None) |
1652 | 1646 |
1657 nodeiter = gennodelst(filerevlog) | 1651 nodeiter = gennodelst(filerevlog) |
1658 nodeiter = list(nodeiter) | 1652 nodeiter = list(nodeiter) |
1659 if nodeiter: | 1653 if nodeiter: |
1660 yield changegroup.chunkheader(len(fname)) | 1654 yield changegroup.chunkheader(len(fname)) |
1661 yield fname | 1655 yield fname |
1662 ffunc = lookuplinkrev_func(filerevlog) | |
1663 def flookup(revlog, x): | 1656 def flookup(revlog, x): |
1664 self.ui.progress( | 1657 self.ui.progress( |
1665 _('bundling'), idx, item=fname, | 1658 _('bundling'), idx, item=fname, |
1666 total=efiles, unit=_('files')) | 1659 total=efiles, unit=_('files')) |
1667 return ffunc(x) | 1660 return cl.node(revlog.linkrev(revlog.rev(x))) |
1668 | 1661 |
1669 for chunk in filerevlog.group(nodeiter, flookup): | 1662 for chunk in filerevlog.group(nodeiter, flookup): |
1670 yield chunk | 1663 yield chunk |
1671 self.ui.progress(_('bundling'), None) | 1664 self.ui.progress(_('bundling'), None) |
1672 | 1665 |