diff --git a/hgext/fetch.py b/hgext/fetch.py --- a/hgext/fetch.py +++ b/hgext/fetch.py @@ -61,7 +61,7 @@ def fetch(ui, repo, source='default', ** raise util.Abort(_('multiple heads in this branch ' '(use "hg heads ." and "hg merge" to merge)')) - other = hg.repository(cmdutil.remoteui(repo, opts), + other = hg.repository(hg.remoteui(repo, opts), ui.expandpath(source)) ui.status(_('pulling from %s\n') % url.hidepassword(ui.expandpath(source))) diff --git a/hgext/graphlog.py b/hgext/graphlog.py --- a/hgext/graphlog.py +++ b/hgext/graphlog.py @@ -279,7 +279,7 @@ def goutgoing(ui, repo, dest=None, **opt dest = ui.expandpath(dest or 'default-push', dest or 'default') dest, branches = hg.parseurl(dest, opts.get('branch')) revs, checkout = hg.addbranchrevs(repo, repo, branches, opts.get('rev')) - other = hg.repository(cmdutil.remoteui(ui, opts), dest) + other = hg.repository(hg.remoteui(ui, opts), dest) if revs: revs = [repo.lookup(rev) for rev in revs] ui.status(_('comparing with %s\n') % url.hidepassword(dest)) @@ -306,7 +306,7 @@ def gincoming(ui, repo, source="default" check_unsupported_flags(opts) source, branches = hg.parseurl(ui.expandpath(source), opts.get('branch')) - other = hg.repository(cmdutil.remoteui(repo, opts), source) + other = hg.repository(hg.remoteui(repo, opts), source) revs, checkout = hg.addbranchrevs(repo, other, branches, opts.get('rev')) ui.status(_('comparing with %s\n') % url.hidepassword(source)) if revs: diff --git a/hgext/mq.py b/hgext/mq.py --- a/hgext/mq.py +++ b/hgext/mq.py @@ -1871,7 +1871,7 @@ def clone(ui, source, dest=None, **opts) return url + '/.hg/patches' if dest is None: dest = hg.defaultdest(source) - sr = hg.repository(cmdutil.remoteui(ui, opts), ui.expandpath(source)) + sr = hg.repository(hg.remoteui(ui, opts), ui.expandpath(source)) if opts['patches']: patchespath = ui.expandpath(opts['patches']) else: diff --git a/hgext/patchbomb.py b/hgext/patchbomb.py --- a/hgext/patchbomb.py +++ b/hgext/patchbomb.py @@ -242,7 +242,7 @@ def patchbomb(ui, repo, *revs, **opts): revs, checkout = hg.addbranchrevs(repo, repo, branches, revs) if revs: revs = [repo.lookup(rev) for rev in revs] - other = hg.repository(cmdutil.remoteui(repo, opts), dest) + other = hg.repository(hg.remoteui(repo, opts), dest) ui.status(_('comparing with %s\n') % dest) o = repo.findoutgoing(other) if not o: diff --git a/hgext/relink.py b/hgext/relink.py --- a/hgext/relink.py +++ b/hgext/relink.py @@ -39,7 +39,7 @@ def relink(ui, repo, origin=None, **opts if not hasattr(util, 'samefile') or not hasattr(util, 'samedevice'): raise util.Abort(_('hardlinks are not supported on this system')) src = hg.repository( - cmdutil.remoteui(repo, opts), + hg.remoteui(repo, opts), ui.expandpath(origin or 'default-relink', origin or 'default')) if not src.local(): raise util.Abort('must specify local origin repository') diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py --- a/mercurial/cmdutil.py +++ b/mercurial/cmdutil.py @@ -111,32 +111,6 @@ def loglimit(opts): limit = None return limit -def remoteui(src, opts): - 'build a remote ui from ui or repo and opts' - if hasattr(src, 'baseui'): # looks like a repository - dst = src.baseui.copy() # drop repo-specific config - src = src.ui # copy target options from repo - else: # assume it's a global ui object - dst = src.copy() # keep all global options - - # copy ssh-specific options - for o in 'ssh', 'remotecmd': - v = opts.get(o) or src.config('ui', o) - if v: - dst.setconfig("ui", o, v) - - # copy bundle-specific options - r = src.config('bundle', 'mainreporoot') - if r: - dst.setconfig('bundle', 'mainreporoot', r) - - # copy auth and http_proxy section settings - for sect in ('auth', 'http_proxy'): - for key, val in src.configitems(sect): - dst.setconfig(sect, key, val) - - return dst - def revpair(repo, revs): '''return pair of nodes, given list of revisions. second item can be None, meaning use working dir.''' diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -594,7 +594,7 @@ def bundle(ui, repo, fname, dest=None, * else: dest = ui.expandpath(dest or 'default-push', dest or 'default') dest, branches = hg.parseurl(dest, opts.get('branch')) - other = hg.repository(cmdutil.remoteui(repo, opts), dest) + other = hg.repository(hg.remoteui(repo, opts), dest) revs, checkout = hg.addbranchrevs(repo, other, branches, revs) o = repo.findoutgoing(other, force=opts.get('force')) @@ -711,7 +711,7 @@ def clone(ui, source, dest=None, **opts) if opts.get('noupdate') and opts.get('updaterev'): raise util.Abort(_("cannot specify both --noupdate and --updaterev")) - r = hg.clone(cmdutil.remoteui(ui, opts), source, dest, + r = hg.clone(hg.remoteui(ui, opts), source, dest, pull=opts.get('pull'), stream=opts.get('uncompressed'), rev=opts.get('rev'), @@ -2071,7 +2071,7 @@ def incoming(ui, repo, source="default", """ limit = cmdutil.loglimit(opts) source, branches = hg.parseurl(ui.expandpath(source), opts.get('branch')) - other = hg.repository(cmdutil.remoteui(repo, opts), source) + other = hg.repository(hg.remoteui(repo, opts), source) ui.status(_('comparing with %s\n') % url.hidepassword(source)) revs, checkout = hg.addbranchrevs(repo, other, branches, opts.get('rev')) if revs: @@ -2141,7 +2141,7 @@ def init(ui, dest=".", **opts): Returns 0 on success. """ - hg.repository(cmdutil.remoteui(ui, opts), dest, create=1) + hg.repository(hg.remoteui(ui, opts), dest, create=1) def locate(ui, repo, *pats, **opts): """locate files matching specific patterns @@ -2379,7 +2379,7 @@ def outgoing(ui, repo, dest=None, **opts if revs: revs = [repo.lookup(rev) for rev in revs] - other = hg.repository(cmdutil.remoteui(repo, opts), dest) + other = hg.repository(hg.remoteui(repo, opts), dest) ui.status(_('comparing with %s\n') % url.hidepassword(dest)) o = repo.findoutgoing(other, force=opts.get('force')) if not o: @@ -2511,7 +2511,7 @@ def pull(ui, repo, source="default", **o Returns 0 on success, 1 if an update had unresolved files. """ source, branches = hg.parseurl(ui.expandpath(source), opts.get('branch')) - other = hg.repository(cmdutil.remoteui(repo, opts), source) + other = hg.repository(hg.remoteui(repo, opts), source) ui.status(_('pulling from %s\n') % url.hidepassword(source)) revs, checkout = hg.addbranchrevs(repo, other, branches, opts.get('rev')) if revs: @@ -2559,7 +2559,7 @@ def push(ui, repo, dest=None, **opts): dest = ui.expandpath(dest or 'default-push', dest or 'default') dest, branches = hg.parseurl(dest, opts.get('branch')) revs, checkout = hg.addbranchrevs(repo, repo, branches, opts.get('rev')) - other = hg.repository(cmdutil.remoteui(repo, opts), dest) + other = hg.repository(hg.remoteui(repo, opts), dest) ui.status(_('pushing to %s\n') % url.hidepassword(dest)) if revs: revs = [repo.lookup(rev) for rev in revs] @@ -3306,7 +3306,7 @@ def summary(ui, repo, **opts): if opts.get('remote'): t = [] source, branches = hg.parseurl(ui.expandpath('default')) - other = hg.repository(cmdutil.remoteui(repo, {}), source) + other = hg.repository(hg.remoteui(repo, {}), source) revs, checkout = hg.addbranchrevs(repo, other, branches, opts.get('rev')) ui.debug('comparing with %s\n' % url.hidepassword(source)) repo.ui.pushbuffer() @@ -3317,7 +3317,7 @@ def summary(ui, repo, **opts): dest, branches = hg.parseurl(ui.expandpath('default-push', 'default')) revs, checkout = hg.addbranchrevs(repo, repo, branches, None) - other = hg.repository(cmdutil.remoteui(repo, {}), dest) + other = hg.repository(hg.remoteui(repo, {}), dest) ui.debug('comparing with %s\n' % url.hidepassword(dest)) repo.ui.pushbuffer() o = repo.findoutgoing(other) diff --git a/mercurial/hg.py b/mercurial/hg.py --- a/mercurial/hg.py +++ b/mercurial/hg.py @@ -400,3 +400,29 @@ def revert(repo, node, choose): def verify(repo): """verify the consistency of a repository""" return verifymod.verify(repo) + +def remoteui(src, opts): + 'build a remote ui from ui or repo and opts' + if hasattr(src, 'baseui'): # looks like a repository + dst = src.baseui.copy() # drop repo-specific config + src = src.ui # copy target options from repo + else: # assume it's a global ui object + dst = src.copy() # keep all global options + + # copy ssh-specific options + for o in 'ssh', 'remotecmd': + v = opts.get(o) or src.config('ui', o) + if v: + dst.setconfig("ui", o, v) + + # copy bundle-specific options + r = src.config('bundle', 'mainreporoot') + if r: + dst.setconfig('bundle', 'mainreporoot', r) + + # copy auth and http_proxy section settings + for sect in ('auth', 'http_proxy'): + for key, val in src.configitems(sect): + dst.setconfig(sect, key, val) + + return dst