##// END OF EJS Templates
localrepo: unify changegroup and changegroupsubset code paths a bit
Dirkjan Ochtman -
r10356:bc241494 default
parent child Browse files
Show More
@@ -54,6 +54,16 b' bundletypes = {'
54 "HG10GZ": ("HG10GZ", lambda: zlib.compressobj()),
54 "HG10GZ": ("HG10GZ", lambda: zlib.compressobj()),
55 }
55 }
56
56
57 def collector(cl, mmfs, files):
58 # Gather information about changeset nodes going out in a bundle.
59 # We want to gather manifests needed and filelogs affected.
60 def collect(node):
61 c = cl.read(node)
62 for fn in c[3]:
63 files.setdefault(fn, fn)
64 mmfs.setdefault(c[0], node)
65 return collect
66
57 # hgweb uses this list to communicate its preferred type
67 # hgweb uses this list to communicate its preferred type
58 bundlepriority = ['HG10GZ', 'HG10BZ', 'HG10UN']
68 bundlepriority = ['HG10GZ', 'HG10BZ', 'HG10UN']
59
69
@@ -1716,28 +1716,6 b' class localrepository(repo.repository):'
1716 for r in revlog.ancestors(*[revlog.rev(n) for n in hasset]):
1716 for r in revlog.ancestors(*[revlog.rev(n) for n in hasset]):
1717 msngset.pop(revlog.node(r), None)
1717 msngset.pop(revlog.node(r), None)
1718
1718
1719 # This is a function generating function used to set up an environment
1720 # for the inner function to execute in.
1721 def manifest_and_file_collector(changedfileset):
1722 # This is an information gathering function that gathers
1723 # information from each changeset node that goes out as part of
1724 # the changegroup. The information gathered is a list of which
1725 # manifest nodes are potentially required (the recipient may
1726 # already have them) and total list of all files which were
1727 # changed in any changeset in the changegroup.
1728 #
1729 # We also remember the first changenode we saw any manifest
1730 # referenced by so we can later determine which changenode 'owns'
1731 # the manifest.
1732 def collect_manifests_and_files(clnode):
1733 c = cl.read(clnode)
1734 for f in c[3]:
1735 # This is to make sure we only have one instance of each
1736 # filename string for each filename.
1737 changedfileset.setdefault(f, f)
1738 msng_mnfst_set.setdefault(c[0], clnode)
1739 return collect_manifests_and_files
1740
1741 # Figure out which manifest nodes (of the ones we think might be part
1719 # Figure out which manifest nodes (of the ones we think might be part
1742 # of the changegroup) the recipient must know about and remove them
1720 # of the changegroup) the recipient must know about and remove them
1743 # from the changegroup.
1721 # from the changegroup.
@@ -1838,10 +1816,11 b' class localrepository(repo.repository):'
1838 def gengroup():
1816 def gengroup():
1839 # The set of changed files starts empty.
1817 # The set of changed files starts empty.
1840 changedfiles = {}
1818 changedfiles = {}
1819 collect = changegroup.collector(cl, msng_mnfst_set, changedfiles)
1820
1841 # Create a changenode group generator that will call our functions
1821 # Create a changenode group generator that will call our functions
1842 # back to lookup the owning changenode and collect information.
1822 # back to lookup the owning changenode and collect information.
1843 group = cl.group(msng_cl_lst, identity,
1823 group = cl.group(msng_cl_lst, identity, collect)
1844 manifest_and_file_collector(changedfiles))
1845 for chnk in group:
1824 for chnk in group:
1846 yield chnk
1825 yield chnk
1847
1826
@@ -1936,12 +1915,6 b' class localrepository(repo.repository):'
1936 if log.linkrev(r) in revset:
1915 if log.linkrev(r) in revset:
1937 yield log.node(r)
1916 yield log.node(r)
1938
1917
1939 def changed_file_collector(changedfileset):
1940 def collect_changed_files(clnode):
1941 c = cl.read(clnode)
1942 changedfileset.update(c[3])
1943 return collect_changed_files
1944
1945 def lookuprevlink_func(revlog):
1918 def lookuprevlink_func(revlog):
1946 def lookuprevlink(n):
1919 def lookuprevlink(n):
1947 return cl.node(revlog.linkrev(revlog.rev(n)))
1920 return cl.node(revlog.linkrev(revlog.rev(n)))
@@ -1950,10 +1923,11 b' class localrepository(repo.repository):'
1950 def gengroup():
1923 def gengroup():
1951 '''yield a sequence of changegroup chunks (strings)'''
1924 '''yield a sequence of changegroup chunks (strings)'''
1952 # construct a list of all changed files
1925 # construct a list of all changed files
1953 changedfiles = set()
1926 changedfiles = {}
1927 mmfs = {}
1928 collect = changegroup.collector(cl, mmfs, changedfiles)
1954
1929
1955 for chnk in cl.group(nodes, identity,
1930 for chnk in cl.group(nodes, identity, collect):
1956 changed_file_collector(changedfiles)):
1957 yield chnk
1931 yield chnk
1958
1932
1959 mnfst = self.manifest
1933 mnfst = self.manifest
General Comments 0
You need to be logged in to leave comments. Login now