Show More
@@ -61,7 +61,7 b" def fetch(ui, repo, source='default', **" | |||||
61 | raise util.Abort(_('multiple heads in this branch ' |
|
61 | raise util.Abort(_('multiple heads in this branch ' | |
62 | '(use "hg heads ." and "hg merge" to merge)')) |
|
62 | '(use "hg heads ." and "hg merge" to merge)')) | |
63 |
|
63 | |||
64 |
other = hg.repository( |
|
64 | other = hg.repository(hg.remoteui(repo, opts), | |
65 | ui.expandpath(source)) |
|
65 | ui.expandpath(source)) | |
66 | ui.status(_('pulling from %s\n') % |
|
66 | ui.status(_('pulling from %s\n') % | |
67 | url.hidepassword(ui.expandpath(source))) |
|
67 | url.hidepassword(ui.expandpath(source))) |
@@ -279,7 +279,7 b' def goutgoing(ui, repo, dest=None, **opt' | |||||
279 | dest = ui.expandpath(dest or 'default-push', dest or 'default') |
|
279 | dest = ui.expandpath(dest or 'default-push', dest or 'default') | |
280 | dest, branches = hg.parseurl(dest, opts.get('branch')) |
|
280 | dest, branches = hg.parseurl(dest, opts.get('branch')) | |
281 | revs, checkout = hg.addbranchrevs(repo, repo, branches, opts.get('rev')) |
|
281 | revs, checkout = hg.addbranchrevs(repo, repo, branches, opts.get('rev')) | |
282 |
other = hg.repository( |
|
282 | other = hg.repository(hg.remoteui(ui, opts), dest) | |
283 | if revs: |
|
283 | if revs: | |
284 | revs = [repo.lookup(rev) for rev in revs] |
|
284 | revs = [repo.lookup(rev) for rev in revs] | |
285 | ui.status(_('comparing with %s\n') % url.hidepassword(dest)) |
|
285 | ui.status(_('comparing with %s\n') % url.hidepassword(dest)) | |
@@ -306,7 +306,7 b' def gincoming(ui, repo, source="default"' | |||||
306 |
|
306 | |||
307 | check_unsupported_flags(opts) |
|
307 | check_unsupported_flags(opts) | |
308 | source, branches = hg.parseurl(ui.expandpath(source), opts.get('branch')) |
|
308 | source, branches = hg.parseurl(ui.expandpath(source), opts.get('branch')) | |
309 |
other = hg.repository( |
|
309 | other = hg.repository(hg.remoteui(repo, opts), source) | |
310 | revs, checkout = hg.addbranchrevs(repo, other, branches, opts.get('rev')) |
|
310 | revs, checkout = hg.addbranchrevs(repo, other, branches, opts.get('rev')) | |
311 | ui.status(_('comparing with %s\n') % url.hidepassword(source)) |
|
311 | ui.status(_('comparing with %s\n') % url.hidepassword(source)) | |
312 | if revs: |
|
312 | if revs: |
@@ -1871,7 +1871,7 b' def clone(ui, source, dest=None, **opts)' | |||||
1871 | return url + '/.hg/patches' |
|
1871 | return url + '/.hg/patches' | |
1872 | if dest is None: |
|
1872 | if dest is None: | |
1873 | dest = hg.defaultdest(source) |
|
1873 | dest = hg.defaultdest(source) | |
1874 |
sr = hg.repository( |
|
1874 | sr = hg.repository(hg.remoteui(ui, opts), ui.expandpath(source)) | |
1875 | if opts['patches']: |
|
1875 | if opts['patches']: | |
1876 | patchespath = ui.expandpath(opts['patches']) |
|
1876 | patchespath = ui.expandpath(opts['patches']) | |
1877 | else: |
|
1877 | else: |
@@ -242,7 +242,7 b' def patchbomb(ui, repo, *revs, **opts):' | |||||
242 | revs, checkout = hg.addbranchrevs(repo, repo, branches, revs) |
|
242 | revs, checkout = hg.addbranchrevs(repo, repo, branches, revs) | |
243 | if revs: |
|
243 | if revs: | |
244 | revs = [repo.lookup(rev) for rev in revs] |
|
244 | revs = [repo.lookup(rev) for rev in revs] | |
245 |
other = hg.repository( |
|
245 | other = hg.repository(hg.remoteui(repo, opts), dest) | |
246 | ui.status(_('comparing with %s\n') % dest) |
|
246 | ui.status(_('comparing with %s\n') % dest) | |
247 | o = repo.findoutgoing(other) |
|
247 | o = repo.findoutgoing(other) | |
248 | if not o: |
|
248 | if not o: |
@@ -39,7 +39,7 b' def relink(ui, repo, origin=None, **opts' | |||||
39 | if not hasattr(util, 'samefile') or not hasattr(util, 'samedevice'): |
|
39 | if not hasattr(util, 'samefile') or not hasattr(util, 'samedevice'): | |
40 | raise util.Abort(_('hardlinks are not supported on this system')) |
|
40 | raise util.Abort(_('hardlinks are not supported on this system')) | |
41 | src = hg.repository( |
|
41 | src = hg.repository( | |
42 |
|
|
42 | hg.remoteui(repo, opts), | |
43 | ui.expandpath(origin or 'default-relink', origin or 'default')) |
|
43 | ui.expandpath(origin or 'default-relink', origin or 'default')) | |
44 | if not src.local(): |
|
44 | if not src.local(): | |
45 | raise util.Abort('must specify local origin repository') |
|
45 | raise util.Abort('must specify local origin repository') |
@@ -111,32 +111,6 b' def loglimit(opts):' | |||||
111 | limit = None |
|
111 | limit = None | |
112 | return limit |
|
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 | def revpair(repo, revs): |
|
114 | def revpair(repo, revs): | |
141 | '''return pair of nodes, given list of revisions. second item can |
|
115 | '''return pair of nodes, given list of revisions. second item can | |
142 | be None, meaning use working dir.''' |
|
116 | be None, meaning use working dir.''' |
@@ -594,7 +594,7 b' def bundle(ui, repo, fname, dest=None, *' | |||||
594 | else: |
|
594 | else: | |
595 | dest = ui.expandpath(dest or 'default-push', dest or 'default') |
|
595 | dest = ui.expandpath(dest or 'default-push', dest or 'default') | |
596 | dest, branches = hg.parseurl(dest, opts.get('branch')) |
|
596 | dest, branches = hg.parseurl(dest, opts.get('branch')) | |
597 |
other = hg.repository( |
|
597 | other = hg.repository(hg.remoteui(repo, opts), dest) | |
598 | revs, checkout = hg.addbranchrevs(repo, other, branches, revs) |
|
598 | revs, checkout = hg.addbranchrevs(repo, other, branches, revs) | |
599 | o = repo.findoutgoing(other, force=opts.get('force')) |
|
599 | o = repo.findoutgoing(other, force=opts.get('force')) | |
600 |
|
600 | |||
@@ -711,7 +711,7 b' def clone(ui, source, dest=None, **opts)' | |||||
711 | if opts.get('noupdate') and opts.get('updaterev'): |
|
711 | if opts.get('noupdate') and opts.get('updaterev'): | |
712 | raise util.Abort(_("cannot specify both --noupdate and --updaterev")) |
|
712 | raise util.Abort(_("cannot specify both --noupdate and --updaterev")) | |
713 |
|
713 | |||
714 |
r = hg.clone( |
|
714 | r = hg.clone(hg.remoteui(ui, opts), source, dest, | |
715 | pull=opts.get('pull'), |
|
715 | pull=opts.get('pull'), | |
716 | stream=opts.get('uncompressed'), |
|
716 | stream=opts.get('uncompressed'), | |
717 | rev=opts.get('rev'), |
|
717 | rev=opts.get('rev'), | |
@@ -2071,7 +2071,7 b' def incoming(ui, repo, source="default",' | |||||
2071 | """ |
|
2071 | """ | |
2072 | limit = cmdutil.loglimit(opts) |
|
2072 | limit = cmdutil.loglimit(opts) | |
2073 | source, branches = hg.parseurl(ui.expandpath(source), opts.get('branch')) |
|
2073 | source, branches = hg.parseurl(ui.expandpath(source), opts.get('branch')) | |
2074 |
other = hg.repository( |
|
2074 | other = hg.repository(hg.remoteui(repo, opts), source) | |
2075 | ui.status(_('comparing with %s\n') % url.hidepassword(source)) |
|
2075 | ui.status(_('comparing with %s\n') % url.hidepassword(source)) | |
2076 | revs, checkout = hg.addbranchrevs(repo, other, branches, opts.get('rev')) |
|
2076 | revs, checkout = hg.addbranchrevs(repo, other, branches, opts.get('rev')) | |
2077 | if revs: |
|
2077 | if revs: | |
@@ -2141,7 +2141,7 b' def init(ui, dest=".", **opts):' | |||||
2141 |
|
2141 | |||
2142 | Returns 0 on success. |
|
2142 | Returns 0 on success. | |
2143 | """ |
|
2143 | """ | |
2144 |
hg.repository( |
|
2144 | hg.repository(hg.remoteui(ui, opts), dest, create=1) | |
2145 |
|
2145 | |||
2146 | def locate(ui, repo, *pats, **opts): |
|
2146 | def locate(ui, repo, *pats, **opts): | |
2147 | """locate files matching specific patterns |
|
2147 | """locate files matching specific patterns | |
@@ -2379,7 +2379,7 b' def outgoing(ui, repo, dest=None, **opts' | |||||
2379 | if revs: |
|
2379 | if revs: | |
2380 | revs = [repo.lookup(rev) for rev in revs] |
|
2380 | revs = [repo.lookup(rev) for rev in revs] | |
2381 |
|
2381 | |||
2382 |
other = hg.repository( |
|
2382 | other = hg.repository(hg.remoteui(repo, opts), dest) | |
2383 | ui.status(_('comparing with %s\n') % url.hidepassword(dest)) |
|
2383 | ui.status(_('comparing with %s\n') % url.hidepassword(dest)) | |
2384 | o = repo.findoutgoing(other, force=opts.get('force')) |
|
2384 | o = repo.findoutgoing(other, force=opts.get('force')) | |
2385 | if not o: |
|
2385 | if not o: | |
@@ -2511,7 +2511,7 b' def pull(ui, repo, source="default", **o' | |||||
2511 | Returns 0 on success, 1 if an update had unresolved files. |
|
2511 | Returns 0 on success, 1 if an update had unresolved files. | |
2512 | """ |
|
2512 | """ | |
2513 | source, branches = hg.parseurl(ui.expandpath(source), opts.get('branch')) |
|
2513 | source, branches = hg.parseurl(ui.expandpath(source), opts.get('branch')) | |
2514 |
other = hg.repository( |
|
2514 | other = hg.repository(hg.remoteui(repo, opts), source) | |
2515 | ui.status(_('pulling from %s\n') % url.hidepassword(source)) |
|
2515 | ui.status(_('pulling from %s\n') % url.hidepassword(source)) | |
2516 | revs, checkout = hg.addbranchrevs(repo, other, branches, opts.get('rev')) |
|
2516 | revs, checkout = hg.addbranchrevs(repo, other, branches, opts.get('rev')) | |
2517 | if revs: |
|
2517 | if revs: | |
@@ -2559,7 +2559,7 b' def push(ui, repo, dest=None, **opts):' | |||||
2559 | dest = ui.expandpath(dest or 'default-push', dest or 'default') |
|
2559 | dest = ui.expandpath(dest or 'default-push', dest or 'default') | |
2560 | dest, branches = hg.parseurl(dest, opts.get('branch')) |
|
2560 | dest, branches = hg.parseurl(dest, opts.get('branch')) | |
2561 | revs, checkout = hg.addbranchrevs(repo, repo, branches, opts.get('rev')) |
|
2561 | revs, checkout = hg.addbranchrevs(repo, repo, branches, opts.get('rev')) | |
2562 |
other = hg.repository( |
|
2562 | other = hg.repository(hg.remoteui(repo, opts), dest) | |
2563 | ui.status(_('pushing to %s\n') % url.hidepassword(dest)) |
|
2563 | ui.status(_('pushing to %s\n') % url.hidepassword(dest)) | |
2564 | if revs: |
|
2564 | if revs: | |
2565 | revs = [repo.lookup(rev) for rev in revs] |
|
2565 | revs = [repo.lookup(rev) for rev in revs] | |
@@ -3306,7 +3306,7 b' def summary(ui, repo, **opts):' | |||||
3306 | if opts.get('remote'): |
|
3306 | if opts.get('remote'): | |
3307 | t = [] |
|
3307 | t = [] | |
3308 | source, branches = hg.parseurl(ui.expandpath('default')) |
|
3308 | source, branches = hg.parseurl(ui.expandpath('default')) | |
3309 |
other = hg.repository( |
|
3309 | other = hg.repository(hg.remoteui(repo, {}), source) | |
3310 | revs, checkout = hg.addbranchrevs(repo, other, branches, opts.get('rev')) |
|
3310 | revs, checkout = hg.addbranchrevs(repo, other, branches, opts.get('rev')) | |
3311 | ui.debug('comparing with %s\n' % url.hidepassword(source)) |
|
3311 | ui.debug('comparing with %s\n' % url.hidepassword(source)) | |
3312 | repo.ui.pushbuffer() |
|
3312 | repo.ui.pushbuffer() | |
@@ -3317,7 +3317,7 b' def summary(ui, repo, **opts):' | |||||
3317 |
|
3317 | |||
3318 | dest, branches = hg.parseurl(ui.expandpath('default-push', 'default')) |
|
3318 | dest, branches = hg.parseurl(ui.expandpath('default-push', 'default')) | |
3319 | revs, checkout = hg.addbranchrevs(repo, repo, branches, None) |
|
3319 | revs, checkout = hg.addbranchrevs(repo, repo, branches, None) | |
3320 |
other = hg.repository( |
|
3320 | other = hg.repository(hg.remoteui(repo, {}), dest) | |
3321 | ui.debug('comparing with %s\n' % url.hidepassword(dest)) |
|
3321 | ui.debug('comparing with %s\n' % url.hidepassword(dest)) | |
3322 | repo.ui.pushbuffer() |
|
3322 | repo.ui.pushbuffer() | |
3323 | o = repo.findoutgoing(other) |
|
3323 | o = repo.findoutgoing(other) |
@@ -400,3 +400,29 b' def revert(repo, node, choose):' | |||||
400 | def verify(repo): |
|
400 | def verify(repo): | |
401 | """verify the consistency of a repository""" |
|
401 | """verify the consistency of a repository""" | |
402 | return verifymod.verify(repo) |
|
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