mercurial/localrepo.py
changeset 13810 0252abaafb8a
parent 13809 e6f795494d4f
child 13811 65c1d309ab91
equal deleted inserted replaced
13809:e6f795494d4f 13810:0252abaafb8a
  1486 
  1486 
  1487         # slow path
  1487         # slow path
  1488         self.hook('preoutgoing', throw=True, source=source)
  1488         self.hook('preoutgoing', throw=True, source=source)
  1489         self.changegroupinfo(csets, source)
  1489         self.changegroupinfo(csets, source)
  1490 
  1490 
  1491         # If we determine that a particular file or manifest node must be a
  1491         # filter any nodes that claim to be part of the known set
  1492         # node that the recipient of the changegroup will already have, we can
  1492         def prune(revlog, missing):
  1493         # also assume the recipient will have all the parents.  This function
  1493             for n in missing:
  1494         # prunes them from the set of missing nodes.
  1494                 if revlog.linkrev(revlog.rev(n)) not in commonrevs:
  1495         def prune(revlog, missingnodes):
  1495                     yield n
  1496             # drop any nodes that claim to be part of a cset in commonrevs
       
  1497             drop = set()
       
  1498             for n in missingnodes:
       
  1499                 if revlog.linkrev(revlog.rev(n)) in commonrevs:
       
  1500                     drop.add(n)
       
  1501             for n in drop:
       
  1502                 missingnodes.pop(n, None)
       
  1503 
  1496 
  1504         # Now that we have all theses utility functions to help out and
  1497         # Now that we have all theses utility functions to help out and
  1505         # logically divide up the task, generate the group.
  1498         # logically divide up the task, generate the group.
  1506         def gengroup():
  1499         def gengroup():
  1507             # The set of changed files starts empty.
  1500             # The set of changed files starts empty.
  1522                 yield chunk
  1515                 yield chunk
  1523             changecount = count[0]
  1516             changecount = count[0]
  1524             efiles = len(changedfiles)
  1517             efiles = len(changedfiles)
  1525             self.ui.progress(_('bundling'), None)
  1518             self.ui.progress(_('bundling'), None)
  1526 
  1519 
  1527             prune(mf, mfs)
       
  1528             # Create a generator for the manifestnodes that calls our lookup
  1520             # Create a generator for the manifestnodes that calls our lookup
  1529             # and data collection functions back.
  1521             # and data collection functions back.
  1530             count = [0]
  1522             count = [0]
  1531             def mlookup(revlog, x):
  1523             def mlookup(revlog, x):
  1532                 clnode = mfs[x]
  1524                 clnode = mfs[x]
  1537                 count[0] += 1
  1529                 count[0] += 1
  1538                 self.ui.progress(_('bundling'), count[0],
  1530                 self.ui.progress(_('bundling'), count[0],
  1539                                  unit=_('manifests'), total=changecount)
  1531                                  unit=_('manifests'), total=changecount)
  1540                 return mfs[x]
  1532                 return mfs[x]
  1541 
  1533 
  1542             for chunk in mf.group(mfs, mlookup):
  1534             for chunk in mf.group(prune(mf, mfs), mlookup):
  1543                 yield chunk
  1535                 yield chunk
  1544             self.ui.progress(_('bundling'), None)
  1536             self.ui.progress(_('bundling'), None)
  1545 
  1537 
  1546             mfs.clear()
  1538             mfs.clear()
  1547 
  1539 
  1551                 if not len(filerevlog):
  1543                 if not len(filerevlog):
  1552                     raise util.Abort(_("empty or missing revlog for %s") % fname)
  1544                     raise util.Abort(_("empty or missing revlog for %s") % fname)
  1553                 # Toss out the filenodes that the recipient isn't really
  1545                 # Toss out the filenodes that the recipient isn't really
  1554                 # missing.
  1546                 # missing.
  1555                 missingfnodes = fnodes.pop(fname, {})
  1547                 missingfnodes = fnodes.pop(fname, {})
  1556                 prune(filerevlog, missingfnodes)
       
  1557                 first = True
  1548                 first = True
  1558 
  1549 
  1559                 def flookup(revlog, x):
  1550                 def flookup(revlog, x):
  1560                     # even though we print the same progress on
  1551                     # even though we print the same progress on
  1561                     # most loop iterations, put the progress call
  1552                     # most loop iterations, put the progress call
  1563                     self.ui.progress(
  1554                     self.ui.progress(
  1564                         _('bundling'), idx, item=fname,
  1555                         _('bundling'), idx, item=fname,
  1565                         unit=_('files'), total=efiles)
  1556                         unit=_('files'), total=efiles)
  1566                     return missingfnodes[x]
  1557                     return missingfnodes[x]
  1567 
  1558 
  1568                 for chunk in filerevlog.group(missingfnodes, flookup):
  1559                 for chunk in filerevlog.group(prune(filerevlog, missingfnodes),
       
  1560                                               flookup):
  1569                     if first:
  1561                     if first:
  1570                         if chunk == changegroup.closechunk():
  1562                         if chunk == changegroup.closechunk():
  1571                             break
  1563                             break
  1572                         yield changegroup.chunkheader(len(fname))
  1564                         yield changegroup.chunkheader(len(fname))
  1573                         yield fname
  1565                         yield fname