Mercurial > public > mercurial-scm > hg
comparison mercurial/localrepo.py @ 13831:d69c9510d648
changegroup: introduce bundler objects
This makes the bundler pluggable at lower levels.
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Thu, 31 Mar 2011 15:24:06 -0500 |
parents | 2dc6e09f2a7d |
children | e6bd5b403de0 |
comparison
equal
deleted
inserted
replaced
13830:2dc6e09f2a7d | 13831:d69c9510d648 |
---|---|
1519 self.ui.progress( | 1519 self.ui.progress( |
1520 _('bundling'), count[0], item=fstate[0], | 1520 _('bundling'), count[0], item=fstate[0], |
1521 unit=_('files'), total=len(changedfiles)) | 1521 unit=_('files'), total=len(changedfiles)) |
1522 return fstate[1][x] | 1522 return fstate[1][x] |
1523 | 1523 |
1524 # Now that we have all theses utility functions to help out and | 1524 bundler = changegroup.bundle10(lookup) |
1525 # logically divide up the task, generate the group. | 1525 |
1526 def gengroup(): | 1526 def gengroup(): |
1527 # Create a changenode group generator that will call our functions | 1527 # Create a changenode group generator that will call our functions |
1528 # back to lookup the owning changenode and collect information. | 1528 # back to lookup the owning changenode and collect information. |
1529 for chunk in cl.group(csets, lookup): | 1529 for chunk in cl.group(csets, bundler): |
1530 yield chunk | 1530 yield chunk |
1531 self.ui.progress(_('bundling'), None) | 1531 self.ui.progress(_('bundling'), None) |
1532 | 1532 |
1533 # Create a generator for the manifestnodes that calls our lookup | 1533 # Create a generator for the manifestnodes that calls our lookup |
1534 # and data collection functions back. | 1534 # and data collection functions back. |
1535 count[0] = 0 | 1535 count[0] = 0 |
1536 for chunk in mf.group(prune(mf, mfs), lookup): | 1536 for chunk in mf.group(prune(mf, mfs), bundler): |
1537 yield chunk | 1537 yield chunk |
1538 self.ui.progress(_('bundling'), None) | 1538 self.ui.progress(_('bundling'), None) |
1539 | 1539 |
1540 mfs.clear() | 1540 mfs.clear() |
1541 | 1541 |
1548 fstate[0] = fname | 1548 fstate[0] = fname |
1549 fstate[1] = fnodes.pop(fname, {}) | 1549 fstate[1] = fnodes.pop(fname, {}) |
1550 first = True | 1550 first = True |
1551 | 1551 |
1552 for chunk in filerevlog.group(prune(filerevlog, fstate[1]), | 1552 for chunk in filerevlog.group(prune(filerevlog, fstate[1]), |
1553 lookup): | 1553 bundler): |
1554 if first: | 1554 if first: |
1555 if chunk == changegroup.closechunk(): | 1555 if chunk == bundler.close(): |
1556 break | 1556 break |
1557 count[0] += 1 | 1557 count[0] += 1 |
1558 yield changegroup.chunkheader(len(fname)) | 1558 yield bundler.fileheader(fname) |
1559 yield fname | |
1560 first = False | 1559 first = False |
1561 yield chunk | 1560 yield chunk |
1562 # Signal that no more groups are left. | 1561 # Signal that no more groups are left. |
1563 yield changegroup.closechunk() | 1562 yield bundler.close() |
1564 self.ui.progress(_('bundling'), None) | 1563 self.ui.progress(_('bundling'), None) |
1565 | 1564 |
1566 if csets: | 1565 if csets: |
1567 self.hook('outgoing', node=hex(csets[0]), source=source) | 1566 self.hook('outgoing', node=hex(csets[0]), source=source) |
1568 | 1567 |
1616 self.ui.progress( | 1615 self.ui.progress( |
1617 _('bundling'), count[0], item=fstate[0], | 1616 _('bundling'), count[0], item=fstate[0], |
1618 total=len(changedfiles), unit=_('files')) | 1617 total=len(changedfiles), unit=_('files')) |
1619 return cl.node(revlog.linkrev(revlog.rev(x))) | 1618 return cl.node(revlog.linkrev(revlog.rev(x))) |
1620 | 1619 |
1620 bundler = changegroup.bundle10(lookup) | |
1621 | |
1621 def gengroup(): | 1622 def gengroup(): |
1622 '''yield a sequence of changegroup chunks (strings)''' | 1623 '''yield a sequence of changegroup chunks (strings)''' |
1623 # construct a list of all changed files | 1624 # construct a list of all changed files |
1624 | 1625 |
1625 for chunk in cl.group(nodes, lookup): | 1626 for chunk in cl.group(nodes, bundler): |
1626 yield chunk | 1627 yield chunk |
1627 self.ui.progress(_('bundling'), None) | 1628 self.ui.progress(_('bundling'), None) |
1628 | 1629 |
1629 count[0] = 0 | 1630 count[0] = 0 |
1630 for chunk in mf.group(gennodelst(mf), lookup): | 1631 for chunk in mf.group(gennodelst(mf), bundler): |
1631 yield chunk | 1632 yield chunk |
1632 self.ui.progress(_('bundling'), None) | 1633 self.ui.progress(_('bundling'), None) |
1633 | 1634 |
1634 count[0] = 0 | 1635 count[0] = 0 |
1635 for fname in sorted(changedfiles): | 1636 for fname in sorted(changedfiles): |
1636 filerevlog = self.file(fname) | 1637 filerevlog = self.file(fname) |
1637 if not len(filerevlog): | 1638 if not len(filerevlog): |
1638 raise util.Abort(_("empty or missing revlog for %s") % fname) | 1639 raise util.Abort(_("empty or missing revlog for %s") % fname) |
1639 fstate[0] = fname | 1640 fstate[0] = fname |
1640 first = True | 1641 first = True |
1641 for chunk in filerevlog.group(gennodelst(filerevlog), lookup): | 1642 for chunk in filerevlog.group(gennodelst(filerevlog), bundler): |
1642 if first: | 1643 if first: |
1643 if chunk == changegroup.closechunk(): | 1644 if chunk == bundler.close(): |
1644 break | 1645 break |
1645 count[0] += 1 | 1646 count[0] += 1 |
1646 yield changegroup.chunkheader(len(fname)) | 1647 yield bundler.fileheader(fname) |
1647 yield fname | |
1648 first = False | 1648 first = False |
1649 yield chunk | 1649 yield chunk |
1650 yield changegroup.closechunk() | 1650 yield bundler.close() |
1651 self.ui.progress(_('bundling'), None) | 1651 self.ui.progress(_('bundling'), None) |
1652 | 1652 |
1653 if nodes: | 1653 if nodes: |
1654 self.hook('outgoing', node=hex(nodes[0]), source=source) | 1654 self.hook('outgoing', node=hex(nodes[0]), source=source) |
1655 | 1655 |