mirror of
https://github.com/facebook/sapling.git
synced 2024-10-07 07:17:55 +03:00
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.
This commit is contained in:
parent
e39125d9f7
commit
4460ff7619
@ -1510,7 +1510,7 @@ class localrepository(repo.repository):
|
||||
for node in nodes:
|
||||
self.ui.debug("%s\n" % hex(node))
|
||||
|
||||
def changegroupsubset(self, bases, heads, source):
|
||||
def changegroupsubset(self, bases, heads, source, extranodes=None):
|
||||
"""This function generates a changegroup consisting of all the nodes
|
||||
that are descendents of any of the bases, and ancestors of any of
|
||||
the heads.
|
||||
@ -1520,7 +1520,15 @@ class localrepository(repo.repository):
|
||||
is non-trivial.
|
||||
|
||||
Another wrinkle is doing the reverse, figuring out which changeset in
|
||||
the changegroup a particular filenode or manifestnode belongs to."""
|
||||
the changegroup a particular filenode or manifestnode belongs to.
|
||||
|
||||
The caller can specify some nodes that must be included in the
|
||||
changegroup using the extranodes argument. It should be a dict
|
||||
where the keys are the filenames (or 1 for the manifest), and the
|
||||
values are lists of (node, linknode) tuples, where node is a wanted
|
||||
node and linknode is the changelog node that should be transmitted as
|
||||
the linkrev.
|
||||
"""
|
||||
|
||||
self.hook('preoutgoing', throw=True, source=source)
|
||||
|
||||
@ -1713,6 +1721,15 @@ class localrepository(repo.repository):
|
||||
return msngset[fnode]
|
||||
return lookup_filenode_link
|
||||
|
||||
# Add the nodes that were explicitly requested.
|
||||
def add_extra_nodes(name, nodes):
|
||||
if not extranodes or name not in extranodes:
|
||||
return
|
||||
|
||||
for node, linknode in extranodes[name]:
|
||||
if node not in nodes:
|
||||
nodes[node] = linknode
|
||||
|
||||
# Now that we have all theses utility functions to help out and
|
||||
# logically divide up the task, generate the group.
|
||||
def gengroup():
|
||||
@ -1728,6 +1745,7 @@ class localrepository(repo.repository):
|
||||
# The list of manifests has been collected by the generator
|
||||
# calling our functions back.
|
||||
prune_manifests()
|
||||
add_extra_nodes(1, msng_mnfst_set)
|
||||
msng_mnfst_lst = msng_mnfst_set.keys()
|
||||
# Sort the manifestnodes by revision number.
|
||||
msng_mnfst_lst.sort(cmp_by_rev_func(mnfst))
|
||||
@ -1743,6 +1761,13 @@ class localrepository(repo.repository):
|
||||
msng_mnfst_lst = None
|
||||
msng_mnfst_set.clear()
|
||||
|
||||
if extranodes:
|
||||
for fname in extranodes:
|
||||
if isinstance(fname, int):
|
||||
continue
|
||||
add_extra_nodes(fname,
|
||||
msng_filenode_set.setdefault(fname, {}))
|
||||
changedfiles[fname] = 1
|
||||
changedfiles = changedfiles.keys()
|
||||
changedfiles.sort()
|
||||
# Go through all our files in order sorted by name.
|
||||
|
Loading…
Reference in New Issue
Block a user