comparison mercurial/commands.py @ 2598:b898afee9d0d

Add ui method to set --ssh/--remotecmd, use it in init/clone/pull/push/in/out. The only user visible change is that 'hg init' now accepts this options, too.
author Thomas Arendsen Hein <thomas@intevation.de>
date Wed, 12 Jul 2006 08:57:18 +0200
parents 5ba8be56fa8f
children c4325f0a9b91
comparison
equal deleted inserted replaced
2597:5ba8be56fa8f 2598:b898afee9d0d
954 954
955 It is possible to specify an ssh:// URL as the destination, but no 955 It is possible to specify an ssh:// URL as the destination, but no
956 .hg/hgrc will be created on the remote side. Look at the help text 956 .hg/hgrc will be created on the remote side. Look at the help text
957 for the pull command for important details about ssh:// URLs. 957 for the pull command for important details about ssh:// URLs.
958 """ 958 """
959 if opts['ssh']: 959 ui.setconfig_remoteopts(**opts)
960 ui.setconfig("ui", "ssh", opts['ssh'])
961 if opts['remotecmd']:
962 ui.setconfig("ui", "remotecmd", opts['remotecmd'])
963
964 hg.clone(ui, ui.expandpath(source), dest, 960 hg.clone(ui, ui.expandpath(source), dest,
965 pull=opts['pull'], 961 pull=opts['pull'],
966 rev=opts['rev'], 962 rev=opts['rev'],
967 update=not opts['noupdate']) 963 update=not opts['noupdate'])
968 964
1816 twice if the incoming is followed by a pull. 1812 twice if the incoming is followed by a pull.
1817 1813
1818 See pull for valid source format details. 1814 See pull for valid source format details.
1819 """ 1815 """
1820 source = ui.expandpath(source) 1816 source = ui.expandpath(source)
1821 if opts['ssh']: 1817 ui.setconfig_remoteopts(**opts)
1822 ui.setconfig("ui", "ssh", opts['ssh'])
1823 if opts['remotecmd']:
1824 ui.setconfig("ui", "remotecmd", opts['remotecmd'])
1825 1818
1826 other = hg.repository(ui, source) 1819 other = hg.repository(ui, source)
1827 incoming = repo.findincoming(other, force=opts["force"]) 1820 incoming = repo.findincoming(other, force=opts["force"])
1828 if not incoming: 1821 if not incoming:
1829 ui.status(_("no changes found\n")) 1822 ui.status(_("no changes found\n"))
1863 if hasattr(other, 'close'): 1856 if hasattr(other, 'close'):
1864 other.close() 1857 other.close()
1865 if cleanup: 1858 if cleanup:
1866 os.unlink(cleanup) 1859 os.unlink(cleanup)
1867 1860
1868 def init(ui, dest="."): 1861 def init(ui, dest=".", **opts):
1869 """create a new repository in the given directory 1862 """create a new repository in the given directory
1870 1863
1871 Initialize a new repository in the given directory. If the given 1864 Initialize a new repository in the given directory. If the given
1872 directory does not exist, it is created. 1865 directory does not exist, it is created.
1873 1866
1875 1868
1876 It is possible to specify an ssh:// URL as the destination. 1869 It is possible to specify an ssh:// URL as the destination.
1877 Look at the help text for the pull command for important details 1870 Look at the help text for the pull command for important details
1878 about ssh:// URLs. 1871 about ssh:// URLs.
1879 """ 1872 """
1873 ui.setconfig_remoteopts(**opts)
1880 hg.repository(ui, dest, create=1) 1874 hg.repository(ui, dest, create=1)
1881 1875
1882 def locate(ui, repo, *pats, **opts): 1876 def locate(ui, repo, *pats, **opts):
1883 """locate files matching specific patterns 1877 """locate files matching specific patterns
1884 1878
2052 if a push was requested. 2046 if a push was requested.
2053 2047
2054 See pull for valid destination format details. 2048 See pull for valid destination format details.
2055 """ 2049 """
2056 dest = ui.expandpath(dest or 'default-push', dest or 'default') 2050 dest = ui.expandpath(dest or 'default-push', dest or 'default')
2057 if opts['ssh']: 2051 ui.setconfig_remoteopts(**opts)
2058 ui.setconfig("ui", "ssh", opts['ssh'])
2059 if opts['remotecmd']:
2060 ui.setconfig("ui", "remotecmd", opts['remotecmd'])
2061 revs = None 2052 revs = None
2062 if opts['rev']: 2053 if opts['rev']:
2063 revs = [repo.lookup(rev) for rev in opts['rev']] 2054 revs = [repo.lookup(rev) for rev in opts['rev']]
2064 2055
2065 other = hg.repository(ui, dest) 2056 other = hg.repository(ui, dest)
2162 Compression on 2153 Compression on
2163 Alternatively specify "ssh -C" as your ssh command in your hgrc or 2154 Alternatively specify "ssh -C" as your ssh command in your hgrc or
2164 with the --ssh command line option. 2155 with the --ssh command line option.
2165 """ 2156 """
2166 source = ui.expandpath(source) 2157 source = ui.expandpath(source)
2167 2158 ui.setconfig_remoteopts(**opts)
2168 if opts['ssh']:
2169 ui.setconfig("ui", "ssh", opts['ssh'])
2170 if opts['remotecmd']:
2171 ui.setconfig("ui", "remotecmd", opts['remotecmd'])
2172 2159
2173 other = hg.repository(ui, source) 2160 other = hg.repository(ui, source)
2174 ui.status(_('pulling from %s\n') % (source)) 2161 ui.status(_('pulling from %s\n') % (source))
2175 revs = None 2162 revs = None
2176 if opts['rev'] and not other.local(): 2163 if opts['rev'] and not other.local():
2204 2191
2205 Pushing to http:// and https:// URLs is possible, too, if this 2192 Pushing to http:// and https:// URLs is possible, too, if this
2206 feature is enabled on the remote Mercurial server. 2193 feature is enabled on the remote Mercurial server.
2207 """ 2194 """
2208 dest = ui.expandpath(dest or 'default-push', dest or 'default') 2195 dest = ui.expandpath(dest or 'default-push', dest or 'default')
2209 2196 ui.setconfig_remoteopts(**opts)
2210 if opts['ssh']:
2211 ui.setconfig("ui", "ssh", opts['ssh'])
2212 if opts['remotecmd']:
2213 ui.setconfig("ui", "remotecmd", opts['remotecmd'])
2214 2197
2215 other = hg.repository(ui, dest) 2198 other = hg.repository(ui, dest)
2216 ui.status('pushing to %s\n' % (dest)) 2199 ui.status('pushing to %s\n' % (dest))
2217 revs = None 2200 revs = None
2218 if opts['rev']: 2201 if opts['rev']:
3011 ('e', 'ssh', '', _('specify ssh command to use')), 2994 ('e', 'ssh', '', _('specify ssh command to use')),
3012 ('', 'remotecmd', '', 2995 ('', 'remotecmd', '',
3013 _('specify hg command to run on the remote side'))], 2996 _('specify hg command to run on the remote side'))],
3014 _('hg incoming [-p] [-n] [-M] [-r REV]...' 2997 _('hg incoming [-p] [-n] [-M] [-r REV]...'
3015 ' [--bundle FILENAME] [SOURCE]')), 2998 ' [--bundle FILENAME] [SOURCE]')),
3016 "^init": (init, [], _('hg init [DEST]')), 2999 "^init":
3000 (init,
3001 [('e', 'ssh', '', _('specify ssh command to use')),
3002 ('', 'remotecmd', '',
3003 _('specify hg command to run on the remote side'))],
3004 _('hg init [-e FILE] [--remotecmd FILE] [DEST]')),
3017 "locate": 3005 "locate":
3018 (locate, 3006 (locate,
3019 [('r', 'rev', '', _('search the repository as it stood at rev')), 3007 [('r', 'rev', '', _('search the repository as it stood at rev')),
3020 ('0', 'print0', None, 3008 ('0', 'print0', None,
3021 _('end filenames with NUL, for use with xargs')), 3009 _('end filenames with NUL, for use with xargs')),
3072 ('f', 'force', None, 3060 ('f', 'force', None,
3073 _('run even when remote repository is unrelated')), 3061 _('run even when remote repository is unrelated')),
3074 ('r', 'rev', [], _('a specific revision you would like to pull')), 3062 ('r', 'rev', [], _('a specific revision you would like to pull')),
3075 ('', 'remotecmd', '', 3063 ('', 'remotecmd', '',
3076 _('specify hg command to run on the remote side'))], 3064 _('specify hg command to run on the remote side'))],
3077 _('hg pull [-u] [-e FILE] [-r REV]... [--remotecmd FILE] [SOURCE]')), 3065 _('hg pull [-u] [-r REV]... [-e FILE] [--remotecmd FILE] [SOURCE]')),
3078 "^push": 3066 "^push":
3079 (push, 3067 (push,
3080 [('f', 'force', None, _('force push')), 3068 [('f', 'force', None, _('force push')),
3081 ('e', 'ssh', '', _('specify ssh command to use')), 3069 ('e', 'ssh', '', _('specify ssh command to use')),
3082 ('r', 'rev', [], _('a specific revision you would like to push')), 3070 ('r', 'rev', [], _('a specific revision you would like to push')),
3083 ('', 'remotecmd', '', 3071 ('', 'remotecmd', '',
3084 _('specify hg command to run on the remote side'))], 3072 _('specify hg command to run on the remote side'))],
3085 _('hg push [-f] [-e FILE] [-r REV]... [--remotecmd FILE] [DEST]')), 3073 _('hg push [-f] [-r REV]... [-e FILE] [--remotecmd FILE] [DEST]')),
3086 "debugrawcommit|rawcommit": 3074 "debugrawcommit|rawcommit":
3087 (rawcommit, 3075 (rawcommit,
3088 [('p', 'parent', [], _('parent')), 3076 [('p', 'parent', [], _('parent')),
3089 ('d', 'date', '', _('date code')), 3077 ('d', 'date', '', _('date code')),
3090 ('u', 'user', '', _('user')), 3078 ('u', 'user', '', _('user')),