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