##// END OF EJS Templates
dispatch: lowercase abort message
Martin Geisler -
r15781:cc2da4a5 default
parent child Browse files
Show More
@@ -1,737 +1,737
1 # dispatch.py - command dispatching for mercurial
1 # dispatch.py - command dispatching for mercurial
2 #
2 #
3 # Copyright 2005-2007 Matt Mackall <mpm@selenic.com>
3 # Copyright 2005-2007 Matt Mackall <mpm@selenic.com>
4 #
4 #
5 # This software may be used and distributed according to the terms of the
5 # This software may be used and distributed according to the terms of the
6 # GNU General Public License version 2 or any later version.
6 # GNU General Public License version 2 or any later version.
7
7
8 from i18n import _
8 from i18n import _
9 import os, sys, atexit, signal, pdb, socket, errno, shlex, time, traceback, re
9 import os, sys, atexit, signal, pdb, socket, errno, shlex, time, traceback, re
10 import util, commands, hg, fancyopts, extensions, hook, error
10 import util, commands, hg, fancyopts, extensions, hook, error
11 import cmdutil, encoding
11 import cmdutil, encoding
12 import ui as uimod
12 import ui as uimod
13
13
14 class request(object):
14 class request(object):
15 def __init__(self, args, ui=None, repo=None, fin=None, fout=None, ferr=None):
15 def __init__(self, args, ui=None, repo=None, fin=None, fout=None, ferr=None):
16 self.args = args
16 self.args = args
17 self.ui = ui
17 self.ui = ui
18 self.repo = repo
18 self.repo = repo
19
19
20 # input/output/error streams
20 # input/output/error streams
21 self.fin = fin
21 self.fin = fin
22 self.fout = fout
22 self.fout = fout
23 self.ferr = ferr
23 self.ferr = ferr
24
24
25 def run():
25 def run():
26 "run the command in sys.argv"
26 "run the command in sys.argv"
27 sys.exit((dispatch(request(sys.argv[1:])) or 0) & 255)
27 sys.exit((dispatch(request(sys.argv[1:])) or 0) & 255)
28
28
29 def dispatch(req):
29 def dispatch(req):
30 "run the command specified in req.args"
30 "run the command specified in req.args"
31 if req.ferr:
31 if req.ferr:
32 ferr = req.ferr
32 ferr = req.ferr
33 elif req.ui:
33 elif req.ui:
34 ferr = req.ui.ferr
34 ferr = req.ui.ferr
35 else:
35 else:
36 ferr = sys.stderr
36 ferr = sys.stderr
37
37
38 try:
38 try:
39 if not req.ui:
39 if not req.ui:
40 req.ui = uimod.ui()
40 req.ui = uimod.ui()
41 if '--traceback' in req.args:
41 if '--traceback' in req.args:
42 req.ui.setconfig('ui', 'traceback', 'on')
42 req.ui.setconfig('ui', 'traceback', 'on')
43
43
44 # set ui streams from the request
44 # set ui streams from the request
45 if req.fin:
45 if req.fin:
46 req.ui.fin = req.fin
46 req.ui.fin = req.fin
47 if req.fout:
47 if req.fout:
48 req.ui.fout = req.fout
48 req.ui.fout = req.fout
49 if req.ferr:
49 if req.ferr:
50 req.ui.ferr = req.ferr
50 req.ui.ferr = req.ferr
51 except util.Abort, inst:
51 except util.Abort, inst:
52 ferr.write(_("abort: %s\n") % inst)
52 ferr.write(_("abort: %s\n") % inst)
53 if inst.hint:
53 if inst.hint:
54 ferr.write(_("(%s)\n") % inst.hint)
54 ferr.write(_("(%s)\n") % inst.hint)
55 return -1
55 return -1
56 except error.ParseError, inst:
56 except error.ParseError, inst:
57 if len(inst.args) > 1:
57 if len(inst.args) > 1:
58 ferr.write(_("hg: parse error at %s: %s\n") %
58 ferr.write(_("hg: parse error at %s: %s\n") %
59 (inst.args[1], inst.args[0]))
59 (inst.args[1], inst.args[0]))
60 else:
60 else:
61 ferr.write(_("hg: parse error: %s\n") % inst.args[0])
61 ferr.write(_("hg: parse error: %s\n") % inst.args[0])
62 return -1
62 return -1
63
63
64 return _runcatch(req)
64 return _runcatch(req)
65
65
66 def _runcatch(req):
66 def _runcatch(req):
67 def catchterm(*args):
67 def catchterm(*args):
68 raise error.SignalInterrupt
68 raise error.SignalInterrupt
69
69
70 ui = req.ui
70 ui = req.ui
71 try:
71 try:
72 for name in 'SIGBREAK', 'SIGHUP', 'SIGTERM':
72 for name in 'SIGBREAK', 'SIGHUP', 'SIGTERM':
73 num = getattr(signal, name, None)
73 num = getattr(signal, name, None)
74 if num:
74 if num:
75 signal.signal(num, catchterm)
75 signal.signal(num, catchterm)
76 except ValueError:
76 except ValueError:
77 pass # happens if called in a thread
77 pass # happens if called in a thread
78
78
79 try:
79 try:
80 try:
80 try:
81 # enter the debugger before command execution
81 # enter the debugger before command execution
82 if '--debugger' in req.args:
82 if '--debugger' in req.args:
83 ui.warn(_("entering debugger - "
83 ui.warn(_("entering debugger - "
84 "type c to continue starting hg or h for help\n"))
84 "type c to continue starting hg or h for help\n"))
85 pdb.set_trace()
85 pdb.set_trace()
86 try:
86 try:
87 return _dispatch(req)
87 return _dispatch(req)
88 finally:
88 finally:
89 ui.flush()
89 ui.flush()
90 except:
90 except:
91 # enter the debugger when we hit an exception
91 # enter the debugger when we hit an exception
92 if '--debugger' in req.args:
92 if '--debugger' in req.args:
93 traceback.print_exc()
93 traceback.print_exc()
94 pdb.post_mortem(sys.exc_info()[2])
94 pdb.post_mortem(sys.exc_info()[2])
95 ui.traceback()
95 ui.traceback()
96 raise
96 raise
97
97
98 # Global exception handling, alphabetically
98 # Global exception handling, alphabetically
99 # Mercurial-specific first, followed by built-in and library exceptions
99 # Mercurial-specific first, followed by built-in and library exceptions
100 except error.AmbiguousCommand, inst:
100 except error.AmbiguousCommand, inst:
101 ui.warn(_("hg: command '%s' is ambiguous:\n %s\n") %
101 ui.warn(_("hg: command '%s' is ambiguous:\n %s\n") %
102 (inst.args[0], " ".join(inst.args[1])))
102 (inst.args[0], " ".join(inst.args[1])))
103 except error.ParseError, inst:
103 except error.ParseError, inst:
104 if len(inst.args) > 1:
104 if len(inst.args) > 1:
105 ui.warn(_("hg: parse error at %s: %s\n") %
105 ui.warn(_("hg: parse error at %s: %s\n") %
106 (inst.args[1], inst.args[0]))
106 (inst.args[1], inst.args[0]))
107 else:
107 else:
108 ui.warn(_("hg: parse error: %s\n") % inst.args[0])
108 ui.warn(_("hg: parse error: %s\n") % inst.args[0])
109 return -1
109 return -1
110 except error.LockHeld, inst:
110 except error.LockHeld, inst:
111 if inst.errno == errno.ETIMEDOUT:
111 if inst.errno == errno.ETIMEDOUT:
112 reason = _('timed out waiting for lock held by %s') % inst.locker
112 reason = _('timed out waiting for lock held by %s') % inst.locker
113 else:
113 else:
114 reason = _('lock held by %s') % inst.locker
114 reason = _('lock held by %s') % inst.locker
115 ui.warn(_("abort: %s: %s\n") % (inst.desc or inst.filename, reason))
115 ui.warn(_("abort: %s: %s\n") % (inst.desc or inst.filename, reason))
116 except error.LockUnavailable, inst:
116 except error.LockUnavailable, inst:
117 ui.warn(_("abort: could not lock %s: %s\n") %
117 ui.warn(_("abort: could not lock %s: %s\n") %
118 (inst.desc or inst.filename, inst.strerror))
118 (inst.desc or inst.filename, inst.strerror))
119 except error.CommandError, inst:
119 except error.CommandError, inst:
120 if inst.args[0]:
120 if inst.args[0]:
121 ui.warn(_("hg %s: %s\n") % (inst.args[0], inst.args[1]))
121 ui.warn(_("hg %s: %s\n") % (inst.args[0], inst.args[1]))
122 commands.help_(ui, inst.args[0], full=False, command=True)
122 commands.help_(ui, inst.args[0], full=False, command=True)
123 else:
123 else:
124 ui.warn(_("hg: %s\n") % inst.args[1])
124 ui.warn(_("hg: %s\n") % inst.args[1])
125 commands.help_(ui, 'shortlist')
125 commands.help_(ui, 'shortlist')
126 except error.OutOfBandError, inst:
126 except error.OutOfBandError, inst:
127 ui.warn(_("abort: remote error:\n"))
127 ui.warn(_("abort: remote error:\n"))
128 ui.warn(''.join(inst.args))
128 ui.warn(''.join(inst.args))
129 except error.RepoError, inst:
129 except error.RepoError, inst:
130 ui.warn(_("abort: %s!\n") % inst)
130 ui.warn(_("abort: %s!\n") % inst)
131 if inst.hint:
131 if inst.hint:
132 ui.warn(_("(%s)\n") % inst.hint)
132 ui.warn(_("(%s)\n") % inst.hint)
133 except error.ResponseError, inst:
133 except error.ResponseError, inst:
134 ui.warn(_("abort: %s") % inst.args[0])
134 ui.warn(_("abort: %s") % inst.args[0])
135 if not isinstance(inst.args[1], basestring):
135 if not isinstance(inst.args[1], basestring):
136 ui.warn(" %r\n" % (inst.args[1],))
136 ui.warn(" %r\n" % (inst.args[1],))
137 elif not inst.args[1]:
137 elif not inst.args[1]:
138 ui.warn(_(" empty string\n"))
138 ui.warn(_(" empty string\n"))
139 else:
139 else:
140 ui.warn("\n%r\n" % util.ellipsis(inst.args[1]))
140 ui.warn("\n%r\n" % util.ellipsis(inst.args[1]))
141 except error.RevlogError, inst:
141 except error.RevlogError, inst:
142 ui.warn(_("abort: %s!\n") % inst)
142 ui.warn(_("abort: %s!\n") % inst)
143 except error.SignalInterrupt:
143 except error.SignalInterrupt:
144 ui.warn(_("killed!\n"))
144 ui.warn(_("killed!\n"))
145 except error.UnknownCommand, inst:
145 except error.UnknownCommand, inst:
146 ui.warn(_("hg: unknown command '%s'\n") % inst.args[0])
146 ui.warn(_("hg: unknown command '%s'\n") % inst.args[0])
147 try:
147 try:
148 # check if the command is in a disabled extension
148 # check if the command is in a disabled extension
149 # (but don't check for extensions themselves)
149 # (but don't check for extensions themselves)
150 commands.help_(ui, inst.args[0], unknowncmd=True)
150 commands.help_(ui, inst.args[0], unknowncmd=True)
151 except error.UnknownCommand:
151 except error.UnknownCommand:
152 commands.help_(ui, 'shortlist')
152 commands.help_(ui, 'shortlist')
153 except util.Abort, inst:
153 except util.Abort, inst:
154 ui.warn(_("abort: %s\n") % inst)
154 ui.warn(_("abort: %s\n") % inst)
155 if inst.hint:
155 if inst.hint:
156 ui.warn(_("(%s)\n") % inst.hint)
156 ui.warn(_("(%s)\n") % inst.hint)
157 except ImportError, inst:
157 except ImportError, inst:
158 ui.warn(_("abort: %s!\n") % inst)
158 ui.warn(_("abort: %s!\n") % inst)
159 m = str(inst).split()[-1]
159 m = str(inst).split()[-1]
160 if m in "mpatch bdiff".split():
160 if m in "mpatch bdiff".split():
161 ui.warn(_("(did you forget to compile extensions?)\n"))
161 ui.warn(_("(did you forget to compile extensions?)\n"))
162 elif m in "zlib".split():
162 elif m in "zlib".split():
163 ui.warn(_("(is your Python install correct?)\n"))
163 ui.warn(_("(is your Python install correct?)\n"))
164 except IOError, inst:
164 except IOError, inst:
165 if util.safehasattr(inst, "code"):
165 if util.safehasattr(inst, "code"):
166 ui.warn(_("abort: %s\n") % inst)
166 ui.warn(_("abort: %s\n") % inst)
167 elif util.safehasattr(inst, "reason"):
167 elif util.safehasattr(inst, "reason"):
168 try: # usually it is in the form (errno, strerror)
168 try: # usually it is in the form (errno, strerror)
169 reason = inst.reason.args[1]
169 reason = inst.reason.args[1]
170 except (AttributeError, IndexError):
170 except (AttributeError, IndexError):
171 # it might be anything, for example a string
171 # it might be anything, for example a string
172 reason = inst.reason
172 reason = inst.reason
173 ui.warn(_("abort: error: %s\n") % reason)
173 ui.warn(_("abort: error: %s\n") % reason)
174 elif util.safehasattr(inst, "args") and inst.args[0] == errno.EPIPE:
174 elif util.safehasattr(inst, "args") and inst.args[0] == errno.EPIPE:
175 if ui.debugflag:
175 if ui.debugflag:
176 ui.warn(_("broken pipe\n"))
176 ui.warn(_("broken pipe\n"))
177 elif getattr(inst, "strerror", None):
177 elif getattr(inst, "strerror", None):
178 if getattr(inst, "filename", None):
178 if getattr(inst, "filename", None):
179 ui.warn(_("abort: %s: %s\n") % (inst.strerror, inst.filename))
179 ui.warn(_("abort: %s: %s\n") % (inst.strerror, inst.filename))
180 else:
180 else:
181 ui.warn(_("abort: %s\n") % inst.strerror)
181 ui.warn(_("abort: %s\n") % inst.strerror)
182 else:
182 else:
183 raise
183 raise
184 except OSError, inst:
184 except OSError, inst:
185 if getattr(inst, "filename", None):
185 if getattr(inst, "filename", None):
186 ui.warn(_("abort: %s: %s\n") % (inst.strerror, inst.filename))
186 ui.warn(_("abort: %s: %s\n") % (inst.strerror, inst.filename))
187 else:
187 else:
188 ui.warn(_("abort: %s\n") % inst.strerror)
188 ui.warn(_("abort: %s\n") % inst.strerror)
189 except KeyboardInterrupt:
189 except KeyboardInterrupt:
190 try:
190 try:
191 ui.warn(_("interrupted!\n"))
191 ui.warn(_("interrupted!\n"))
192 except IOError, inst:
192 except IOError, inst:
193 if inst.errno == errno.EPIPE:
193 if inst.errno == errno.EPIPE:
194 if ui.debugflag:
194 if ui.debugflag:
195 ui.warn(_("\nbroken pipe\n"))
195 ui.warn(_("\nbroken pipe\n"))
196 else:
196 else:
197 raise
197 raise
198 except MemoryError:
198 except MemoryError:
199 ui.warn(_("abort: out of memory\n"))
199 ui.warn(_("abort: out of memory\n"))
200 except SystemExit, inst:
200 except SystemExit, inst:
201 # Commands shouldn't sys.exit directly, but give a return code.
201 # Commands shouldn't sys.exit directly, but give a return code.
202 # Just in case catch this and and pass exit code to caller.
202 # Just in case catch this and and pass exit code to caller.
203 return inst.code
203 return inst.code
204 except socket.error, inst:
204 except socket.error, inst:
205 ui.warn(_("abort: %s\n") % inst.args[-1])
205 ui.warn(_("abort: %s\n") % inst.args[-1])
206 except:
206 except:
207 ui.warn(_("** unknown exception encountered,"
207 ui.warn(_("** unknown exception encountered,"
208 " please report by visiting\n"))
208 " please report by visiting\n"))
209 ui.warn(_("** http://mercurial.selenic.com/wiki/BugTracker\n"))
209 ui.warn(_("** http://mercurial.selenic.com/wiki/BugTracker\n"))
210 ui.warn(_("** Python %s\n") % sys.version.replace('\n', ''))
210 ui.warn(_("** Python %s\n") % sys.version.replace('\n', ''))
211 ui.warn(_("** Mercurial Distributed SCM (version %s)\n")
211 ui.warn(_("** Mercurial Distributed SCM (version %s)\n")
212 % util.version())
212 % util.version())
213 ui.warn(_("** Extensions loaded: %s\n")
213 ui.warn(_("** Extensions loaded: %s\n")
214 % ", ".join([x[0] for x in extensions.extensions()]))
214 % ", ".join([x[0] for x in extensions.extensions()]))
215 raise
215 raise
216
216
217 return -1
217 return -1
218
218
219 def aliasargs(fn, givenargs):
219 def aliasargs(fn, givenargs):
220 args = getattr(fn, 'args', [])
220 args = getattr(fn, 'args', [])
221 if args and givenargs:
221 if args and givenargs:
222 cmd = ' '.join(map(util.shellquote, args))
222 cmd = ' '.join(map(util.shellquote, args))
223
223
224 nums = []
224 nums = []
225 def replacer(m):
225 def replacer(m):
226 num = int(m.group(1)) - 1
226 num = int(m.group(1)) - 1
227 nums.append(num)
227 nums.append(num)
228 return givenargs[num]
228 return givenargs[num]
229 cmd = re.sub(r'\$(\d+|\$)', replacer, cmd)
229 cmd = re.sub(r'\$(\d+|\$)', replacer, cmd)
230 givenargs = [x for i, x in enumerate(givenargs)
230 givenargs = [x for i, x in enumerate(givenargs)
231 if i not in nums]
231 if i not in nums]
232 args = shlex.split(cmd)
232 args = shlex.split(cmd)
233 return args + givenargs
233 return args + givenargs
234
234
235 class cmdalias(object):
235 class cmdalias(object):
236 def __init__(self, name, definition, cmdtable):
236 def __init__(self, name, definition, cmdtable):
237 self.name = self.cmd = name
237 self.name = self.cmd = name
238 self.cmdname = ''
238 self.cmdname = ''
239 self.definition = definition
239 self.definition = definition
240 self.args = []
240 self.args = []
241 self.opts = []
241 self.opts = []
242 self.help = ''
242 self.help = ''
243 self.norepo = True
243 self.norepo = True
244 self.badalias = False
244 self.badalias = False
245
245
246 try:
246 try:
247 aliases, entry = cmdutil.findcmd(self.name, cmdtable)
247 aliases, entry = cmdutil.findcmd(self.name, cmdtable)
248 for alias, e in cmdtable.iteritems():
248 for alias, e in cmdtable.iteritems():
249 if e is entry:
249 if e is entry:
250 self.cmd = alias
250 self.cmd = alias
251 break
251 break
252 self.shadows = True
252 self.shadows = True
253 except error.UnknownCommand:
253 except error.UnknownCommand:
254 self.shadows = False
254 self.shadows = False
255
255
256 if not self.definition:
256 if not self.definition:
257 def fn(ui, *args):
257 def fn(ui, *args):
258 ui.warn(_("no definition for alias '%s'\n") % self.name)
258 ui.warn(_("no definition for alias '%s'\n") % self.name)
259 return 1
259 return 1
260 self.fn = fn
260 self.fn = fn
261 self.badalias = True
261 self.badalias = True
262 return
262 return
263
263
264 if self.definition.startswith('!'):
264 if self.definition.startswith('!'):
265 self.shell = True
265 self.shell = True
266 def fn(ui, *args):
266 def fn(ui, *args):
267 env = {'HG_ARGS': ' '.join((self.name,) + args)}
267 env = {'HG_ARGS': ' '.join((self.name,) + args)}
268 def _checkvar(m):
268 def _checkvar(m):
269 if m.groups()[0] == '$':
269 if m.groups()[0] == '$':
270 return m.group()
270 return m.group()
271 elif int(m.groups()[0]) <= len(args):
271 elif int(m.groups()[0]) <= len(args):
272 return m.group()
272 return m.group()
273 else:
273 else:
274 ui.debug("No argument found for substitution "
274 ui.debug("No argument found for substitution "
275 "of %i variable in alias '%s' definition."
275 "of %i variable in alias '%s' definition."
276 % (int(m.groups()[0]), self.name))
276 % (int(m.groups()[0]), self.name))
277 return ''
277 return ''
278 cmd = re.sub(r'\$(\d+|\$)', _checkvar, self.definition[1:])
278 cmd = re.sub(r'\$(\d+|\$)', _checkvar, self.definition[1:])
279 replace = dict((str(i + 1), arg) for i, arg in enumerate(args))
279 replace = dict((str(i + 1), arg) for i, arg in enumerate(args))
280 replace['0'] = self.name
280 replace['0'] = self.name
281 replace['@'] = ' '.join(args)
281 replace['@'] = ' '.join(args)
282 cmd = util.interpolate(r'\$', replace, cmd, escape_prefix=True)
282 cmd = util.interpolate(r'\$', replace, cmd, escape_prefix=True)
283 return util.system(cmd, environ=env, out=ui.fout)
283 return util.system(cmd, environ=env, out=ui.fout)
284 self.fn = fn
284 self.fn = fn
285 return
285 return
286
286
287 args = shlex.split(self.definition)
287 args = shlex.split(self.definition)
288 self.cmdname = cmd = args.pop(0)
288 self.cmdname = cmd = args.pop(0)
289 args = map(util.expandpath, args)
289 args = map(util.expandpath, args)
290
290
291 for invalidarg in ("--cwd", "-R", "--repository", "--repo"):
291 for invalidarg in ("--cwd", "-R", "--repository", "--repo"):
292 if _earlygetopt([invalidarg], args):
292 if _earlygetopt([invalidarg], args):
293 def fn(ui, *args):
293 def fn(ui, *args):
294 ui.warn(_("error in definition for alias '%s': %s may only "
294 ui.warn(_("error in definition for alias '%s': %s may only "
295 "be given on the command line\n")
295 "be given on the command line\n")
296 % (self.name, invalidarg))
296 % (self.name, invalidarg))
297 return 1
297 return 1
298
298
299 self.fn = fn
299 self.fn = fn
300 self.badalias = True
300 self.badalias = True
301 return
301 return
302
302
303 try:
303 try:
304 tableentry = cmdutil.findcmd(cmd, cmdtable, False)[1]
304 tableentry = cmdutil.findcmd(cmd, cmdtable, False)[1]
305 if len(tableentry) > 2:
305 if len(tableentry) > 2:
306 self.fn, self.opts, self.help = tableentry
306 self.fn, self.opts, self.help = tableentry
307 else:
307 else:
308 self.fn, self.opts = tableentry
308 self.fn, self.opts = tableentry
309
309
310 self.args = aliasargs(self.fn, args)
310 self.args = aliasargs(self.fn, args)
311 if cmd not in commands.norepo.split(' '):
311 if cmd not in commands.norepo.split(' '):
312 self.norepo = False
312 self.norepo = False
313 if self.help.startswith("hg " + cmd):
313 if self.help.startswith("hg " + cmd):
314 # drop prefix in old-style help lines so hg shows the alias
314 # drop prefix in old-style help lines so hg shows the alias
315 self.help = self.help[4 + len(cmd):]
315 self.help = self.help[4 + len(cmd):]
316 self.__doc__ = self.fn.__doc__
316 self.__doc__ = self.fn.__doc__
317
317
318 except error.UnknownCommand:
318 except error.UnknownCommand:
319 def fn(ui, *args):
319 def fn(ui, *args):
320 ui.warn(_("alias '%s' resolves to unknown command '%s'\n") \
320 ui.warn(_("alias '%s' resolves to unknown command '%s'\n") \
321 % (self.name, cmd))
321 % (self.name, cmd))
322 try:
322 try:
323 # check if the command is in a disabled extension
323 # check if the command is in a disabled extension
324 commands.help_(ui, cmd, unknowncmd=True)
324 commands.help_(ui, cmd, unknowncmd=True)
325 except error.UnknownCommand:
325 except error.UnknownCommand:
326 pass
326 pass
327 return 1
327 return 1
328 self.fn = fn
328 self.fn = fn
329 self.badalias = True
329 self.badalias = True
330 except error.AmbiguousCommand:
330 except error.AmbiguousCommand:
331 def fn(ui, *args):
331 def fn(ui, *args):
332 ui.warn(_("alias '%s' resolves to ambiguous command '%s'\n") \
332 ui.warn(_("alias '%s' resolves to ambiguous command '%s'\n") \
333 % (self.name, cmd))
333 % (self.name, cmd))
334 return 1
334 return 1
335 self.fn = fn
335 self.fn = fn
336 self.badalias = True
336 self.badalias = True
337
337
338 def __call__(self, ui, *args, **opts):
338 def __call__(self, ui, *args, **opts):
339 if self.shadows:
339 if self.shadows:
340 ui.debug("alias '%s' shadows command '%s'\n" %
340 ui.debug("alias '%s' shadows command '%s'\n" %
341 (self.name, self.cmdname))
341 (self.name, self.cmdname))
342
342
343 if util.safehasattr(self, 'shell'):
343 if util.safehasattr(self, 'shell'):
344 return self.fn(ui, *args, **opts)
344 return self.fn(ui, *args, **opts)
345 else:
345 else:
346 try:
346 try:
347 util.checksignature(self.fn)(ui, *args, **opts)
347 util.checksignature(self.fn)(ui, *args, **opts)
348 except error.SignatureError:
348 except error.SignatureError:
349 args = ' '.join([self.cmdname] + self.args)
349 args = ' '.join([self.cmdname] + self.args)
350 ui.debug("alias '%s' expands to '%s'\n" % (self.name, args))
350 ui.debug("alias '%s' expands to '%s'\n" % (self.name, args))
351 raise
351 raise
352
352
353 def addaliases(ui, cmdtable):
353 def addaliases(ui, cmdtable):
354 # aliases are processed after extensions have been loaded, so they
354 # aliases are processed after extensions have been loaded, so they
355 # may use extension commands. Aliases can also use other alias definitions,
355 # may use extension commands. Aliases can also use other alias definitions,
356 # but only if they have been defined prior to the current definition.
356 # but only if they have been defined prior to the current definition.
357 for alias, definition in ui.configitems('alias'):
357 for alias, definition in ui.configitems('alias'):
358 aliasdef = cmdalias(alias, definition, cmdtable)
358 aliasdef = cmdalias(alias, definition, cmdtable)
359
359
360 try:
360 try:
361 olddef = cmdtable[aliasdef.cmd][0]
361 olddef = cmdtable[aliasdef.cmd][0]
362 if olddef.definition == aliasdef.definition:
362 if olddef.definition == aliasdef.definition:
363 continue
363 continue
364 except (KeyError, AttributeError):
364 except (KeyError, AttributeError):
365 # definition might not exist or it might not be a cmdalias
365 # definition might not exist or it might not be a cmdalias
366 pass
366 pass
367
367
368 cmdtable[aliasdef.name] = (aliasdef, aliasdef.opts, aliasdef.help)
368 cmdtable[aliasdef.name] = (aliasdef, aliasdef.opts, aliasdef.help)
369 if aliasdef.norepo:
369 if aliasdef.norepo:
370 commands.norepo += ' %s' % alias
370 commands.norepo += ' %s' % alias
371
371
372 def _parse(ui, args):
372 def _parse(ui, args):
373 options = {}
373 options = {}
374 cmdoptions = {}
374 cmdoptions = {}
375
375
376 try:
376 try:
377 args = fancyopts.fancyopts(args, commands.globalopts, options)
377 args = fancyopts.fancyopts(args, commands.globalopts, options)
378 except fancyopts.getopt.GetoptError, inst:
378 except fancyopts.getopt.GetoptError, inst:
379 raise error.CommandError(None, inst)
379 raise error.CommandError(None, inst)
380
380
381 if args:
381 if args:
382 cmd, args = args[0], args[1:]
382 cmd, args = args[0], args[1:]
383 aliases, entry = cmdutil.findcmd(cmd, commands.table,
383 aliases, entry = cmdutil.findcmd(cmd, commands.table,
384 ui.config("ui", "strict"))
384 ui.config("ui", "strict"))
385 cmd = aliases[0]
385 cmd = aliases[0]
386 args = aliasargs(entry[0], args)
386 args = aliasargs(entry[0], args)
387 defaults = ui.config("defaults", cmd)
387 defaults = ui.config("defaults", cmd)
388 if defaults:
388 if defaults:
389 args = map(util.expandpath, shlex.split(defaults)) + args
389 args = map(util.expandpath, shlex.split(defaults)) + args
390 c = list(entry[1])
390 c = list(entry[1])
391 else:
391 else:
392 cmd = None
392 cmd = None
393 c = []
393 c = []
394
394
395 # combine global options into local
395 # combine global options into local
396 for o in commands.globalopts:
396 for o in commands.globalopts:
397 c.append((o[0], o[1], options[o[1]], o[3]))
397 c.append((o[0], o[1], options[o[1]], o[3]))
398
398
399 try:
399 try:
400 args = fancyopts.fancyopts(args, c, cmdoptions, True)
400 args = fancyopts.fancyopts(args, c, cmdoptions, True)
401 except fancyopts.getopt.GetoptError, inst:
401 except fancyopts.getopt.GetoptError, inst:
402 raise error.CommandError(cmd, inst)
402 raise error.CommandError(cmd, inst)
403
403
404 # separate global options back out
404 # separate global options back out
405 for o in commands.globalopts:
405 for o in commands.globalopts:
406 n = o[1]
406 n = o[1]
407 options[n] = cmdoptions[n]
407 options[n] = cmdoptions[n]
408 del cmdoptions[n]
408 del cmdoptions[n]
409
409
410 return (cmd, cmd and entry[0] or None, args, options, cmdoptions)
410 return (cmd, cmd and entry[0] or None, args, options, cmdoptions)
411
411
412 def _parseconfig(ui, config):
412 def _parseconfig(ui, config):
413 """parse the --config options from the command line"""
413 """parse the --config options from the command line"""
414 configs = []
414 configs = []
415
415
416 for cfg in config:
416 for cfg in config:
417 try:
417 try:
418 name, value = cfg.split('=', 1)
418 name, value = cfg.split('=', 1)
419 section, name = name.split('.', 1)
419 section, name = name.split('.', 1)
420 if not section or not name:
420 if not section or not name:
421 raise IndexError
421 raise IndexError
422 ui.setconfig(section, name, value)
422 ui.setconfig(section, name, value)
423 configs.append((section, name, value))
423 configs.append((section, name, value))
424 except (IndexError, ValueError):
424 except (IndexError, ValueError):
425 raise util.Abort(_('malformed --config option: %r '
425 raise util.Abort(_('malformed --config option: %r '
426 '(use --config section.name=value)') % cfg)
426 '(use --config section.name=value)') % cfg)
427
427
428 return configs
428 return configs
429
429
430 def _earlygetopt(aliases, args):
430 def _earlygetopt(aliases, args):
431 """Return list of values for an option (or aliases).
431 """Return list of values for an option (or aliases).
432
432
433 The values are listed in the order they appear in args.
433 The values are listed in the order they appear in args.
434 The options and values are removed from args.
434 The options and values are removed from args.
435 """
435 """
436 try:
436 try:
437 argcount = args.index("--")
437 argcount = args.index("--")
438 except ValueError:
438 except ValueError:
439 argcount = len(args)
439 argcount = len(args)
440 shortopts = [opt for opt in aliases if len(opt) == 2]
440 shortopts = [opt for opt in aliases if len(opt) == 2]
441 values = []
441 values = []
442 pos = 0
442 pos = 0
443 while pos < argcount:
443 while pos < argcount:
444 if args[pos] in aliases:
444 if args[pos] in aliases:
445 if pos + 1 >= argcount:
445 if pos + 1 >= argcount:
446 # ignore and let getopt report an error if there is no value
446 # ignore and let getopt report an error if there is no value
447 break
447 break
448 del args[pos]
448 del args[pos]
449 values.append(args.pop(pos))
449 values.append(args.pop(pos))
450 argcount -= 2
450 argcount -= 2
451 elif args[pos][:2] in shortopts:
451 elif args[pos][:2] in shortopts:
452 # short option can have no following space, e.g. hg log -Rfoo
452 # short option can have no following space, e.g. hg log -Rfoo
453 values.append(args.pop(pos)[2:])
453 values.append(args.pop(pos)[2:])
454 argcount -= 1
454 argcount -= 1
455 else:
455 else:
456 pos += 1
456 pos += 1
457 return values
457 return values
458
458
459 def runcommand(lui, repo, cmd, fullargs, ui, options, d, cmdpats, cmdoptions):
459 def runcommand(lui, repo, cmd, fullargs, ui, options, d, cmdpats, cmdoptions):
460 # run pre-hook, and abort if it fails
460 # run pre-hook, and abort if it fails
461 ret = hook.hook(lui, repo, "pre-%s" % cmd, False, args=" ".join(fullargs),
461 ret = hook.hook(lui, repo, "pre-%s" % cmd, False, args=" ".join(fullargs),
462 pats=cmdpats, opts=cmdoptions)
462 pats=cmdpats, opts=cmdoptions)
463 if ret:
463 if ret:
464 return ret
464 return ret
465 ret = _runcommand(ui, options, cmd, d)
465 ret = _runcommand(ui, options, cmd, d)
466 # run post-hook, passing command result
466 # run post-hook, passing command result
467 hook.hook(lui, repo, "post-%s" % cmd, False, args=" ".join(fullargs),
467 hook.hook(lui, repo, "post-%s" % cmd, False, args=" ".join(fullargs),
468 result=ret, pats=cmdpats, opts=cmdoptions)
468 result=ret, pats=cmdpats, opts=cmdoptions)
469 return ret
469 return ret
470
470
471 def _getlocal(ui, rpath):
471 def _getlocal(ui, rpath):
472 """Return (path, local ui object) for the given target path.
472 """Return (path, local ui object) for the given target path.
473
473
474 Takes paths in [cwd]/.hg/hgrc into account."
474 Takes paths in [cwd]/.hg/hgrc into account."
475 """
475 """
476 try:
476 try:
477 wd = os.getcwd()
477 wd = os.getcwd()
478 except OSError, e:
478 except OSError, e:
479 raise util.Abort(_("error getting current working directory: %s") %
479 raise util.Abort(_("error getting current working directory: %s") %
480 e.strerror)
480 e.strerror)
481 path = cmdutil.findrepo(wd) or ""
481 path = cmdutil.findrepo(wd) or ""
482 if not path:
482 if not path:
483 lui = ui
483 lui = ui
484 else:
484 else:
485 lui = ui.copy()
485 lui = ui.copy()
486 lui.readconfig(os.path.join(path, ".hg", "hgrc"), path)
486 lui.readconfig(os.path.join(path, ".hg", "hgrc"), path)
487
487
488 if rpath and rpath[-1]:
488 if rpath and rpath[-1]:
489 path = lui.expandpath(rpath[-1])
489 path = lui.expandpath(rpath[-1])
490 lui = ui.copy()
490 lui = ui.copy()
491 lui.readconfig(os.path.join(path, ".hg", "hgrc"), path)
491 lui.readconfig(os.path.join(path, ".hg", "hgrc"), path)
492
492
493 return path, lui
493 return path, lui
494
494
495 def _checkshellalias(lui, ui, args):
495 def _checkshellalias(lui, ui, args):
496 norepo = commands.norepo
496 norepo = commands.norepo
497 options = {}
497 options = {}
498
498
499 try:
499 try:
500 args = fancyopts.fancyopts(args, commands.globalopts, options)
500 args = fancyopts.fancyopts(args, commands.globalopts, options)
501 except fancyopts.getopt.GetoptError:
501 except fancyopts.getopt.GetoptError:
502 return
502 return
503
503
504 if not args:
504 if not args:
505 return
505 return
506
506
507 cmdtable = commands.table.copy()
507 cmdtable = commands.table.copy()
508 addaliases(lui, cmdtable)
508 addaliases(lui, cmdtable)
509
509
510 cmd = args[0]
510 cmd = args[0]
511 try:
511 try:
512 aliases, entry = cmdutil.findcmd(cmd, cmdtable, lui.config("ui", "strict"))
512 aliases, entry = cmdutil.findcmd(cmd, cmdtable, lui.config("ui", "strict"))
513 except (error.AmbiguousCommand, error.UnknownCommand):
513 except (error.AmbiguousCommand, error.UnknownCommand):
514 commands.norepo = norepo
514 commands.norepo = norepo
515 return
515 return
516
516
517 cmd = aliases[0]
517 cmd = aliases[0]
518 fn = entry[0]
518 fn = entry[0]
519
519
520 if cmd and util.safehasattr(fn, 'shell'):
520 if cmd and util.safehasattr(fn, 'shell'):
521 d = lambda: fn(ui, *args[1:])
521 d = lambda: fn(ui, *args[1:])
522 return lambda: runcommand(lui, None, cmd, args[:1], ui, options, d, [], {})
522 return lambda: runcommand(lui, None, cmd, args[:1], ui, options, d, [], {})
523
523
524 commands.norepo = norepo
524 commands.norepo = norepo
525
525
526 _loaded = set()
526 _loaded = set()
527 def _dispatch(req):
527 def _dispatch(req):
528 args = req.args
528 args = req.args
529 ui = req.ui
529 ui = req.ui
530
530
531 # read --config before doing anything else
531 # read --config before doing anything else
532 # (e.g. to change trust settings for reading .hg/hgrc)
532 # (e.g. to change trust settings for reading .hg/hgrc)
533 cfgs = _parseconfig(ui, _earlygetopt(['--config'], args))
533 cfgs = _parseconfig(ui, _earlygetopt(['--config'], args))
534
534
535 # check for cwd
535 # check for cwd
536 cwd = _earlygetopt(['--cwd'], args)
536 cwd = _earlygetopt(['--cwd'], args)
537 if cwd:
537 if cwd:
538 os.chdir(cwd[-1])
538 os.chdir(cwd[-1])
539
539
540 rpath = _earlygetopt(["-R", "--repository", "--repo"], args)
540 rpath = _earlygetopt(["-R", "--repository", "--repo"], args)
541 path, lui = _getlocal(ui, rpath)
541 path, lui = _getlocal(ui, rpath)
542
542
543 # Now that we're operating in the right directory/repository with
543 # Now that we're operating in the right directory/repository with
544 # the right config settings, check for shell aliases
544 # the right config settings, check for shell aliases
545 shellaliasfn = _checkshellalias(lui, ui, args)
545 shellaliasfn = _checkshellalias(lui, ui, args)
546 if shellaliasfn:
546 if shellaliasfn:
547 return shellaliasfn()
547 return shellaliasfn()
548
548
549 # Configure extensions in phases: uisetup, extsetup, cmdtable, and
549 # Configure extensions in phases: uisetup, extsetup, cmdtable, and
550 # reposetup. Programs like TortoiseHg will call _dispatch several
550 # reposetup. Programs like TortoiseHg will call _dispatch several
551 # times so we keep track of configured extensions in _loaded.
551 # times so we keep track of configured extensions in _loaded.
552 extensions.loadall(lui)
552 extensions.loadall(lui)
553 exts = [ext for ext in extensions.extensions() if ext[0] not in _loaded]
553 exts = [ext for ext in extensions.extensions() if ext[0] not in _loaded]
554 # Propagate any changes to lui.__class__ by extensions
554 # Propagate any changes to lui.__class__ by extensions
555 ui.__class__ = lui.__class__
555 ui.__class__ = lui.__class__
556
556
557 # (uisetup and extsetup are handled in extensions.loadall)
557 # (uisetup and extsetup are handled in extensions.loadall)
558
558
559 for name, module in exts:
559 for name, module in exts:
560 cmdtable = getattr(module, 'cmdtable', {})
560 cmdtable = getattr(module, 'cmdtable', {})
561 overrides = [cmd for cmd in cmdtable if cmd in commands.table]
561 overrides = [cmd for cmd in cmdtable if cmd in commands.table]
562 if overrides:
562 if overrides:
563 ui.warn(_("extension '%s' overrides commands: %s\n")
563 ui.warn(_("extension '%s' overrides commands: %s\n")
564 % (name, " ".join(overrides)))
564 % (name, " ".join(overrides)))
565 commands.table.update(cmdtable)
565 commands.table.update(cmdtable)
566 _loaded.add(name)
566 _loaded.add(name)
567
567
568 # (reposetup is handled in hg.repository)
568 # (reposetup is handled in hg.repository)
569
569
570 addaliases(lui, commands.table)
570 addaliases(lui, commands.table)
571
571
572 # check for fallback encoding
572 # check for fallback encoding
573 fallback = lui.config('ui', 'fallbackencoding')
573 fallback = lui.config('ui', 'fallbackencoding')
574 if fallback:
574 if fallback:
575 encoding.fallbackencoding = fallback
575 encoding.fallbackencoding = fallback
576
576
577 fullargs = args
577 fullargs = args
578 cmd, func, args, options, cmdoptions = _parse(lui, args)
578 cmd, func, args, options, cmdoptions = _parse(lui, args)
579
579
580 if options["config"]:
580 if options["config"]:
581 raise util.Abort(_("option --config may not be abbreviated!"))
581 raise util.Abort(_("option --config may not be abbreviated!"))
582 if options["cwd"]:
582 if options["cwd"]:
583 raise util.Abort(_("option --cwd may not be abbreviated!"))
583 raise util.Abort(_("option --cwd may not be abbreviated!"))
584 if options["repository"]:
584 if options["repository"]:
585 raise util.Abort(_(
585 raise util.Abort(_(
586 "Option -R has to be separated from other options (e.g. not -qR) "
586 "option -R has to be separated from other options (e.g. not -qR) "
587 "and --repository may only be abbreviated as --repo!"))
587 "and --repository may only be abbreviated as --repo!"))
588
588
589 if options["encoding"]:
589 if options["encoding"]:
590 encoding.encoding = options["encoding"]
590 encoding.encoding = options["encoding"]
591 if options["encodingmode"]:
591 if options["encodingmode"]:
592 encoding.encodingmode = options["encodingmode"]
592 encoding.encodingmode = options["encodingmode"]
593 if options["time"]:
593 if options["time"]:
594 def get_times():
594 def get_times():
595 t = os.times()
595 t = os.times()
596 if t[4] == 0.0: # Windows leaves this as zero, so use time.clock()
596 if t[4] == 0.0: # Windows leaves this as zero, so use time.clock()
597 t = (t[0], t[1], t[2], t[3], time.clock())
597 t = (t[0], t[1], t[2], t[3], time.clock())
598 return t
598 return t
599 s = get_times()
599 s = get_times()
600 def print_time():
600 def print_time():
601 t = get_times()
601 t = get_times()
602 ui.warn(_("Time: real %.3f secs (user %.3f+%.3f sys %.3f+%.3f)\n") %
602 ui.warn(_("Time: real %.3f secs (user %.3f+%.3f sys %.3f+%.3f)\n") %
603 (t[4]-s[4], t[0]-s[0], t[2]-s[2], t[1]-s[1], t[3]-s[3]))
603 (t[4]-s[4], t[0]-s[0], t[2]-s[2], t[1]-s[1], t[3]-s[3]))
604 atexit.register(print_time)
604 atexit.register(print_time)
605
605
606 uis = set([ui, lui])
606 uis = set([ui, lui])
607
607
608 if req.repo:
608 if req.repo:
609 uis.add(req.repo.ui)
609 uis.add(req.repo.ui)
610
610
611 # copy configs that were passed on the cmdline (--config) to the repo ui
611 # copy configs that were passed on the cmdline (--config) to the repo ui
612 for cfg in cfgs:
612 for cfg in cfgs:
613 req.repo.ui.setconfig(*cfg)
613 req.repo.ui.setconfig(*cfg)
614
614
615 if options['verbose'] or options['debug'] or options['quiet']:
615 if options['verbose'] or options['debug'] or options['quiet']:
616 for opt in ('verbose', 'debug', 'quiet'):
616 for opt in ('verbose', 'debug', 'quiet'):
617 val = str(bool(options[opt]))
617 val = str(bool(options[opt]))
618 for ui_ in uis:
618 for ui_ in uis:
619 ui_.setconfig('ui', opt, val)
619 ui_.setconfig('ui', opt, val)
620
620
621 if options['traceback']:
621 if options['traceback']:
622 for ui_ in uis:
622 for ui_ in uis:
623 ui_.setconfig('ui', 'traceback', 'on')
623 ui_.setconfig('ui', 'traceback', 'on')
624
624
625 if options['noninteractive']:
625 if options['noninteractive']:
626 for ui_ in uis:
626 for ui_ in uis:
627 ui_.setconfig('ui', 'interactive', 'off')
627 ui_.setconfig('ui', 'interactive', 'off')
628
628
629 if cmdoptions.get('insecure', False):
629 if cmdoptions.get('insecure', False):
630 for ui_ in uis:
630 for ui_ in uis:
631 ui_.setconfig('web', 'cacerts', '')
631 ui_.setconfig('web', 'cacerts', '')
632
632
633 if options['version']:
633 if options['version']:
634 return commands.version_(ui)
634 return commands.version_(ui)
635 if options['help']:
635 if options['help']:
636 return commands.help_(ui, cmd)
636 return commands.help_(ui, cmd)
637 elif not cmd:
637 elif not cmd:
638 return commands.help_(ui, 'shortlist')
638 return commands.help_(ui, 'shortlist')
639
639
640 repo = None
640 repo = None
641 cmdpats = args[:]
641 cmdpats = args[:]
642 if cmd not in commands.norepo.split():
642 if cmd not in commands.norepo.split():
643 # use the repo from the request only if we don't have -R
643 # use the repo from the request only if we don't have -R
644 if not rpath and not cwd:
644 if not rpath and not cwd:
645 repo = req.repo
645 repo = req.repo
646
646
647 if repo:
647 if repo:
648 # set the descriptors of the repo ui to those of ui
648 # set the descriptors of the repo ui to those of ui
649 repo.ui.fin = ui.fin
649 repo.ui.fin = ui.fin
650 repo.ui.fout = ui.fout
650 repo.ui.fout = ui.fout
651 repo.ui.ferr = ui.ferr
651 repo.ui.ferr = ui.ferr
652 else:
652 else:
653 try:
653 try:
654 repo = hg.repository(ui, path=path)
654 repo = hg.repository(ui, path=path)
655 if not repo.local():
655 if not repo.local():
656 raise util.Abort(_("repository '%s' is not local") % path)
656 raise util.Abort(_("repository '%s' is not local") % path)
657 repo.ui.setconfig("bundle", "mainreporoot", repo.root)
657 repo.ui.setconfig("bundle", "mainreporoot", repo.root)
658 except error.RequirementError:
658 except error.RequirementError:
659 raise
659 raise
660 except error.RepoError:
660 except error.RepoError:
661 if cmd not in commands.optionalrepo.split():
661 if cmd not in commands.optionalrepo.split():
662 if args and not path: # try to infer -R from command args
662 if args and not path: # try to infer -R from command args
663 repos = map(cmdutil.findrepo, args)
663 repos = map(cmdutil.findrepo, args)
664 guess = repos[0]
664 guess = repos[0]
665 if guess and repos.count(guess) == len(repos):
665 if guess and repos.count(guess) == len(repos):
666 req.args = ['--repository', guess] + fullargs
666 req.args = ['--repository', guess] + fullargs
667 return _dispatch(req)
667 return _dispatch(req)
668 if not path:
668 if not path:
669 raise error.RepoError(_("no repository found in '%s'"
669 raise error.RepoError(_("no repository found in '%s'"
670 " (.hg not found)") % os.getcwd())
670 " (.hg not found)") % os.getcwd())
671 raise
671 raise
672 if repo:
672 if repo:
673 ui = repo.ui
673 ui = repo.ui
674 args.insert(0, repo)
674 args.insert(0, repo)
675 elif rpath:
675 elif rpath:
676 ui.warn(_("warning: --repository ignored\n"))
676 ui.warn(_("warning: --repository ignored\n"))
677
677
678 msg = ' '.join(' ' in a and repr(a) or a for a in fullargs)
678 msg = ' '.join(' ' in a and repr(a) or a for a in fullargs)
679 ui.log("command", msg + "\n")
679 ui.log("command", msg + "\n")
680 d = lambda: util.checksignature(func)(ui, *args, **cmdoptions)
680 d = lambda: util.checksignature(func)(ui, *args, **cmdoptions)
681 try:
681 try:
682 return runcommand(lui, repo, cmd, fullargs, ui, options, d,
682 return runcommand(lui, repo, cmd, fullargs, ui, options, d,
683 cmdpats, cmdoptions)
683 cmdpats, cmdoptions)
684 finally:
684 finally:
685 if repo and repo != req.repo:
685 if repo and repo != req.repo:
686 repo.close()
686 repo.close()
687
687
688 def _runcommand(ui, options, cmd, cmdfunc):
688 def _runcommand(ui, options, cmd, cmdfunc):
689 def checkargs():
689 def checkargs():
690 try:
690 try:
691 return cmdfunc()
691 return cmdfunc()
692 except error.SignatureError:
692 except error.SignatureError:
693 raise error.CommandError(cmd, _("invalid arguments"))
693 raise error.CommandError(cmd, _("invalid arguments"))
694
694
695 if options['profile']:
695 if options['profile']:
696 format = ui.config('profiling', 'format', default='text')
696 format = ui.config('profiling', 'format', default='text')
697
697
698 if not format in ['text', 'kcachegrind']:
698 if not format in ['text', 'kcachegrind']:
699 ui.warn(_("unrecognized profiling format '%s'"
699 ui.warn(_("unrecognized profiling format '%s'"
700 " - Ignored\n") % format)
700 " - Ignored\n") % format)
701 format = 'text'
701 format = 'text'
702
702
703 output = ui.config('profiling', 'output')
703 output = ui.config('profiling', 'output')
704
704
705 if output:
705 if output:
706 path = ui.expandpath(output)
706 path = ui.expandpath(output)
707 ostream = open(path, 'wb')
707 ostream = open(path, 'wb')
708 else:
708 else:
709 ostream = sys.stderr
709 ostream = sys.stderr
710
710
711 try:
711 try:
712 from mercurial import lsprof
712 from mercurial import lsprof
713 except ImportError:
713 except ImportError:
714 raise util.Abort(_(
714 raise util.Abort(_(
715 'lsprof not available - install from '
715 'lsprof not available - install from '
716 'http://codespeak.net/svn/user/arigo/hack/misc/lsprof/'))
716 'http://codespeak.net/svn/user/arigo/hack/misc/lsprof/'))
717 p = lsprof.Profiler()
717 p = lsprof.Profiler()
718 p.enable(subcalls=True)
718 p.enable(subcalls=True)
719 try:
719 try:
720 return checkargs()
720 return checkargs()
721 finally:
721 finally:
722 p.disable()
722 p.disable()
723
723
724 if format == 'kcachegrind':
724 if format == 'kcachegrind':
725 import lsprofcalltree
725 import lsprofcalltree
726 calltree = lsprofcalltree.KCacheGrind(p)
726 calltree = lsprofcalltree.KCacheGrind(p)
727 calltree.output(ostream)
727 calltree.output(ostream)
728 else:
728 else:
729 # format == 'text'
729 # format == 'text'
730 stats = lsprof.Stats(p.getstats())
730 stats = lsprof.Stats(p.getstats())
731 stats.sort()
731 stats.sort()
732 stats.pprint(top=10, file=ostream, climit=5)
732 stats.pprint(top=10, file=ostream, climit=5)
733
733
734 if output:
734 if output:
735 ostream.close()
735 ostream.close()
736 else:
736 else:
737 return checkargs()
737 return checkargs()
@@ -1,440 +1,440
1 $ "$TESTDIR/hghave" no-outer-repo || exit 80
1 $ "$TESTDIR/hghave" no-outer-repo || exit 80
2
2
3 $ hg init a
3 $ hg init a
4 $ cd a
4 $ cd a
5 $ echo a > a
5 $ echo a > a
6 $ hg ci -A -d'1 0' -m a
6 $ hg ci -A -d'1 0' -m a
7 adding a
7 adding a
8
8
9 $ cd ..
9 $ cd ..
10
10
11 $ hg init b
11 $ hg init b
12 $ cd b
12 $ cd b
13 $ echo b > b
13 $ echo b > b
14 $ hg ci -A -d'1 0' -m b
14 $ hg ci -A -d'1 0' -m b
15 adding b
15 adding b
16
16
17 $ cd ..
17 $ cd ..
18
18
19 $ hg clone a c
19 $ hg clone a c
20 updating to branch default
20 updating to branch default
21 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
21 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
22 $ cd c
22 $ cd c
23 $ cat >> .hg/hgrc <<EOF
23 $ cat >> .hg/hgrc <<EOF
24 > [paths]
24 > [paths]
25 > relative = ../a
25 > relative = ../a
26 > EOF
26 > EOF
27 $ hg pull -f ../b
27 $ hg pull -f ../b
28 pulling from ../b
28 pulling from ../b
29 searching for changes
29 searching for changes
30 warning: repository is unrelated
30 warning: repository is unrelated
31 requesting all changes
31 requesting all changes
32 adding changesets
32 adding changesets
33 adding manifests
33 adding manifests
34 adding file changes
34 adding file changes
35 added 1 changesets with 1 changes to 1 files (+1 heads)
35 added 1 changesets with 1 changes to 1 files (+1 heads)
36 (run 'hg heads' to see heads, 'hg merge' to merge)
36 (run 'hg heads' to see heads, 'hg merge' to merge)
37 $ hg merge
37 $ hg merge
38 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
38 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
39 (branch merge, don't forget to commit)
39 (branch merge, don't forget to commit)
40
40
41 $ cd ..
41 $ cd ..
42
42
43 Testing -R/--repository:
43 Testing -R/--repository:
44
44
45 $ hg -R a tip
45 $ hg -R a tip
46 changeset: 0:8580ff50825a
46 changeset: 0:8580ff50825a
47 tag: tip
47 tag: tip
48 user: test
48 user: test
49 date: Thu Jan 01 00:00:01 1970 +0000
49 date: Thu Jan 01 00:00:01 1970 +0000
50 summary: a
50 summary: a
51
51
52 $ hg --repository b tip
52 $ hg --repository b tip
53 changeset: 0:b6c483daf290
53 changeset: 0:b6c483daf290
54 tag: tip
54 tag: tip
55 user: test
55 user: test
56 date: Thu Jan 01 00:00:01 1970 +0000
56 date: Thu Jan 01 00:00:01 1970 +0000
57 summary: b
57 summary: b
58
58
59
59
60 -R with a URL:
60 -R with a URL:
61
61
62 $ hg -R file:a identify
62 $ hg -R file:a identify
63 8580ff50825a tip
63 8580ff50825a tip
64 $ hg -R file://localhost/`pwd`/a/ identify
64 $ hg -R file://localhost/`pwd`/a/ identify
65 8580ff50825a tip
65 8580ff50825a tip
66
66
67 -R with path aliases:
67 -R with path aliases:
68
68
69 $ cd c
69 $ cd c
70 $ hg -R default identify
70 $ hg -R default identify
71 8580ff50825a tip
71 8580ff50825a tip
72 $ hg -R relative identify
72 $ hg -R relative identify
73 8580ff50825a tip
73 8580ff50825a tip
74 $ echo '[paths]' >> $HGRCPATH
74 $ echo '[paths]' >> $HGRCPATH
75 $ echo 'relativetohome = a' >> $HGRCPATH
75 $ echo 'relativetohome = a' >> $HGRCPATH
76 $ HOME=`pwd`/../ hg -R relativetohome identify
76 $ HOME=`pwd`/../ hg -R relativetohome identify
77 8580ff50825a tip
77 8580ff50825a tip
78 $ cd ..
78 $ cd ..
79
79
80 Implicit -R:
80 Implicit -R:
81
81
82 $ hg ann a/a
82 $ hg ann a/a
83 0: a
83 0: a
84 $ hg ann a/a a/a
84 $ hg ann a/a a/a
85 0: a
85 0: a
86 $ hg ann a/a b/b
86 $ hg ann a/a b/b
87 abort: no repository found in '$TESTTMP' (.hg not found)!
87 abort: no repository found in '$TESTTMP' (.hg not found)!
88 [255]
88 [255]
89 $ hg -R b ann a/a
89 $ hg -R b ann a/a
90 abort: a/a not under root
90 abort: a/a not under root
91 [255]
91 [255]
92 $ hg log
92 $ hg log
93 abort: no repository found in '$TESTTMP' (.hg not found)!
93 abort: no repository found in '$TESTTMP' (.hg not found)!
94 [255]
94 [255]
95
95
96 Abbreviation of long option:
96 Abbreviation of long option:
97
97
98 $ hg --repo c tip
98 $ hg --repo c tip
99 changeset: 1:b6c483daf290
99 changeset: 1:b6c483daf290
100 tag: tip
100 tag: tip
101 parent: -1:000000000000
101 parent: -1:000000000000
102 user: test
102 user: test
103 date: Thu Jan 01 00:00:01 1970 +0000
103 date: Thu Jan 01 00:00:01 1970 +0000
104 summary: b
104 summary: b
105
105
106
106
107 earlygetopt with duplicate options (36d23de02da1):
107 earlygetopt with duplicate options (36d23de02da1):
108
108
109 $ hg --cwd a --cwd b --cwd c tip
109 $ hg --cwd a --cwd b --cwd c tip
110 changeset: 1:b6c483daf290
110 changeset: 1:b6c483daf290
111 tag: tip
111 tag: tip
112 parent: -1:000000000000
112 parent: -1:000000000000
113 user: test
113 user: test
114 date: Thu Jan 01 00:00:01 1970 +0000
114 date: Thu Jan 01 00:00:01 1970 +0000
115 summary: b
115 summary: b
116
116
117 $ hg --repo c --repository b -R a tip
117 $ hg --repo c --repository b -R a tip
118 changeset: 0:8580ff50825a
118 changeset: 0:8580ff50825a
119 tag: tip
119 tag: tip
120 user: test
120 user: test
121 date: Thu Jan 01 00:00:01 1970 +0000
121 date: Thu Jan 01 00:00:01 1970 +0000
122 summary: a
122 summary: a
123
123
124
124
125 earlygetopt short option without following space:
125 earlygetopt short option without following space:
126
126
127 $ hg -q -Rb tip
127 $ hg -q -Rb tip
128 0:b6c483daf290
128 0:b6c483daf290
129
129
130 earlygetopt with illegal abbreviations:
130 earlygetopt with illegal abbreviations:
131
131
132 $ hg --confi "foo.bar=baz"
132 $ hg --confi "foo.bar=baz"
133 abort: option --config may not be abbreviated!
133 abort: option --config may not be abbreviated!
134 [255]
134 [255]
135 $ hg --cw a tip
135 $ hg --cw a tip
136 abort: option --cwd may not be abbreviated!
136 abort: option --cwd may not be abbreviated!
137 [255]
137 [255]
138 $ hg --rep a tip
138 $ hg --rep a tip
139 abort: Option -R has to be separated from other options (e.g. not -qR) and --repository may only be abbreviated as --repo!
139 abort: option -R has to be separated from other options (e.g. not -qR) and --repository may only be abbreviated as --repo!
140 [255]
140 [255]
141 $ hg --repositor a tip
141 $ hg --repositor a tip
142 abort: Option -R has to be separated from other options (e.g. not -qR) and --repository may only be abbreviated as --repo!
142 abort: option -R has to be separated from other options (e.g. not -qR) and --repository may only be abbreviated as --repo!
143 [255]
143 [255]
144 $ hg -qR a tip
144 $ hg -qR a tip
145 abort: Option -R has to be separated from other options (e.g. not -qR) and --repository may only be abbreviated as --repo!
145 abort: option -R has to be separated from other options (e.g. not -qR) and --repository may only be abbreviated as --repo!
146 [255]
146 [255]
147 $ hg -qRa tip
147 $ hg -qRa tip
148 abort: Option -R has to be separated from other options (e.g. not -qR) and --repository may only be abbreviated as --repo!
148 abort: option -R has to be separated from other options (e.g. not -qR) and --repository may only be abbreviated as --repo!
149 [255]
149 [255]
150
150
151 Testing --cwd:
151 Testing --cwd:
152
152
153 $ hg --cwd a parents
153 $ hg --cwd a parents
154 changeset: 0:8580ff50825a
154 changeset: 0:8580ff50825a
155 tag: tip
155 tag: tip
156 user: test
156 user: test
157 date: Thu Jan 01 00:00:01 1970 +0000
157 date: Thu Jan 01 00:00:01 1970 +0000
158 summary: a
158 summary: a
159
159
160
160
161 Testing -y/--noninteractive - just be sure it is parsed:
161 Testing -y/--noninteractive - just be sure it is parsed:
162
162
163 $ hg --cwd a tip -q --noninteractive
163 $ hg --cwd a tip -q --noninteractive
164 0:8580ff50825a
164 0:8580ff50825a
165 $ hg --cwd a tip -q -y
165 $ hg --cwd a tip -q -y
166 0:8580ff50825a
166 0:8580ff50825a
167
167
168 Testing -q/--quiet:
168 Testing -q/--quiet:
169
169
170 $ hg -R a -q tip
170 $ hg -R a -q tip
171 0:8580ff50825a
171 0:8580ff50825a
172 $ hg -R b -q tip
172 $ hg -R b -q tip
173 0:b6c483daf290
173 0:b6c483daf290
174 $ hg -R c --quiet parents
174 $ hg -R c --quiet parents
175 0:8580ff50825a
175 0:8580ff50825a
176 1:b6c483daf290
176 1:b6c483daf290
177
177
178 Testing -v/--verbose:
178 Testing -v/--verbose:
179
179
180 $ hg --cwd c head -v
180 $ hg --cwd c head -v
181 changeset: 1:b6c483daf290
181 changeset: 1:b6c483daf290
182 tag: tip
182 tag: tip
183 parent: -1:000000000000
183 parent: -1:000000000000
184 user: test
184 user: test
185 date: Thu Jan 01 00:00:01 1970 +0000
185 date: Thu Jan 01 00:00:01 1970 +0000
186 files: b
186 files: b
187 description:
187 description:
188 b
188 b
189
189
190
190
191 changeset: 0:8580ff50825a
191 changeset: 0:8580ff50825a
192 user: test
192 user: test
193 date: Thu Jan 01 00:00:01 1970 +0000
193 date: Thu Jan 01 00:00:01 1970 +0000
194 files: a
194 files: a
195 description:
195 description:
196 a
196 a
197
197
198
198
199 $ hg --cwd b tip --verbose
199 $ hg --cwd b tip --verbose
200 changeset: 0:b6c483daf290
200 changeset: 0:b6c483daf290
201 tag: tip
201 tag: tip
202 user: test
202 user: test
203 date: Thu Jan 01 00:00:01 1970 +0000
203 date: Thu Jan 01 00:00:01 1970 +0000
204 files: b
204 files: b
205 description:
205 description:
206 b
206 b
207
207
208
208
209
209
210 Testing --config:
210 Testing --config:
211
211
212 $ hg --cwd c --config paths.quuxfoo=bar paths | grep quuxfoo > /dev/null && echo quuxfoo
212 $ hg --cwd c --config paths.quuxfoo=bar paths | grep quuxfoo > /dev/null && echo quuxfoo
213 quuxfoo
213 quuxfoo
214 $ hg --cwd c --config '' tip -q
214 $ hg --cwd c --config '' tip -q
215 abort: malformed --config option: '' (use --config section.name=value)
215 abort: malformed --config option: '' (use --config section.name=value)
216 [255]
216 [255]
217 $ hg --cwd c --config a.b tip -q
217 $ hg --cwd c --config a.b tip -q
218 abort: malformed --config option: 'a.b' (use --config section.name=value)
218 abort: malformed --config option: 'a.b' (use --config section.name=value)
219 [255]
219 [255]
220 $ hg --cwd c --config a tip -q
220 $ hg --cwd c --config a tip -q
221 abort: malformed --config option: 'a' (use --config section.name=value)
221 abort: malformed --config option: 'a' (use --config section.name=value)
222 [255]
222 [255]
223 $ hg --cwd c --config a.= tip -q
223 $ hg --cwd c --config a.= tip -q
224 abort: malformed --config option: 'a.=' (use --config section.name=value)
224 abort: malformed --config option: 'a.=' (use --config section.name=value)
225 [255]
225 [255]
226 $ hg --cwd c --config .b= tip -q
226 $ hg --cwd c --config .b= tip -q
227 abort: malformed --config option: '.b=' (use --config section.name=value)
227 abort: malformed --config option: '.b=' (use --config section.name=value)
228 [255]
228 [255]
229
229
230 Testing --debug:
230 Testing --debug:
231
231
232 $ hg --cwd c log --debug
232 $ hg --cwd c log --debug
233 changeset: 1:b6c483daf2907ce5825c0bb50f5716226281cc1a
233 changeset: 1:b6c483daf2907ce5825c0bb50f5716226281cc1a
234 tag: tip
234 tag: tip
235 parent: -1:0000000000000000000000000000000000000000
235 parent: -1:0000000000000000000000000000000000000000
236 parent: -1:0000000000000000000000000000000000000000
236 parent: -1:0000000000000000000000000000000000000000
237 manifest: 1:23226e7a252cacdc2d99e4fbdc3653441056de49
237 manifest: 1:23226e7a252cacdc2d99e4fbdc3653441056de49
238 user: test
238 user: test
239 date: Thu Jan 01 00:00:01 1970 +0000
239 date: Thu Jan 01 00:00:01 1970 +0000
240 files+: b
240 files+: b
241 extra: branch=default
241 extra: branch=default
242 description:
242 description:
243 b
243 b
244
244
245
245
246 changeset: 0:8580ff50825a50c8f716709acdf8de0deddcd6ab
246 changeset: 0:8580ff50825a50c8f716709acdf8de0deddcd6ab
247 parent: -1:0000000000000000000000000000000000000000
247 parent: -1:0000000000000000000000000000000000000000
248 parent: -1:0000000000000000000000000000000000000000
248 parent: -1:0000000000000000000000000000000000000000
249 manifest: 0:a0c8bcbbb45c63b90b70ad007bf38961f64f2af0
249 manifest: 0:a0c8bcbbb45c63b90b70ad007bf38961f64f2af0
250 user: test
250 user: test
251 date: Thu Jan 01 00:00:01 1970 +0000
251 date: Thu Jan 01 00:00:01 1970 +0000
252 files+: a
252 files+: a
253 extra: branch=default
253 extra: branch=default
254 description:
254 description:
255 a
255 a
256
256
257
257
258
258
259 Testing --traceback:
259 Testing --traceback:
260
260
261 $ hg --cwd c --config x --traceback id 2>&1 | grep -i 'traceback'
261 $ hg --cwd c --config x --traceback id 2>&1 | grep -i 'traceback'
262 Traceback (most recent call last):
262 Traceback (most recent call last):
263
263
264 Testing --time:
264 Testing --time:
265
265
266 $ hg --cwd a --time id
266 $ hg --cwd a --time id
267 8580ff50825a tip
267 8580ff50825a tip
268 Time: real * (glob)
268 Time: real * (glob)
269
269
270 Testing --version:
270 Testing --version:
271
271
272 $ hg --version -q
272 $ hg --version -q
273 Mercurial Distributed SCM * (glob)
273 Mercurial Distributed SCM * (glob)
274
274
275 Testing -h/--help:
275 Testing -h/--help:
276
276
277 $ hg -h
277 $ hg -h
278 Mercurial Distributed SCM
278 Mercurial Distributed SCM
279
279
280 list of commands:
280 list of commands:
281
281
282 add add the specified files on the next commit
282 add add the specified files on the next commit
283 addremove add all new files, delete all missing files
283 addremove add all new files, delete all missing files
284 annotate show changeset information by line for each file
284 annotate show changeset information by line for each file
285 archive create an unversioned archive of a repository revision
285 archive create an unversioned archive of a repository revision
286 backout reverse effect of earlier changeset
286 backout reverse effect of earlier changeset
287 bisect subdivision search of changesets
287 bisect subdivision search of changesets
288 bookmarks track a line of development with movable markers
288 bookmarks track a line of development with movable markers
289 branch set or show the current branch name
289 branch set or show the current branch name
290 branches list repository named branches
290 branches list repository named branches
291 bundle create a changegroup file
291 bundle create a changegroup file
292 cat output the current or given revision of files
292 cat output the current or given revision of files
293 clone make a copy of an existing repository
293 clone make a copy of an existing repository
294 commit commit the specified files or all outstanding changes
294 commit commit the specified files or all outstanding changes
295 copy mark files as copied for the next commit
295 copy mark files as copied for the next commit
296 diff diff repository (or selected files)
296 diff diff repository (or selected files)
297 export dump the header and diffs for one or more changesets
297 export dump the header and diffs for one or more changesets
298 forget forget the specified files on the next commit
298 forget forget the specified files on the next commit
299 graft copy changes from other branches onto the current branch
299 graft copy changes from other branches onto the current branch
300 grep search for a pattern in specified files and revisions
300 grep search for a pattern in specified files and revisions
301 heads show current repository heads or show branch heads
301 heads show current repository heads or show branch heads
302 help show help for a given topic or a help overview
302 help show help for a given topic or a help overview
303 identify identify the working copy or specified revision
303 identify identify the working copy or specified revision
304 import import an ordered set of patches
304 import import an ordered set of patches
305 incoming show new changesets found in source
305 incoming show new changesets found in source
306 init create a new repository in the given directory
306 init create a new repository in the given directory
307 locate locate files matching specific patterns
307 locate locate files matching specific patterns
308 log show revision history of entire repository or files
308 log show revision history of entire repository or files
309 manifest output the current or given revision of the project manifest
309 manifest output the current or given revision of the project manifest
310 merge merge working directory with another revision
310 merge merge working directory with another revision
311 outgoing show changesets not found in the destination
311 outgoing show changesets not found in the destination
312 parents show the parents of the working directory or revision
312 parents show the parents of the working directory or revision
313 paths show aliases for remote repositories
313 paths show aliases for remote repositories
314 pull pull changes from the specified source
314 pull pull changes from the specified source
315 push push changes to the specified destination
315 push push changes to the specified destination
316 recover roll back an interrupted transaction
316 recover roll back an interrupted transaction
317 remove remove the specified files on the next commit
317 remove remove the specified files on the next commit
318 rename rename files; equivalent of copy + remove
318 rename rename files; equivalent of copy + remove
319 resolve redo merges or set/view the merge status of files
319 resolve redo merges or set/view the merge status of files
320 revert restore files to their checkout state
320 revert restore files to their checkout state
321 rollback roll back the last transaction (dangerous)
321 rollback roll back the last transaction (dangerous)
322 root print the root (top) of the current working directory
322 root print the root (top) of the current working directory
323 serve start stand-alone webserver
323 serve start stand-alone webserver
324 showconfig show combined config settings from all hgrc files
324 showconfig show combined config settings from all hgrc files
325 status show changed files in the working directory
325 status show changed files in the working directory
326 summary summarize working directory state
326 summary summarize working directory state
327 tag add one or more tags for the current or given revision
327 tag add one or more tags for the current or given revision
328 tags list repository tags
328 tags list repository tags
329 tip show the tip revision
329 tip show the tip revision
330 unbundle apply one or more changegroup files
330 unbundle apply one or more changegroup files
331 update update working directory (or switch revisions)
331 update update working directory (or switch revisions)
332 verify verify the integrity of the repository
332 verify verify the integrity of the repository
333 version output version and copyright information
333 version output version and copyright information
334
334
335 additional help topics:
335 additional help topics:
336
336
337 config Configuration Files
337 config Configuration Files
338 dates Date Formats
338 dates Date Formats
339 diffs Diff Formats
339 diffs Diff Formats
340 environment Environment Variables
340 environment Environment Variables
341 extensions Using additional features
341 extensions Using additional features
342 filesets Specifying File Sets
342 filesets Specifying File Sets
343 glossary Glossary
343 glossary Glossary
344 hgignore syntax for Mercurial ignore files
344 hgignore syntax for Mercurial ignore files
345 hgweb Configuring hgweb
345 hgweb Configuring hgweb
346 merge-tools Merge Tools
346 merge-tools Merge Tools
347 multirevs Specifying Multiple Revisions
347 multirevs Specifying Multiple Revisions
348 patterns File Name Patterns
348 patterns File Name Patterns
349 revisions Specifying Single Revisions
349 revisions Specifying Single Revisions
350 revsets Specifying Revision Sets
350 revsets Specifying Revision Sets
351 subrepos Subrepositories
351 subrepos Subrepositories
352 templating Template Usage
352 templating Template Usage
353 urls URL Paths
353 urls URL Paths
354
354
355 use "hg -v help" to show builtin aliases and global options
355 use "hg -v help" to show builtin aliases and global options
356
356
357
357
358
358
359 $ hg --help
359 $ hg --help
360 Mercurial Distributed SCM
360 Mercurial Distributed SCM
361
361
362 list of commands:
362 list of commands:
363
363
364 add add the specified files on the next commit
364 add add the specified files on the next commit
365 addremove add all new files, delete all missing files
365 addremove add all new files, delete all missing files
366 annotate show changeset information by line for each file
366 annotate show changeset information by line for each file
367 archive create an unversioned archive of a repository revision
367 archive create an unversioned archive of a repository revision
368 backout reverse effect of earlier changeset
368 backout reverse effect of earlier changeset
369 bisect subdivision search of changesets
369 bisect subdivision search of changesets
370 bookmarks track a line of development with movable markers
370 bookmarks track a line of development with movable markers
371 branch set or show the current branch name
371 branch set or show the current branch name
372 branches list repository named branches
372 branches list repository named branches
373 bundle create a changegroup file
373 bundle create a changegroup file
374 cat output the current or given revision of files
374 cat output the current or given revision of files
375 clone make a copy of an existing repository
375 clone make a copy of an existing repository
376 commit commit the specified files or all outstanding changes
376 commit commit the specified files or all outstanding changes
377 copy mark files as copied for the next commit
377 copy mark files as copied for the next commit
378 diff diff repository (or selected files)
378 diff diff repository (or selected files)
379 export dump the header and diffs for one or more changesets
379 export dump the header and diffs for one or more changesets
380 forget forget the specified files on the next commit
380 forget forget the specified files on the next commit
381 graft copy changes from other branches onto the current branch
381 graft copy changes from other branches onto the current branch
382 grep search for a pattern in specified files and revisions
382 grep search for a pattern in specified files and revisions
383 heads show current repository heads or show branch heads
383 heads show current repository heads or show branch heads
384 help show help for a given topic or a help overview
384 help show help for a given topic or a help overview
385 identify identify the working copy or specified revision
385 identify identify the working copy or specified revision
386 import import an ordered set of patches
386 import import an ordered set of patches
387 incoming show new changesets found in source
387 incoming show new changesets found in source
388 init create a new repository in the given directory
388 init create a new repository in the given directory
389 locate locate files matching specific patterns
389 locate locate files matching specific patterns
390 log show revision history of entire repository or files
390 log show revision history of entire repository or files
391 manifest output the current or given revision of the project manifest
391 manifest output the current or given revision of the project manifest
392 merge merge working directory with another revision
392 merge merge working directory with another revision
393 outgoing show changesets not found in the destination
393 outgoing show changesets not found in the destination
394 parents show the parents of the working directory or revision
394 parents show the parents of the working directory or revision
395 paths show aliases for remote repositories
395 paths show aliases for remote repositories
396 pull pull changes from the specified source
396 pull pull changes from the specified source
397 push push changes to the specified destination
397 push push changes to the specified destination
398 recover roll back an interrupted transaction
398 recover roll back an interrupted transaction
399 remove remove the specified files on the next commit
399 remove remove the specified files on the next commit
400 rename rename files; equivalent of copy + remove
400 rename rename files; equivalent of copy + remove
401 resolve redo merges or set/view the merge status of files
401 resolve redo merges or set/view the merge status of files
402 revert restore files to their checkout state
402 revert restore files to their checkout state
403 rollback roll back the last transaction (dangerous)
403 rollback roll back the last transaction (dangerous)
404 root print the root (top) of the current working directory
404 root print the root (top) of the current working directory
405 serve start stand-alone webserver
405 serve start stand-alone webserver
406 showconfig show combined config settings from all hgrc files
406 showconfig show combined config settings from all hgrc files
407 status show changed files in the working directory
407 status show changed files in the working directory
408 summary summarize working directory state
408 summary summarize working directory state
409 tag add one or more tags for the current or given revision
409 tag add one or more tags for the current or given revision
410 tags list repository tags
410 tags list repository tags
411 tip show the tip revision
411 tip show the tip revision
412 unbundle apply one or more changegroup files
412 unbundle apply one or more changegroup files
413 update update working directory (or switch revisions)
413 update update working directory (or switch revisions)
414 verify verify the integrity of the repository
414 verify verify the integrity of the repository
415 version output version and copyright information
415 version output version and copyright information
416
416
417 additional help topics:
417 additional help topics:
418
418
419 config Configuration Files
419 config Configuration Files
420 dates Date Formats
420 dates Date Formats
421 diffs Diff Formats
421 diffs Diff Formats
422 environment Environment Variables
422 environment Environment Variables
423 extensions Using additional features
423 extensions Using additional features
424 filesets Specifying File Sets
424 filesets Specifying File Sets
425 glossary Glossary
425 glossary Glossary
426 hgignore syntax for Mercurial ignore files
426 hgignore syntax for Mercurial ignore files
427 hgweb Configuring hgweb
427 hgweb Configuring hgweb
428 merge-tools Merge Tools
428 merge-tools Merge Tools
429 multirevs Specifying Multiple Revisions
429 multirevs Specifying Multiple Revisions
430 patterns File Name Patterns
430 patterns File Name Patterns
431 revisions Specifying Single Revisions
431 revisions Specifying Single Revisions
432 revsets Specifying Revision Sets
432 revsets Specifying Revision Sets
433 subrepos Subrepositories
433 subrepos Subrepositories
434 templating Template Usage
434 templating Template Usage
435 urls URL Paths
435 urls URL Paths
436
436
437 use "hg -v help" to show builtin aliases and global options
437 use "hg -v help" to show builtin aliases and global options
438
438
439 Not tested: --debugger
439 Not tested: --debugger
440
440
General Comments 0
You need to be logged in to leave comments. Login now