Mercurial > hg
comparison mercurial/localrepo.py @ 13787:5333c87f6048
changegroup: fold filenode collector into mlookup
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Mon, 28 Mar 2011 11:18:56 -0500 |
parents | 4ed718f909e5 |
children | 307c72686eb0 |
comparison
equal
deleted
inserted
replaced
13786:4ed718f909e5 | 13787:5333c87f6048 |
---|---|
1489 | 1489 |
1490 # slow path | 1490 # slow path |
1491 self.hook('preoutgoing', throw=True, source=source) | 1491 self.hook('preoutgoing', throw=True, source=source) |
1492 self.changegroupinfo(csets, source) | 1492 self.changegroupinfo(csets, source) |
1493 | 1493 |
1494 # A function generating function that sets up the initial environment | |
1495 # the inner function. | |
1496 def filenode_collector(changedfiles): | |
1497 # This gathers information from each manifestnode included in the | |
1498 # changegroup about which filenodes the manifest node references | |
1499 # so we can include those in the changegroup too. | |
1500 # | |
1501 # It also remembers which changenode each filenode belongs to. It | |
1502 # does this by assuming the a filenode belongs to the changenode | |
1503 # the first manifest that references it belongs to. | |
1504 def collect(mnode): | |
1505 r = mf.rev(mnode) | |
1506 clnode = mfs[mnode] | |
1507 mdata = mf.readfast(mnode) | |
1508 for f in changedfiles: | |
1509 if f in mdata: | |
1510 fnodes.setdefault(f, {}).setdefault(mdata[f], clnode) | |
1511 | |
1512 return collect | |
1513 | |
1514 # If we determine that a particular file or manifest node must be a | 1494 # If we determine that a particular file or manifest node must be a |
1515 # node that the recipient of the changegroup will already have, we can | 1495 # node that the recipient of the changegroup will already have, we can |
1516 # also assume the recipient will have all the parents. This function | 1496 # also assume the recipient will have all the parents. This function |
1517 # prunes them from the set of missing nodes. | 1497 # prunes them from the set of missing nodes. |
1518 def prune(revlog, missingnodes): | 1498 def prune(revlog, missingnodes): |
1548 self.ui.progress(_('bundling'), None) | 1528 self.ui.progress(_('bundling'), None) |
1549 | 1529 |
1550 prune(mf, mfs) | 1530 prune(mf, mfs) |
1551 # Create a generator for the manifestnodes that calls our lookup | 1531 # Create a generator for the manifestnodes that calls our lookup |
1552 # and data collection functions back. | 1532 # and data collection functions back. |
1553 fcollect = filenode_collector(changedfiles) | |
1554 count = [0] | 1533 count = [0] |
1555 def mlookup(revlog, x): | 1534 def mlookup(revlog, x): |
1556 fcollect(x) | 1535 clnode = mfs[x] |
1536 mdata = mf.readfast(x) | |
1537 for f in changedfiles: | |
1538 if f in mdata: | |
1539 fnodes.setdefault(f, {}).setdefault(mdata[f], clnode) | |
1557 count[0] += 1 | 1540 count[0] += 1 |
1558 self.ui.progress(_('bundling'), count[0], | 1541 self.ui.progress(_('bundling'), count[0], |
1559 unit=_('manifests'), total=changecount) | 1542 unit=_('manifests'), total=changecount) |
1560 return mfs[x] | 1543 return mfs[x] |
1561 | 1544 |