comparison mercurial/localrepo.py @ 13809:e6f795494d4f

changegroup: add first logic to send file header This will allow us to later change how we filter needed file nodes
author Matt Mackall <mpm@selenic.com>
date Wed, 30 Mar 2011 17:50:27 -0500
parents 8ba08a16e4e0
children 0252abaafb8a
comparison
equal deleted inserted replaced
13808:58b86b9149f1 13809:e6f795494d4f
1552 raise util.Abort(_("empty or missing revlog for %s") % fname) 1552 raise util.Abort(_("empty or missing revlog for %s") % fname)
1553 # Toss out the filenodes that the recipient isn't really 1553 # Toss out the filenodes that the recipient isn't really
1554 # missing. 1554 # missing.
1555 missingfnodes = fnodes.pop(fname, {}) 1555 missingfnodes = fnodes.pop(fname, {})
1556 prune(filerevlog, missingfnodes) 1556 prune(filerevlog, missingfnodes)
1557 # If any filenodes are left, generate the group for them, 1557 first = True
1558 # otherwise don't bother. 1558
1559 if missingfnodes: 1559 def flookup(revlog, x):
1560 yield changegroup.chunkheader(len(fname)) 1560 # even though we print the same progress on
1561 yield fname 1561 # most loop iterations, put the progress call
1562 # Create a group generator and only pass in a changenode 1562 # here so that time estimates (if any) can be updated
1563 # lookup function as we need to collect no information 1563 self.ui.progress(
1564 # from filenodes. 1564 _('bundling'), idx, item=fname,
1565 def flookup(revlog, x): 1565 unit=_('files'), total=efiles)
1566 # even though we print the same progress on 1566 return missingfnodes[x]
1567 # most loop iterations, put the progress call 1567
1568 # here so that time estimates (if any) can be updated 1568 for chunk in filerevlog.group(missingfnodes, flookup):
1569 self.ui.progress( 1569 if first:
1570 _('bundling'), idx, item=fname, 1570 if chunk == changegroup.closechunk():
1571 unit=_('files'), total=efiles) 1571 break
1572 return missingfnodes[x] 1572 yield changegroup.chunkheader(len(fname))
1573 1573 yield fname
1574 for chunk in filerevlog.group(missingfnodes, flookup): 1574 first = False
1575 yield chunk 1575 yield chunk
1576 # Signal that no more groups are left. 1576 # Signal that no more groups are left.
1577 yield changegroup.closechunk() 1577 yield changegroup.closechunk()
1578 self.ui.progress(_('bundling'), None) 1578 self.ui.progress(_('bundling'), None)
1579 1579
1580 if csets: 1580 if csets:
1643 1643
1644 for idx, fname in enumerate(sorted(changedfiles)): 1644 for idx, fname in enumerate(sorted(changedfiles)):
1645 filerevlog = self.file(fname) 1645 filerevlog = self.file(fname)
1646 if not len(filerevlog): 1646 if not len(filerevlog):
1647 raise util.Abort(_("empty or missing revlog for %s") % fname) 1647 raise util.Abort(_("empty or missing revlog for %s") % fname)
1648 first = True
1648 nodeiter = gennodelst(filerevlog) 1649 nodeiter = gennodelst(filerevlog)
1649 nodeiter = list(nodeiter) 1650 def flookup(revlog, x):
1650 if nodeiter: 1651 self.ui.progress(
1651 yield changegroup.chunkheader(len(fname)) 1652 _('bundling'), idx, item=fname,
1652 yield fname 1653 total=efiles, unit=_('files'))
1653 def flookup(revlog, x): 1654 return cl.node(revlog.linkrev(revlog.rev(x)))
1654 self.ui.progress( 1655
1655 _('bundling'), idx, item=fname, 1656 for chunk in filerevlog.group(nodeiter, flookup):
1656 total=efiles, unit=_('files')) 1657 if first:
1657 return cl.node(revlog.linkrev(revlog.rev(x))) 1658 if chunk == changegroup.closechunk():
1658 1659 break
1659 for chunk in filerevlog.group(nodeiter, flookup): 1660 yield changegroup.chunkheader(len(fname))
1660 yield chunk 1661 yield fname
1662 first = False
1663 yield chunk
1661 self.ui.progress(_('bundling'), None) 1664 self.ui.progress(_('bundling'), None)
1662 1665
1663 yield changegroup.closechunk() 1666 yield changegroup.closechunk()
1664 1667
1665 if nodes: 1668 if nodes: