comparison mercurial/localrepo.py @ 19199:d6d0f1ed8ebb

bundle-ng: move bundler creation up in the stack Create a simple start() method to pass the lookup function until bundler becomes smarter and gets a repo object. Since we now create the bundler for the whole lifetime, we need to pass it down to revlog methods.
author Benoit Boissinot <benoit.boissinot@ens-lyon.org>
date Fri, 10 May 2013 20:37:41 +0200
parents e579687cb5d8
children 4cfdec944edf
comparison
equal deleted inserted replaced
19196:0fbcabe523bc 19199:d6d0f1ed8ebb
1838 1838
1839 # create a changegroup from local 1839 # create a changegroup from local
1840 if revs is None and not outgoing.excluded: 1840 if revs is None and not outgoing.excluded:
1841 # push everything, 1841 # push everything,
1842 # use the fast path, no race possible on push 1842 # use the fast path, no race possible on push
1843 cg = self._changegroup(outgoing.missing, 'push') 1843 bundler = changegroup.bundle10()
1844 cg = self._changegroup(outgoing.missing, bundler,
1845 'push')
1844 else: 1846 else:
1845 cg = self.getlocalbundle('push', outgoing) 1847 cg = self.getlocalbundle('push', outgoing)
1846 1848
1847 # apply changegroup to remote 1849 # apply changegroup to remote
1848 if unbundle: 1850 if unbundle:
1984 if not bases: 1986 if not bases:
1985 bases = [nullid] 1987 bases = [nullid]
1986 csets, bases, heads = cl.nodesbetween(bases, heads) 1988 csets, bases, heads = cl.nodesbetween(bases, heads)
1987 # We assume that all ancestors of bases are known 1989 # We assume that all ancestors of bases are known
1988 common = cl.ancestors([cl.rev(n) for n in bases]) 1990 common = cl.ancestors([cl.rev(n) for n in bases])
1989 return self._changegroupsubset(common, csets, heads, source) 1991 bundler = changegroup.bundle10()
1992 return self._changegroupsubset(common, csets, heads, bundler, source)
1990 1993
1991 def getlocalbundle(self, source, outgoing): 1994 def getlocalbundle(self, source, outgoing):
1992 """Like getbundle, but taking a discovery.outgoing as an argument. 1995 """Like getbundle, but taking a discovery.outgoing as an argument.
1993 1996
1994 This is only implemented for local repos and reuses potentially 1997 This is only implemented for local repos and reuses potentially
1995 precomputed sets in outgoing.""" 1998 precomputed sets in outgoing."""
1996 if not outgoing.missing: 1999 if not outgoing.missing:
1997 return None 2000 return None
2001 bundler = changegroup.bundle10()
1998 return self._changegroupsubset(outgoing.common, 2002 return self._changegroupsubset(outgoing.common,
1999 outgoing.missing, 2003 outgoing.missing,
2000 outgoing.missingheads, 2004 outgoing.missingheads,
2005 bundler,
2001 source) 2006 source)
2002 2007
2003 def getbundle(self, source, heads=None, common=None): 2008 def getbundle(self, source, heads=None, common=None):
2004 """Like changegroupsubset, but returns the set difference between the 2009 """Like changegroupsubset, but returns the set difference between the
2005 ancestors of heads and the ancestors common. 2010 ancestors of heads and the ancestors common.
2019 heads = cl.heads() 2024 heads = cl.heads()
2020 return self.getlocalbundle(source, 2025 return self.getlocalbundle(source,
2021 discovery.outgoing(cl, common, heads)) 2026 discovery.outgoing(cl, common, heads))
2022 2027
2023 @unfilteredmethod 2028 @unfilteredmethod
2024 def _changegroupsubset(self, commonrevs, csets, heads, source): 2029 def _changegroupsubset(self, commonrevs, csets, heads, bundler, source):
2025 2030
2026 cl = self.changelog 2031 cl = self.changelog
2027 mf = self.manifest 2032 mf = self.manifest
2028 mfs = {} # needed manifests 2033 mfs = {} # needed manifests
2029 fnodes = {} # needed file nodes 2034 fnodes = {} # needed file nodes
2032 count = [0, 0] 2037 count = [0, 0]
2033 2038
2034 # can we go through the fast path ? 2039 # can we go through the fast path ?
2035 heads.sort() 2040 heads.sort()
2036 if heads == sorted(self.heads()): 2041 if heads == sorted(self.heads()):
2037 return self._changegroup(csets, source) 2042 return self._changegroup(csets, bundler, source)
2038 2043
2039 # slow path 2044 # slow path
2040 self.hook('preoutgoing', throw=True, source=source) 2045 self.hook('preoutgoing', throw=True, source=source)
2041 self.changegroupinfo(csets, source) 2046 self.changegroupinfo(csets, source)
2042 2047
2074 else: 2079 else:
2075 progress(_bundling, count[0], item=fstate[0], 2080 progress(_bundling, count[0], item=fstate[0],
2076 unit=_files, total=count[1]) 2081 unit=_files, total=count[1])
2077 return fstate[1][x] 2082 return fstate[1][x]
2078 2083
2079 bundler = changegroup.bundle10(lookup) 2084 bundler.start(lookup)
2080 reorder = self.ui.config('bundle', 'reorder', 'auto') 2085 reorder = self.ui.config('bundle', 'reorder', 'auto')
2081 if reorder == 'auto': 2086 if reorder == 'auto':
2082 reorder = None 2087 reorder = None
2083 else: 2088 else:
2084 reorder = util.parsebool(reorder) 2089 reorder = util.parsebool(reorder)
2131 def changegroup(self, basenodes, source): 2136 def changegroup(self, basenodes, source):
2132 # to avoid a race we use changegroupsubset() (issue1320) 2137 # to avoid a race we use changegroupsubset() (issue1320)
2133 return self.changegroupsubset(basenodes, self.heads(), source) 2138 return self.changegroupsubset(basenodes, self.heads(), source)
2134 2139
2135 @unfilteredmethod 2140 @unfilteredmethod
2136 def _changegroup(self, nodes, source): 2141 def _changegroup(self, nodes, bundler, source):
2137 """Compute the changegroup of all nodes that we have that a recipient 2142 """Compute the changegroup of all nodes that we have that a recipient
2138 doesn't. Return a chunkbuffer object whose read() method will return 2143 doesn't. Return a chunkbuffer object whose read() method will return
2139 successive changegroup chunks. 2144 successive changegroup chunks.
2140 2145
2141 This is much easier than the previous function as we can assume that 2146 This is much easier than the previous function as we can assume that
2182 else: 2187 else:
2183 progress(_bundling, count[0], item=fstate[0], 2188 progress(_bundling, count[0], item=fstate[0],
2184 total=count[1], unit=_files) 2189 total=count[1], unit=_files)
2185 return cl.node(revlog.linkrev(revlog.rev(x))) 2190 return cl.node(revlog.linkrev(revlog.rev(x)))
2186 2191
2187 bundler = changegroup.bundle10(lookup) 2192 bundler.start(lookup)
2188 reorder = self.ui.config('bundle', 'reorder', 'auto') 2193 reorder = self.ui.config('bundle', 'reorder', 'auto')
2189 if reorder == 'auto': 2194 if reorder == 'auto':
2190 reorder = None 2195 reorder = None
2191 else: 2196 else:
2192 reorder = util.parsebool(reorder) 2197 reorder = util.parsebool(reorder)