##// END OF EJS Templates
bundle-ng: add bundlecaps argument to getbundle() command
Benoit Boissinot -
r19201:309c439c default
parent child Browse files
Show More
@@ -225,8 +225,11 b' def readbundle(fh, fname):'
225 225
226 226 class bundle10(object):
227 227 deltaheader = _BUNDLE10_DELTA_HEADER
228 def __init__(self):
229 pass
228 def __init__(self, bundlecaps=None):
229 # Set of capabilities we can use to build the bundle.
230 if bundlecaps is None:
231 bundlecaps = set()
232 self._bundlecaps = bundlecaps
230 233 def start(self, lookup):
231 234 self._lookup = lookup
232 235 def close(self):
@@ -1096,13 +1096,16 b' def bundle(ui, repo, fname, dest=None, *'
1096 1096 base = ['null']
1097 1097 else:
1098 1098 base = scmutil.revrange(repo, opts.get('base'))
1099 # TODO: get desired bundlecaps from command line.
1100 bundlecaps = None
1099 1101 if base:
1100 1102 if dest:
1101 1103 raise util.Abort(_("--base is incompatible with specifying "
1102 1104 "a destination"))
1103 1105 common = [repo.lookup(rev) for rev in base]
1104 1106 heads = revs and map(repo.lookup, revs) or revs
1105 cg = repo.getbundle('bundle', heads=heads, common=common)
1107 cg = repo.getbundle('bundle', heads=heads, common=common,
1108 bundlecaps=bundlecaps)
1106 1109 outgoing = None
1107 1110 else:
1108 1111 dest = ui.expandpath(dest or 'default-push', dest or 'default')
@@ -1114,7 +1117,7 b' def bundle(ui, repo, fname, dest=None, *'
1114 1117 onlyheads=heads,
1115 1118 force=opts.get('force'),
1116 1119 portable=True)
1117 cg = repo.getlocalbundle('bundle', outgoing)
1120 cg = repo.getlocalbundle('bundle', outgoing, bundlecaps)
1118 1121 if not cg:
1119 1122 scmutil.nochangesfound(ui, repo, outgoing and outgoing.excluded)
1120 1123 return 1
@@ -1913,6 +1916,8 b' def debuggetbundle(ui, repopath, bundlep'
1913 1916 args['common'] = [bin(s) for s in common]
1914 1917 if head:
1915 1918 args['heads'] = [bin(s) for s in head]
1919 # TODO: get desired bundlecaps from command line.
1920 args['bundlecaps'] = None
1916 1921 bundle = repo.getbundle('debug', **args)
1917 1922
1918 1923 bundletype = opts.get('type', 'bzip2').lower()
@@ -99,8 +99,9 b' class localpeer(peer.peerrepository):'
99 99 def known(self, nodes):
100 100 return self._repo.known(nodes)
101 101
102 def getbundle(self, source, heads=None, common=None):
103 return self._repo.getbundle(source, heads=heads, common=common)
102 def getbundle(self, source, heads=None, common=None, bundlecaps=None):
103 return self._repo.getbundle(source, heads=heads, common=common,
104 bundlecaps=None)
104 105
105 106 # TODO We might want to move the next two calls into legacypeer and add
106 107 # unbundle instead.
@@ -1674,6 +1675,7 b' class localrepository(object):'
1674 1675 heads = rheads
1675 1676
1676 1677 if remote.capable('getbundle'):
1678 # TODO: get bundlecaps from remote
1677 1679 cg = remote.getbundle('pull', common=common,
1678 1680 heads=heads or rheads)
1679 1681 elif heads is None:
@@ -1836,15 +1838,17 b' class localrepository(object):'
1836 1838 remoteheads, newbranch,
1837 1839 bool(inc))
1838 1840
1841 # TODO: get bundlecaps from remote
1842 bundlecaps = None
1839 1843 # create a changegroup from local
1840 1844 if revs is None and not outgoing.excluded:
1841 1845 # push everything,
1842 1846 # use the fast path, no race possible on push
1843 bundler = changegroup.bundle10()
1847 bundler = changegroup.bundle10(bundlecaps)
1844 1848 cg = self._changegroup(outgoing.missing, bundler,
1845 1849 'push')
1846 1850 else:
1847 cg = self.getlocalbundle('push', outgoing)
1851 cg = self.getlocalbundle('push', outgoing, bundlecaps)
1848 1852
1849 1853 # apply changegroup to remote
1850 1854 if unbundle:
@@ -1991,21 +1995,21 b' class localrepository(object):'
1991 1995 bundler = changegroup.bundle10()
1992 1996 return self._changegroupsubset(common, csets, heads, bundler, source)
1993 1997
1994 def getlocalbundle(self, source, outgoing):
1998 def getlocalbundle(self, source, outgoing, bundlecaps=None):
1995 1999 """Like getbundle, but taking a discovery.outgoing as an argument.
1996 2000
1997 2001 This is only implemented for local repos and reuses potentially
1998 2002 precomputed sets in outgoing."""
1999 2003 if not outgoing.missing:
2000 2004 return None
2001 bundler = changegroup.bundle10()
2005 bundler = changegroup.bundle10(bundlecaps)
2002 2006 return self._changegroupsubset(outgoing.common,
2003 2007 outgoing.missing,
2004 2008 outgoing.missingheads,
2005 2009 bundler,
2006 2010 source)
2007 2011
2008 def getbundle(self, source, heads=None, common=None):
2012 def getbundle(self, source, heads=None, common=None, bundlecaps=None):
2009 2013 """Like changegroupsubset, but returns the set difference between the
2010 2014 ancestors of heads and the ancestors common.
2011 2015
@@ -2023,7 +2027,8 b' class localrepository(object):'
2023 2027 if not heads:
2024 2028 heads = cl.heads()
2025 2029 return self.getlocalbundle(source,
2026 discovery.outgoing(cl, common, heads))
2030 discovery.outgoing(cl, common, heads),
2031 bundlecaps=bundlecaps)
2027 2032
2028 2033 @unfilteredmethod
2029 2034 def _changegroupsubset(self, commonrevs, csets, heads, bundler, source):
@@ -281,13 +281,15 b' class wirepeer(peer.peerrepository):'
281 281 bases=bases, heads=heads)
282 282 return changegroupmod.unbundle10(self._decompress(f), 'UN')
283 283
284 def getbundle(self, source, heads=None, common=None):
284 def getbundle(self, source, heads=None, common=None, bundlecaps=None):
285 285 self.requirecap('getbundle', _('look up remote changes'))
286 286 opts = {}
287 287 if heads is not None:
288 288 opts['heads'] = encodelist(heads)
289 289 if common is not None:
290 290 opts['common'] = encodelist(common)
291 if bundlecaps is not None:
292 opts['bundlecaps'] = ','.join(bundlecaps)
291 293 f = self._callstream("getbundle", **opts)
292 294 return changegroupmod.unbundle10(self._decompress(f), 'UN')
293 295
@@ -449,9 +451,12 b' def debugwireargs(repo, proto, one, two,'
449 451 return repo.debugwireargs(one, two, **opts)
450 452
451 453 def getbundle(repo, proto, others):
452 opts = options('getbundle', ['heads', 'common'], others)
454 opts = options('getbundle', ['heads', 'common', 'bundlecaps'], others)
453 455 for k, v in opts.iteritems():
454 opts[k] = decodelist(v)
456 if k in ('heads', 'common'):
457 opts[k] = decodelist(v)
458 elif k == 'bundlecaps':
459 opts[k] = set(v.split(','))
455 460 cg = repo.getbundle('serve', **opts)
456 461 return streamres(proto.groupchunks(cg))
457 462
General Comments 0
You need to be logged in to leave comments. Login now