##// END OF EJS Templates
changegroupsubset: more minor cleanups...
Matt Mackall -
r13707:296e7874 default
parent child Browse files
Show More
@@ -1444,19 +1444,13 b' class localrepository(repo.repository):'
1444 mfs = {} # needed manifests
1444 mfs = {} # needed manifests
1445 fnodes = {} # needed file nodes
1445 fnodes = {} # needed file nodes
1446
1446
1447 # Compute the list of changesets in this changegroup.
1448 # Some bases may turn out to be superfluous, and some heads may be
1449 # too. nodesbetween will return the minimal set of bases and heads
1450 # necessary to re-create the changegroup.
1451 if not bases:
1447 if not bases:
1452 bases = [nullid]
1448 bases = [nullid]
1453 csets, bases, heads = cl.nodesbetween(bases, heads)
1449 csets, bases, heads = cl.nodesbetween(bases, heads)
1454
1450
1455 # can we go through the fast path ?
1451 # can we go through the fast path ?
1456 heads.sort()
1452 heads.sort()
1457 allheads = self.heads()
1453 if heads == sorted(self.heads()):
1458 allheads.sort()
1459 if heads == allheads:
1460 return self._changegroup(csets, source)
1454 return self._changegroup(csets, source)
1461
1455
1462 # slow path
1456 # slow path
@@ -1466,11 +1460,6 b' class localrepository(repo.repository):'
1466 # We assume that all ancestors of bases are known
1460 # We assume that all ancestors of bases are known
1467 commonrevs = set(cl.ancestors(*[cl.rev(n) for n in bases]))
1461 commonrevs = set(cl.ancestors(*[cl.rev(n) for n in bases]))
1468
1462
1469 # A changeset always belongs to itself, so the changenode lookup
1470 # function for a changenode is identity.
1471 def identity(x):
1472 return x
1473
1474 # A function generating function that sets up the initial environment
1463 # A function generating function that sets up the initial environment
1475 # the inner function.
1464 # the inner function.
1476 def filenode_collector(changedfiles):
1465 def filenode_collector(changedfiles):
@@ -1481,19 +1470,19 b' class localrepository(repo.repository):'
1481 # It also remembers which changenode each filenode belongs to. It
1470 # It also remembers which changenode each filenode belongs to. It
1482 # does this by assuming the a filenode belongs to the changenode
1471 # does this by assuming the a filenode belongs to the changenode
1483 # the first manifest that references it belongs to.
1472 # the first manifest that references it belongs to.
1484 def collect(mannode):
1473 def collect(mnode):
1485 r = mf.rev(mannode)
1474 r = mf.rev(mnode)
1486 if mf.deltaparent(r) in mf.parentrevs(r):
1475 if mf.deltaparent(r) in mf.parentrevs(r):
1487 # If the previous rev is one of the parents,
1476 # If the previous rev is one of the parents,
1488 # we only need to see a diff.
1477 # we only need to see a diff.
1489 deltamf = mf.readdelta(mannode)
1478 deltamf = mf.readdelta(mnode)
1490 # For each line in the delta
1479 # For each line in the delta
1491 for f, fnode in deltamf.iteritems():
1480 for f, fnode in deltamf.iteritems():
1492 # And if the file is in the list of files we care
1481 # And if the file is in the list of files we care
1493 # about.
1482 # about.
1494 if f in changedfiles:
1483 if f in changedfiles:
1495 # Get the changenode this manifest belongs to
1484 # Get the changenode this manifest belongs to
1496 clnode = mfs[mannode]
1485 clnode = mfs[mnode]
1497 # Create the set of filenodes for the file if
1486 # Create the set of filenodes for the file if
1498 # there isn't one already.
1487 # there isn't one already.
1499 ndset = fnodes.setdefault(f, {})
1488 ndset = fnodes.setdefault(f, {})
@@ -1502,14 +1491,14 b' class localrepository(repo.repository):'
1502 ndset.setdefault(fnode, clnode)
1491 ndset.setdefault(fnode, clnode)
1503 else:
1492 else:
1504 # Otherwise we need a full manifest.
1493 # Otherwise we need a full manifest.
1505 m = mf.read(mannode)
1494 m = mf.read(mnode)
1506 # For every file in we care about.
1495 # For every file in we care about.
1507 for f in changedfiles:
1496 for f in changedfiles:
1508 fnode = m.get(f, None)
1497 fnode = m.get(f, None)
1509 # If it's in the manifest
1498 # If it's in the manifest
1510 if fnode is not None:
1499 if fnode is not None:
1511 # See comments above.
1500 # See comments above.
1512 clnode = mfs[mannode]
1501 clnode = mfs[mnode]
1513 ndset = fnodes.setdefault(f, {})
1502 ndset = fnodes.setdefault(f, {})
1514 ndset.setdefault(fnode, clnode)
1503 ndset.setdefault(fnode, clnode)
1515 return collect
1504 return collect
@@ -1541,7 +1530,7 b' class localrepository(repo.repository):'
1541
1530
1542 # Create a changenode group generator that will call our functions
1531 # Create a changenode group generator that will call our functions
1543 # back to lookup the owning changenode and collect information.
1532 # back to lookup the owning changenode and collect information.
1544 group = cl.group(csets, identity, collect)
1533 group = cl.group(csets, lambda x: x, collect)
1545 for cnt, chnk in enumerate(group):
1534 for cnt, chnk in enumerate(group):
1546 yield chnk
1535 yield chnk
1547 # revlog.group yields three entries per node, so
1536 # revlog.group yields three entries per node, so
@@ -1586,14 +1575,12 b' class localrepository(repo.repository):'
1586 if missingfnodes:
1575 if missingfnodes:
1587 yield changegroup.chunkheader(len(fname))
1576 yield changegroup.chunkheader(len(fname))
1588 yield fname
1577 yield fname
1589 # Sort the filenodes by their revision # (topological order)
1590 nodeiter = list(missingfnodes)
1591 nodeiter.sort(key=filerevlog.rev)
1592 # Create a group generator and only pass in a changenode
1578 # Create a group generator and only pass in a changenode
1593 # lookup function as we need to collect no information
1579 # lookup function as we need to collect no information
1594 # from filenodes.
1580 # from filenodes.
1595 group = filerevlog.group(nodeiter,
1581 group = filerevlog.group(
1596 lambda fnode: missingfnodes[fnode])
1582 sorted(missingfnodes, key=filerevlog.rev),
1583 lambda fnode: missingfnodes[fnode])
1597 for chnk in group:
1584 for chnk in group:
1598 # even though we print the same progress on
1585 # even though we print the same progress on
1599 # most loop iterations, put the progress call
1586 # most loop iterations, put the progress call
General Comments 0
You need to be logged in to leave comments. Login now