##// END OF EJS Templates
remoteui: move from cmdutil to hg
Matt Mackall -
r11273:d1908cb9 default
parent child Browse files
Show More
@@ -61,7 +61,7 b" def fetch(ui, repo, source='default', **"
61 61 raise util.Abort(_('multiple heads in this branch '
62 62 '(use "hg heads ." and "hg merge" to merge)'))
63 63
64 other = hg.repository(cmdutil.remoteui(repo, opts),
64 other = hg.repository(hg.remoteui(repo, opts),
65 65 ui.expandpath(source))
66 66 ui.status(_('pulling from %s\n') %
67 67 url.hidepassword(ui.expandpath(source)))
@@ -279,7 +279,7 b' def goutgoing(ui, repo, dest=None, **opt'
279 279 dest = ui.expandpath(dest or 'default-push', dest or 'default')
280 280 dest, branches = hg.parseurl(dest, opts.get('branch'))
281 281 revs, checkout = hg.addbranchrevs(repo, repo, branches, opts.get('rev'))
282 other = hg.repository(cmdutil.remoteui(ui, opts), dest)
282 other = hg.repository(hg.remoteui(ui, opts), dest)
283 283 if revs:
284 284 revs = [repo.lookup(rev) for rev in revs]
285 285 ui.status(_('comparing with %s\n') % url.hidepassword(dest))
@@ -306,7 +306,7 b' def gincoming(ui, repo, source="default"'
306 306
307 307 check_unsupported_flags(opts)
308 308 source, branches = hg.parseurl(ui.expandpath(source), opts.get('branch'))
309 other = hg.repository(cmdutil.remoteui(repo, opts), source)
309 other = hg.repository(hg.remoteui(repo, opts), source)
310 310 revs, checkout = hg.addbranchrevs(repo, other, branches, opts.get('rev'))
311 311 ui.status(_('comparing with %s\n') % url.hidepassword(source))
312 312 if revs:
@@ -1871,7 +1871,7 b' def clone(ui, source, dest=None, **opts)'
1871 1871 return url + '/.hg/patches'
1872 1872 if dest is None:
1873 1873 dest = hg.defaultdest(source)
1874 sr = hg.repository(cmdutil.remoteui(ui, opts), ui.expandpath(source))
1874 sr = hg.repository(hg.remoteui(ui, opts), ui.expandpath(source))
1875 1875 if opts['patches']:
1876 1876 patchespath = ui.expandpath(opts['patches'])
1877 1877 else:
@@ -242,7 +242,7 b' def patchbomb(ui, repo, *revs, **opts):'
242 242 revs, checkout = hg.addbranchrevs(repo, repo, branches, revs)
243 243 if revs:
244 244 revs = [repo.lookup(rev) for rev in revs]
245 other = hg.repository(cmdutil.remoteui(repo, opts), dest)
245 other = hg.repository(hg.remoteui(repo, opts), dest)
246 246 ui.status(_('comparing with %s\n') % dest)
247 247 o = repo.findoutgoing(other)
248 248 if not o:
@@ -39,7 +39,7 b' def relink(ui, repo, origin=None, **opts'
39 39 if not hasattr(util, 'samefile') or not hasattr(util, 'samedevice'):
40 40 raise util.Abort(_('hardlinks are not supported on this system'))
41 41 src = hg.repository(
42 cmdutil.remoteui(repo, opts),
42 hg.remoteui(repo, opts),
43 43 ui.expandpath(origin or 'default-relink', origin or 'default'))
44 44 if not src.local():
45 45 raise util.Abort('must specify local origin repository')
@@ -111,32 +111,6 b' def loglimit(opts):'
111 111 limit = None
112 112 return limit
113 113
114 def remoteui(src, opts):
115 'build a remote ui from ui or repo and opts'
116 if hasattr(src, 'baseui'): # looks like a repository
117 dst = src.baseui.copy() # drop repo-specific config
118 src = src.ui # copy target options from repo
119 else: # assume it's a global ui object
120 dst = src.copy() # keep all global options
121
122 # copy ssh-specific options
123 for o in 'ssh', 'remotecmd':
124 v = opts.get(o) or src.config('ui', o)
125 if v:
126 dst.setconfig("ui", o, v)
127
128 # copy bundle-specific options
129 r = src.config('bundle', 'mainreporoot')
130 if r:
131 dst.setconfig('bundle', 'mainreporoot', r)
132
133 # copy auth and http_proxy section settings
134 for sect in ('auth', 'http_proxy'):
135 for key, val in src.configitems(sect):
136 dst.setconfig(sect, key, val)
137
138 return dst
139
140 114 def revpair(repo, revs):
141 115 '''return pair of nodes, given list of revisions. second item can
142 116 be None, meaning use working dir.'''
@@ -594,7 +594,7 b' def bundle(ui, repo, fname, dest=None, *'
594 594 else:
595 595 dest = ui.expandpath(dest or 'default-push', dest or 'default')
596 596 dest, branches = hg.parseurl(dest, opts.get('branch'))
597 other = hg.repository(cmdutil.remoteui(repo, opts), dest)
597 other = hg.repository(hg.remoteui(repo, opts), dest)
598 598 revs, checkout = hg.addbranchrevs(repo, other, branches, revs)
599 599 o = repo.findoutgoing(other, force=opts.get('force'))
600 600
@@ -711,7 +711,7 b' def clone(ui, source, dest=None, **opts)'
711 711 if opts.get('noupdate') and opts.get('updaterev'):
712 712 raise util.Abort(_("cannot specify both --noupdate and --updaterev"))
713 713
714 r = hg.clone(cmdutil.remoteui(ui, opts), source, dest,
714 r = hg.clone(hg.remoteui(ui, opts), source, dest,
715 715 pull=opts.get('pull'),
716 716 stream=opts.get('uncompressed'),
717 717 rev=opts.get('rev'),
@@ -2071,7 +2071,7 b' def incoming(ui, repo, source="default",'
2071 2071 """
2072 2072 limit = cmdutil.loglimit(opts)
2073 2073 source, branches = hg.parseurl(ui.expandpath(source), opts.get('branch'))
2074 other = hg.repository(cmdutil.remoteui(repo, opts), source)
2074 other = hg.repository(hg.remoteui(repo, opts), source)
2075 2075 ui.status(_('comparing with %s\n') % url.hidepassword(source))
2076 2076 revs, checkout = hg.addbranchrevs(repo, other, branches, opts.get('rev'))
2077 2077 if revs:
@@ -2141,7 +2141,7 b' def init(ui, dest=".", **opts):'
2141 2141
2142 2142 Returns 0 on success.
2143 2143 """
2144 hg.repository(cmdutil.remoteui(ui, opts), dest, create=1)
2144 hg.repository(hg.remoteui(ui, opts), dest, create=1)
2145 2145
2146 2146 def locate(ui, repo, *pats, **opts):
2147 2147 """locate files matching specific patterns
@@ -2379,7 +2379,7 b' def outgoing(ui, repo, dest=None, **opts'
2379 2379 if revs:
2380 2380 revs = [repo.lookup(rev) for rev in revs]
2381 2381
2382 other = hg.repository(cmdutil.remoteui(repo, opts), dest)
2382 other = hg.repository(hg.remoteui(repo, opts), dest)
2383 2383 ui.status(_('comparing with %s\n') % url.hidepassword(dest))
2384 2384 o = repo.findoutgoing(other, force=opts.get('force'))
2385 2385 if not o:
@@ -2511,7 +2511,7 b' def pull(ui, repo, source="default", **o'
2511 2511 Returns 0 on success, 1 if an update had unresolved files.
2512 2512 """
2513 2513 source, branches = hg.parseurl(ui.expandpath(source), opts.get('branch'))
2514 other = hg.repository(cmdutil.remoteui(repo, opts), source)
2514 other = hg.repository(hg.remoteui(repo, opts), source)
2515 2515 ui.status(_('pulling from %s\n') % url.hidepassword(source))
2516 2516 revs, checkout = hg.addbranchrevs(repo, other, branches, opts.get('rev'))
2517 2517 if revs:
@@ -2559,7 +2559,7 b' def push(ui, repo, dest=None, **opts):'
2559 2559 dest = ui.expandpath(dest or 'default-push', dest or 'default')
2560 2560 dest, branches = hg.parseurl(dest, opts.get('branch'))
2561 2561 revs, checkout = hg.addbranchrevs(repo, repo, branches, opts.get('rev'))
2562 other = hg.repository(cmdutil.remoteui(repo, opts), dest)
2562 other = hg.repository(hg.remoteui(repo, opts), dest)
2563 2563 ui.status(_('pushing to %s\n') % url.hidepassword(dest))
2564 2564 if revs:
2565 2565 revs = [repo.lookup(rev) for rev in revs]
@@ -3306,7 +3306,7 b' def summary(ui, repo, **opts):'
3306 3306 if opts.get('remote'):
3307 3307 t = []
3308 3308 source, branches = hg.parseurl(ui.expandpath('default'))
3309 other = hg.repository(cmdutil.remoteui(repo, {}), source)
3309 other = hg.repository(hg.remoteui(repo, {}), source)
3310 3310 revs, checkout = hg.addbranchrevs(repo, other, branches, opts.get('rev'))
3311 3311 ui.debug('comparing with %s\n' % url.hidepassword(source))
3312 3312 repo.ui.pushbuffer()
@@ -3317,7 +3317,7 b' def summary(ui, repo, **opts):'
3317 3317
3318 3318 dest, branches = hg.parseurl(ui.expandpath('default-push', 'default'))
3319 3319 revs, checkout = hg.addbranchrevs(repo, repo, branches, None)
3320 other = hg.repository(cmdutil.remoteui(repo, {}), dest)
3320 other = hg.repository(hg.remoteui(repo, {}), dest)
3321 3321 ui.debug('comparing with %s\n' % url.hidepassword(dest))
3322 3322 repo.ui.pushbuffer()
3323 3323 o = repo.findoutgoing(other)
@@ -400,3 +400,29 b' def revert(repo, node, choose):'
400 400 def verify(repo):
401 401 """verify the consistency of a repository"""
402 402 return verifymod.verify(repo)
403
404 def remoteui(src, opts):
405 'build a remote ui from ui or repo and opts'
406 if hasattr(src, 'baseui'): # looks like a repository
407 dst = src.baseui.copy() # drop repo-specific config
408 src = src.ui # copy target options from repo
409 else: # assume it's a global ui object
410 dst = src.copy() # keep all global options
411
412 # copy ssh-specific options
413 for o in 'ssh', 'remotecmd':
414 v = opts.get(o) or src.config('ui', o)
415 if v:
416 dst.setconfig("ui", o, v)
417
418 # copy bundle-specific options
419 r = src.config('bundle', 'mainreporoot')
420 if r:
421 dst.setconfig('bundle', 'mainreporoot', r)
422
423 # copy auth and http_proxy section settings
424 for sect in ('auth', 'http_proxy'):
425 for key, val in src.configitems(sect):
426 dst.setconfig(sect, key, val)
427
428 return dst
General Comments 0
You need to be logged in to leave comments. Login now