comparison mercurial/localrepo.py @ 5908:afa1e6122be7

changegroupsubset: accept list of per-revlog nodes to include This will allow strip to include in the temporary changegroup some extra file/manifest revisions that should be restored after the truncations. This code doesn't allow specification of changelog nodes since I won't need that right now, the code wouldn't be tested and it's probably possible to do something similar enough by using the bases/heads arguments.
author Alexis S. L. Carvalho <alexis@cecm.usp.br>
date Sat, 19 Jan 2008 18:01:16 -0200
parents afb7bdf11a61
children 7c2921a60035
comparison
equal deleted inserted replaced
5907:afb7bdf11a61 5908:afa1e6122be7
1508 if self.ui.debugflag: 1508 if self.ui.debugflag:
1509 self.ui.debug(_("List of changesets:\n")) 1509 self.ui.debug(_("List of changesets:\n"))
1510 for node in nodes: 1510 for node in nodes:
1511 self.ui.debug("%s\n" % hex(node)) 1511 self.ui.debug("%s\n" % hex(node))
1512 1512
1513 def changegroupsubset(self, bases, heads, source): 1513 def changegroupsubset(self, bases, heads, source, extranodes=None):
1514 """This function generates a changegroup consisting of all the nodes 1514 """This function generates a changegroup consisting of all the nodes
1515 that are descendents of any of the bases, and ancestors of any of 1515 that are descendents of any of the bases, and ancestors of any of
1516 the heads. 1516 the heads.
1517 1517
1518 It is fairly complex as determining which filenodes and which 1518 It is fairly complex as determining which filenodes and which
1519 manifest nodes need to be included for the changeset to be complete 1519 manifest nodes need to be included for the changeset to be complete
1520 is non-trivial. 1520 is non-trivial.
1521 1521
1522 Another wrinkle is doing the reverse, figuring out which changeset in 1522 Another wrinkle is doing the reverse, figuring out which changeset in
1523 the changegroup a particular filenode or manifestnode belongs to.""" 1523 the changegroup a particular filenode or manifestnode belongs to.
1524
1525 The caller can specify some nodes that must be included in the
1526 changegroup using the extranodes argument. It should be a dict
1527 where the keys are the filenames (or 1 for the manifest), and the
1528 values are lists of (node, linknode) tuples, where node is a wanted
1529 node and linknode is the changelog node that should be transmitted as
1530 the linkrev.
1531 """
1524 1532
1525 self.hook('preoutgoing', throw=True, source=source) 1533 self.hook('preoutgoing', throw=True, source=source)
1526 1534
1527 # Set up some initial variables 1535 # Set up some initial variables
1528 # Make it easy to refer to self.changelog 1536 # Make it easy to refer to self.changelog
1711 # Lookup the changenode the filenode belongs to. 1719 # Lookup the changenode the filenode belongs to.
1712 def lookup_filenode_link(fnode): 1720 def lookup_filenode_link(fnode):
1713 return msngset[fnode] 1721 return msngset[fnode]
1714 return lookup_filenode_link 1722 return lookup_filenode_link
1715 1723
1724 # Add the nodes that were explicitly requested.
1725 def add_extra_nodes(name, nodes):
1726 if not extranodes or name not in extranodes:
1727 return
1728
1729 for node, linknode in extranodes[name]:
1730 if node not in nodes:
1731 nodes[node] = linknode
1732
1716 # Now that we have all theses utility functions to help out and 1733 # Now that we have all theses utility functions to help out and
1717 # logically divide up the task, generate the group. 1734 # logically divide up the task, generate the group.
1718 def gengroup(): 1735 def gengroup():
1719 # The set of changed files starts empty. 1736 # The set of changed files starts empty.
1720 changedfiles = {} 1737 changedfiles = {}
1726 yield chnk 1743 yield chnk
1727 1744
1728 # The list of manifests has been collected by the generator 1745 # The list of manifests has been collected by the generator
1729 # calling our functions back. 1746 # calling our functions back.
1730 prune_manifests() 1747 prune_manifests()
1748 add_extra_nodes(1, msng_mnfst_set)
1731 msng_mnfst_lst = msng_mnfst_set.keys() 1749 msng_mnfst_lst = msng_mnfst_set.keys()
1732 # Sort the manifestnodes by revision number. 1750 # Sort the manifestnodes by revision number.
1733 msng_mnfst_lst.sort(cmp_by_rev_func(mnfst)) 1751 msng_mnfst_lst.sort(cmp_by_rev_func(mnfst))
1734 # Create a generator for the manifestnodes that calls our lookup 1752 # Create a generator for the manifestnodes that calls our lookup
1735 # and data collection functions back. 1753 # and data collection functions back.
1741 # These are no longer needed, dereference and toss the memory for 1759 # These are no longer needed, dereference and toss the memory for
1742 # them. 1760 # them.
1743 msng_mnfst_lst = None 1761 msng_mnfst_lst = None
1744 msng_mnfst_set.clear() 1762 msng_mnfst_set.clear()
1745 1763
1764 if extranodes:
1765 for fname in extranodes:
1766 if isinstance(fname, int):
1767 continue
1768 add_extra_nodes(fname,
1769 msng_filenode_set.setdefault(fname, {}))
1770 changedfiles[fname] = 1
1746 changedfiles = changedfiles.keys() 1771 changedfiles = changedfiles.keys()
1747 changedfiles.sort() 1772 changedfiles.sort()
1748 # Go through all our files in order sorted by name. 1773 # Go through all our files in order sorted by name.
1749 for fname in changedfiles: 1774 for fname in changedfiles:
1750 filerevlog = self.file(fname) 1775 filerevlog = self.file(fname)