changeset 11273:d1908cb95a82

remoteui: move from cmdutil to hg
author Matt Mackall <mpm@selenic.com>
date Tue, 01 Jun 2010 11:18:57 -0500
parents e8a66a40474d
children 77272d28b53f
files hgext/fetch.py hgext/graphlog.py hgext/mq.py hgext/patchbomb.py hgext/relink.py mercurial/cmdutil.py mercurial/commands.py mercurial/hg.py
diffstat 8 files changed, 41 insertions(+), 41 deletions(-) [+]
line wrap: on
line diff
--- 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)))
--- 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:
--- 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:
--- 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:
--- 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')
--- 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.'''
--- 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)
--- 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