# HG changeset patch # User Matt Mackall # Date 1275409137 18000 # Node ID d1908cb95a82949e4ee51ca51b8912193f74f047 # Parent e8a66a40474df0c70609ed16843f95183c1639c8 remoteui: move from cmdutil to hg diff -r e8a66a40474d -r d1908cb95a82 hgext/fetch.py --- a/hgext/fetch.py Thu Jun 03 21:38:30 2010 +0200 +++ b/hgext/fetch.py Tue Jun 01 11:18:57 2010 -0500 @@ -61,7 +61,7 @@ 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 -r e8a66a40474d -r d1908cb95a82 hgext/graphlog.py --- a/hgext/graphlog.py Thu Jun 03 21:38:30 2010 +0200 +++ b/hgext/graphlog.py Tue Jun 01 11:18:57 2010 -0500 @@ -279,7 +279,7 @@ 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 @@ 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 -r e8a66a40474d -r d1908cb95a82 hgext/mq.py --- a/hgext/mq.py Thu Jun 03 21:38:30 2010 +0200 +++ b/hgext/mq.py Tue Jun 01 11:18:57 2010 -0500 @@ -1871,7 +1871,7 @@ 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 -r e8a66a40474d -r d1908cb95a82 hgext/patchbomb.py --- a/hgext/patchbomb.py Thu Jun 03 21:38:30 2010 +0200 +++ b/hgext/patchbomb.py Tue Jun 01 11:18:57 2010 -0500 @@ -242,7 +242,7 @@ 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 -r e8a66a40474d -r d1908cb95a82 hgext/relink.py --- a/hgext/relink.py Thu Jun 03 21:38:30 2010 +0200 +++ b/hgext/relink.py Tue Jun 01 11:18:57 2010 -0500 @@ -39,7 +39,7 @@ 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 -r e8a66a40474d -r d1908cb95a82 mercurial/cmdutil.py --- a/mercurial/cmdutil.py Thu Jun 03 21:38:30 2010 +0200 +++ b/mercurial/cmdutil.py Tue Jun 01 11:18:57 2010 -0500 @@ -111,32 +111,6 @@ 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 -r e8a66a40474d -r d1908cb95a82 mercurial/commands.py --- a/mercurial/commands.py Thu Jun 03 21:38:30 2010 +0200 +++ b/mercurial/commands.py Tue Jun 01 11:18:57 2010 -0500 @@ -594,7 +594,7 @@ 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 @@ 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 @@ """ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 -r e8a66a40474d -r d1908cb95a82 mercurial/hg.py --- a/mercurial/hg.py Thu Jun 03 21:38:30 2010 +0200 +++ b/mercurial/hg.py Tue Jun 01 11:18:57 2010 -0500 @@ -400,3 +400,29 @@ 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