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