##// END OF EJS Templates
githelp: cleanup one more abort message...
Matt Harbison -
r38145:a40cc6d7 default
parent child Browse files
Show More
@@ -1,1090 +1,1089 b''
1 # githelp.py - Try to map Git commands to Mercurial equivalents.
1 # githelp.py - Try to map Git commands to Mercurial equivalents.
2 #
2 #
3 # Copyright 2013 Facebook, Inc.
3 # Copyright 2013 Facebook, Inc.
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 """try mapping git commands to Mercurial commands
7 """try mapping git commands to Mercurial commands
8
8
9 Tries to map a given git command to a Mercurial command:
9 Tries to map a given git command to a Mercurial command:
10
10
11 $ hg githelp -- git checkout master
11 $ hg githelp -- git checkout master
12 hg update master
12 hg update master
13
13
14 If an unknown command or parameter combination is detected, an error is
14 If an unknown command or parameter combination is detected, an error is
15 produced.
15 produced.
16 """
16 """
17
17
18 from __future__ import absolute_import
18 from __future__ import absolute_import
19
19
20 import getopt
20 import getopt
21 import re
21 import re
22
22
23 from mercurial.i18n import _
23 from mercurial.i18n import _
24 from mercurial import (
24 from mercurial import (
25 encoding,
25 encoding,
26 error,
26 error,
27 fancyopts,
27 fancyopts,
28 registrar,
28 registrar,
29 scmutil,
29 scmutil,
30 )
30 )
31 from mercurial.utils import (
31 from mercurial.utils import (
32 procutil,
32 procutil,
33 )
33 )
34
34
35 # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for
35 # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for
36 # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should
36 # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should
37 # be specifying the version(s) of Mercurial they are tested with, or
37 # be specifying the version(s) of Mercurial they are tested with, or
38 # leave the attribute unspecified.
38 # leave the attribute unspecified.
39 testedwith = 'ships-with-hg-core'
39 testedwith = 'ships-with-hg-core'
40
40
41 cmdtable = {}
41 cmdtable = {}
42 command = registrar.command(cmdtable)
42 command = registrar.command(cmdtable)
43
43
44 def convert(s):
44 def convert(s):
45 if s.startswith("origin/"):
45 if s.startswith("origin/"):
46 return s[7:]
46 return s[7:]
47 if 'HEAD' in s:
47 if 'HEAD' in s:
48 s = s.replace('HEAD', '.')
48 s = s.replace('HEAD', '.')
49 # HEAD~ in git is .~1 in mercurial
49 # HEAD~ in git is .~1 in mercurial
50 s = re.sub('~$', '~1', s)
50 s = re.sub('~$', '~1', s)
51 return s
51 return s
52
52
53 @command('^githelp|git', [
53 @command('^githelp|git', [
54 ], _('hg githelp'))
54 ], _('hg githelp'))
55 def githelp(ui, repo, *args, **kwargs):
55 def githelp(ui, repo, *args, **kwargs):
56 '''suggests the Mercurial equivalent of the given git command
56 '''suggests the Mercurial equivalent of the given git command
57
57
58 Usage: hg githelp -- <git command>
58 Usage: hg githelp -- <git command>
59 '''
59 '''
60
60
61 if len(args) == 0 or (len(args) == 1 and args[0] =='git'):
61 if len(args) == 0 or (len(args) == 1 and args[0] =='git'):
62 raise error.Abort(_('missing git command - '
62 raise error.Abort(_('missing git command - '
63 'usage: hg githelp -- <git command>'))
63 'usage: hg githelp -- <git command>'))
64
64
65 if args[0] == 'git':
65 if args[0] == 'git':
66 args = args[1:]
66 args = args[1:]
67
67
68 cmd = args[0]
68 cmd = args[0]
69 if not cmd in gitcommands:
69 if not cmd in gitcommands:
70 raise error.Abort(_("error: unknown git command %s") % (cmd))
70 raise error.Abort(_("error: unknown git command %s") % (cmd))
71
71
72 ui.pager('githelp')
72 ui.pager('githelp')
73 args = args[1:]
73 args = args[1:]
74 return gitcommands[cmd](ui, repo, *args, **kwargs)
74 return gitcommands[cmd](ui, repo, *args, **kwargs)
75
75
76 def parseoptions(ui, cmdoptions, args):
76 def parseoptions(ui, cmdoptions, args):
77 cmdoptions = list(cmdoptions)
77 cmdoptions = list(cmdoptions)
78 opts = {}
78 opts = {}
79 args = list(args)
79 args = list(args)
80 while True:
80 while True:
81 try:
81 try:
82 args = fancyopts.fancyopts(list(args), cmdoptions, opts, True)
82 args = fancyopts.fancyopts(list(args), cmdoptions, opts, True)
83 break
83 break
84 except getopt.GetoptError as ex:
84 except getopt.GetoptError as ex:
85 flag = None
85 flag = None
86 if "requires argument" in ex.msg:
86 if "requires argument" in ex.msg:
87 raise
87 raise
88 if ('--' + ex.opt) in ex.msg:
88 if ('--' + ex.opt) in ex.msg:
89 flag = '--' + ex.opt
89 flag = '--' + ex.opt
90 elif ('-' + ex.opt) in ex.msg:
90 elif ('-' + ex.opt) in ex.msg:
91 flag = '-' + ex.opt
91 flag = '-' + ex.opt
92 else:
92 else:
93 raise error.Abort(_("unknown option %s") % ex.opt)
93 raise error.Abort(_("unknown option %s") % ex.opt)
94 try:
94 try:
95 args.remove(flag)
95 args.remove(flag)
96 except Exception:
96 except Exception:
97 raise error.Abort(
97 msg = _("unknown option '{0}' packed with other options")
98 "unknown option {0} packed with other options\n"
98 hint = _("please try passing the option as its own flag: -{0}")
99 "Please try passing the option as it's own flag: -{0}" \
99 raise error.Abort(msg.format(ex.opt), hint=hint.format(ex.opt))
100 .format(ex.opt))
101
100
102 ui.warn(_("ignoring unknown option %s\n") % flag)
101 ui.warn(_("ignoring unknown option %s\n") % flag)
103
102
104 args = list([convert(x) for x in args])
103 args = list([convert(x) for x in args])
105 opts = dict([(k, convert(v)) if isinstance(v, str) else (k, v)
104 opts = dict([(k, convert(v)) if isinstance(v, str) else (k, v)
106 for k, v in opts.iteritems()])
105 for k, v in opts.iteritems()])
107
106
108 return args, opts
107 return args, opts
109
108
110 class Command(object):
109 class Command(object):
111 def __init__(self, name):
110 def __init__(self, name):
112 self.name = name
111 self.name = name
113 self.args = []
112 self.args = []
114 self.opts = {}
113 self.opts = {}
115
114
116 def __bytes__(self):
115 def __bytes__(self):
117 cmd = "hg " + self.name
116 cmd = "hg " + self.name
118 if self.opts:
117 if self.opts:
119 for k, values in sorted(self.opts.iteritems()):
118 for k, values in sorted(self.opts.iteritems()):
120 for v in values:
119 for v in values:
121 if v:
120 if v:
122 cmd += " %s %s" % (k, v)
121 cmd += " %s %s" % (k, v)
123 else:
122 else:
124 cmd += " %s" % (k,)
123 cmd += " %s" % (k,)
125 if self.args:
124 if self.args:
126 cmd += " "
125 cmd += " "
127 cmd += " ".join(self.args)
126 cmd += " ".join(self.args)
128 return cmd
127 return cmd
129
128
130 __str__ = encoding.strmethod(__bytes__)
129 __str__ = encoding.strmethod(__bytes__)
131
130
132 def append(self, value):
131 def append(self, value):
133 self.args.append(value)
132 self.args.append(value)
134
133
135 def extend(self, values):
134 def extend(self, values):
136 self.args.extend(values)
135 self.args.extend(values)
137
136
138 def __setitem__(self, key, value):
137 def __setitem__(self, key, value):
139 values = self.opts.setdefault(key, [])
138 values = self.opts.setdefault(key, [])
140 values.append(value)
139 values.append(value)
141
140
142 def __and__(self, other):
141 def __and__(self, other):
143 return AndCommand(self, other)
142 return AndCommand(self, other)
144
143
145 class AndCommand(object):
144 class AndCommand(object):
146 def __init__(self, left, right):
145 def __init__(self, left, right):
147 self.left = left
146 self.left = left
148 self.right = right
147 self.right = right
149
148
150 def __str__(self):
149 def __str__(self):
151 return "%s && %s" % (self.left, self.right)
150 return "%s && %s" % (self.left, self.right)
152
151
153 def __and__(self, other):
152 def __and__(self, other):
154 return AndCommand(self, other)
153 return AndCommand(self, other)
155
154
156 def add(ui, repo, *args, **kwargs):
155 def add(ui, repo, *args, **kwargs):
157 cmdoptions = [
156 cmdoptions = [
158 ('A', 'all', None, ''),
157 ('A', 'all', None, ''),
159 ('p', 'patch', None, ''),
158 ('p', 'patch', None, ''),
160 ]
159 ]
161 args, opts = parseoptions(ui, cmdoptions, args)
160 args, opts = parseoptions(ui, cmdoptions, args)
162
161
163 if (opts.get('patch')):
162 if (opts.get('patch')):
164 ui.status(_("note: Mercurial will commit when complete, "
163 ui.status(_("note: Mercurial will commit when complete, "
165 "as there is no staging area in Mercurial\n\n"))
164 "as there is no staging area in Mercurial\n\n"))
166 cmd = Command('commit --interactive')
165 cmd = Command('commit --interactive')
167 else:
166 else:
168 cmd = Command("add")
167 cmd = Command("add")
169
168
170 if not opts.get('all'):
169 if not opts.get('all'):
171 cmd.extend(args)
170 cmd.extend(args)
172 else:
171 else:
173 ui.status(_("note: use hg addremove to remove files that have "
172 ui.status(_("note: use hg addremove to remove files that have "
174 "been deleted.\n\n"))
173 "been deleted.\n\n"))
175
174
176 ui.status((bytes(cmd)), "\n")
175 ui.status((bytes(cmd)), "\n")
177
176
178 def am(ui, repo, *args, **kwargs):
177 def am(ui, repo, *args, **kwargs):
179 cmdoptions=[
178 cmdoptions=[
180 ]
179 ]
181 args, opts = parseoptions(ui, cmdoptions, args)
180 args, opts = parseoptions(ui, cmdoptions, args)
182 cmd = Command('import')
181 cmd = Command('import')
183 ui.status(bytes(cmd), "\n")
182 ui.status(bytes(cmd), "\n")
184
183
185 def apply(ui, repo, *args, **kwargs):
184 def apply(ui, repo, *args, **kwargs):
186 cmdoptions = [
185 cmdoptions = [
187 ('p', 'p', int, ''),
186 ('p', 'p', int, ''),
188 ]
187 ]
189 args, opts = parseoptions(ui, cmdoptions, args)
188 args, opts = parseoptions(ui, cmdoptions, args)
190
189
191 cmd = Command('import --no-commit')
190 cmd = Command('import --no-commit')
192 if (opts.get('p')):
191 if (opts.get('p')):
193 cmd['-p'] = opts.get('p')
192 cmd['-p'] = opts.get('p')
194 cmd.extend(args)
193 cmd.extend(args)
195
194
196 ui.status((bytes(cmd)), "\n")
195 ui.status((bytes(cmd)), "\n")
197
196
198 def bisect(ui, repo, *args, **kwargs):
197 def bisect(ui, repo, *args, **kwargs):
199 ui.status(_("see 'hg help bisect' for how to use bisect.\n\n"))
198 ui.status(_("see 'hg help bisect' for how to use bisect.\n\n"))
200
199
201 def blame(ui, repo, *args, **kwargs):
200 def blame(ui, repo, *args, **kwargs):
202 cmdoptions = [
201 cmdoptions = [
203 ]
202 ]
204 args, opts = parseoptions(ui, cmdoptions, args)
203 args, opts = parseoptions(ui, cmdoptions, args)
205 cmd = Command('annotate -udl')
204 cmd = Command('annotate -udl')
206 cmd.extend([convert(v) for v in args])
205 cmd.extend([convert(v) for v in args])
207 ui.status((bytes(cmd)), "\n")
206 ui.status((bytes(cmd)), "\n")
208
207
209 def branch(ui, repo, *args, **kwargs):
208 def branch(ui, repo, *args, **kwargs):
210 cmdoptions = [
209 cmdoptions = [
211 ('', 'set-upstream', None, ''),
210 ('', 'set-upstream', None, ''),
212 ('', 'set-upstream-to', '', ''),
211 ('', 'set-upstream-to', '', ''),
213 ('d', 'delete', None, ''),
212 ('d', 'delete', None, ''),
214 ('D', 'delete', None, ''),
213 ('D', 'delete', None, ''),
215 ('m', 'move', None, ''),
214 ('m', 'move', None, ''),
216 ('M', 'move', None, ''),
215 ('M', 'move', None, ''),
217 ]
216 ]
218 args, opts = parseoptions(ui, cmdoptions, args)
217 args, opts = parseoptions(ui, cmdoptions, args)
219
218
220 cmd = Command("bookmark")
219 cmd = Command("bookmark")
221
220
222 if opts.get('set_upstream') or opts.get('set_upstream_to'):
221 if opts.get('set_upstream') or opts.get('set_upstream_to'):
223 ui.status(_("Mercurial has no concept of upstream branches\n"))
222 ui.status(_("Mercurial has no concept of upstream branches\n"))
224 return
223 return
225 elif opts.get('delete'):
224 elif opts.get('delete'):
226 cmd = Command("strip")
225 cmd = Command("strip")
227 for branch in args:
226 for branch in args:
228 cmd['-B'] = branch
227 cmd['-B'] = branch
229 else:
228 else:
230 cmd['-B'] = None
229 cmd['-B'] = None
231 elif opts.get('move'):
230 elif opts.get('move'):
232 if len(args) > 0:
231 if len(args) > 0:
233 if len(args) > 1:
232 if len(args) > 1:
234 old = args.pop(0)
233 old = args.pop(0)
235 else:
234 else:
236 # shell command to output the active bookmark for the active
235 # shell command to output the active bookmark for the active
237 # revision
236 # revision
238 old = '`hg log -T"{activebookmark}" -r .`'
237 old = '`hg log -T"{activebookmark}" -r .`'
239 else:
238 else:
240 raise error.Abort(_('missing newbranch argument'))
239 raise error.Abort(_('missing newbranch argument'))
241 new = args[0]
240 new = args[0]
242 cmd['-m'] = old
241 cmd['-m'] = old
243 cmd.append(new)
242 cmd.append(new)
244 else:
243 else:
245 if len(args) > 1:
244 if len(args) > 1:
246 cmd['-r'] = args[1]
245 cmd['-r'] = args[1]
247 cmd.append(args[0])
246 cmd.append(args[0])
248 elif len(args) == 1:
247 elif len(args) == 1:
249 cmd.append(args[0])
248 cmd.append(args[0])
250 ui.status((bytes(cmd)), "\n")
249 ui.status((bytes(cmd)), "\n")
251
250
252 def ispath(repo, string):
251 def ispath(repo, string):
253 """
252 """
254 The first argument to git checkout can either be a revision or a path. Let's
253 The first argument to git checkout can either be a revision or a path. Let's
255 generally assume it's a revision, unless it's obviously a path. There are
254 generally assume it's a revision, unless it's obviously a path. There are
256 too many ways to spell revisions in git for us to reasonably catch all of
255 too many ways to spell revisions in git for us to reasonably catch all of
257 them, so let's be conservative.
256 them, so let's be conservative.
258 """
257 """
259 if scmutil.isrevsymbol(repo, string):
258 if scmutil.isrevsymbol(repo, string):
260 # if it's definitely a revision let's not even check if a file of the
259 # if it's definitely a revision let's not even check if a file of the
261 # same name exists.
260 # same name exists.
262 return False
261 return False
263
262
264 cwd = repo.getcwd()
263 cwd = repo.getcwd()
265 if cwd == '':
264 if cwd == '':
266 repopath = string
265 repopath = string
267 else:
266 else:
268 repopath = cwd + '/' + string
267 repopath = cwd + '/' + string
269
268
270 exists = repo.wvfs.exists(repopath)
269 exists = repo.wvfs.exists(repopath)
271 if exists:
270 if exists:
272 return True
271 return True
273
272
274 manifest = repo['.'].manifest()
273 manifest = repo['.'].manifest()
275
274
276 didexist = (repopath in manifest) or manifest.hasdir(repopath)
275 didexist = (repopath in manifest) or manifest.hasdir(repopath)
277
276
278 return didexist
277 return didexist
279
278
280 def checkout(ui, repo, *args, **kwargs):
279 def checkout(ui, repo, *args, **kwargs):
281 cmdoptions = [
280 cmdoptions = [
282 ('b', 'branch', '', ''),
281 ('b', 'branch', '', ''),
283 ('B', 'branch', '', ''),
282 ('B', 'branch', '', ''),
284 ('f', 'force', None, ''),
283 ('f', 'force', None, ''),
285 ('p', 'patch', None, ''),
284 ('p', 'patch', None, ''),
286 ]
285 ]
287 paths = []
286 paths = []
288 if '--' in args:
287 if '--' in args:
289 sepindex = args.index('--')
288 sepindex = args.index('--')
290 paths.extend(args[sepindex + 1:])
289 paths.extend(args[sepindex + 1:])
291 args = args[:sepindex]
290 args = args[:sepindex]
292
291
293 args, opts = parseoptions(ui, cmdoptions, args)
292 args, opts = parseoptions(ui, cmdoptions, args)
294
293
295 rev = None
294 rev = None
296 if args and ispath(repo, args[0]):
295 if args and ispath(repo, args[0]):
297 paths = args + paths
296 paths = args + paths
298 elif args:
297 elif args:
299 rev = args[0]
298 rev = args[0]
300 paths = args[1:] + paths
299 paths = args[1:] + paths
301
300
302 cmd = Command('update')
301 cmd = Command('update')
303
302
304 if opts.get('force'):
303 if opts.get('force'):
305 if paths or rev:
304 if paths or rev:
306 cmd['-C'] = None
305 cmd['-C'] = None
307
306
308 if opts.get('patch'):
307 if opts.get('patch'):
309 cmd = Command('revert')
308 cmd = Command('revert')
310 cmd['-i'] = None
309 cmd['-i'] = None
311
310
312 if opts.get('branch'):
311 if opts.get('branch'):
313 if len(args) == 0:
312 if len(args) == 0:
314 cmd = Command('bookmark')
313 cmd = Command('bookmark')
315 cmd.append(opts.get('branch'))
314 cmd.append(opts.get('branch'))
316 else:
315 else:
317 cmd.append(args[0])
316 cmd.append(args[0])
318 bookcmd = Command('bookmark')
317 bookcmd = Command('bookmark')
319 bookcmd.append(opts.get('branch'))
318 bookcmd.append(opts.get('branch'))
320 cmd = cmd & bookcmd
319 cmd = cmd & bookcmd
321 # if there is any path argument supplied, use revert instead of update
320 # if there is any path argument supplied, use revert instead of update
322 elif len(paths) > 0:
321 elif len(paths) > 0:
323 ui.status(_("note: use --no-backup to avoid creating .orig files\n\n"))
322 ui.status(_("note: use --no-backup to avoid creating .orig files\n\n"))
324 cmd = Command('revert')
323 cmd = Command('revert')
325 if opts.get('patch'):
324 if opts.get('patch'):
326 cmd['-i'] = None
325 cmd['-i'] = None
327 if rev:
326 if rev:
328 cmd['-r'] = rev
327 cmd['-r'] = rev
329 cmd.extend(paths)
328 cmd.extend(paths)
330 elif rev:
329 elif rev:
331 if opts.get('patch'):
330 if opts.get('patch'):
332 cmd['-r'] = rev
331 cmd['-r'] = rev
333 else:
332 else:
334 cmd.append(rev)
333 cmd.append(rev)
335 elif opts.get('force'):
334 elif opts.get('force'):
336 cmd = Command('revert')
335 cmd = Command('revert')
337 cmd['--all'] = None
336 cmd['--all'] = None
338 else:
337 else:
339 raise error.Abort(_("a commit must be specified"))
338 raise error.Abort(_("a commit must be specified"))
340
339
341 ui.status((bytes(cmd)), "\n")
340 ui.status((bytes(cmd)), "\n")
342
341
343 def cherrypick(ui, repo, *args, **kwargs):
342 def cherrypick(ui, repo, *args, **kwargs):
344 cmdoptions = [
343 cmdoptions = [
345 ('', 'continue', None, ''),
344 ('', 'continue', None, ''),
346 ('', 'abort', None, ''),
345 ('', 'abort', None, ''),
347 ('e', 'edit', None, ''),
346 ('e', 'edit', None, ''),
348 ]
347 ]
349 args, opts = parseoptions(ui, cmdoptions, args)
348 args, opts = parseoptions(ui, cmdoptions, args)
350
349
351 cmd = Command('graft')
350 cmd = Command('graft')
352
351
353 if opts.get('edit'):
352 if opts.get('edit'):
354 cmd['--edit'] = None
353 cmd['--edit'] = None
355 if opts.get('continue'):
354 if opts.get('continue'):
356 cmd['--continue'] = None
355 cmd['--continue'] = None
357 elif opts.get('abort'):
356 elif opts.get('abort'):
358 ui.status(_("note: hg graft does not have --abort.\n\n"))
357 ui.status(_("note: hg graft does not have --abort.\n\n"))
359 return
358 return
360 else:
359 else:
361 cmd.extend(args)
360 cmd.extend(args)
362
361
363 ui.status((bytes(cmd)), "\n")
362 ui.status((bytes(cmd)), "\n")
364
363
365 def clean(ui, repo, *args, **kwargs):
364 def clean(ui, repo, *args, **kwargs):
366 cmdoptions = [
365 cmdoptions = [
367 ('d', 'd', None, ''),
366 ('d', 'd', None, ''),
368 ('f', 'force', None, ''),
367 ('f', 'force', None, ''),
369 ('x', 'x', None, ''),
368 ('x', 'x', None, ''),
370 ]
369 ]
371 args, opts = parseoptions(ui, cmdoptions, args)
370 args, opts = parseoptions(ui, cmdoptions, args)
372
371
373 cmd = Command('purge')
372 cmd = Command('purge')
374 if opts.get('x'):
373 if opts.get('x'):
375 cmd['--all'] = None
374 cmd['--all'] = None
376 cmd.extend(args)
375 cmd.extend(args)
377
376
378 ui.status((bytes(cmd)), "\n")
377 ui.status((bytes(cmd)), "\n")
379
378
380 def clone(ui, repo, *args, **kwargs):
379 def clone(ui, repo, *args, **kwargs):
381 cmdoptions = [
380 cmdoptions = [
382 ('', 'bare', None, ''),
381 ('', 'bare', None, ''),
383 ('n', 'no-checkout', None, ''),
382 ('n', 'no-checkout', None, ''),
384 ('b', 'branch', '', ''),
383 ('b', 'branch', '', ''),
385 ]
384 ]
386 args, opts = parseoptions(ui, cmdoptions, args)
385 args, opts = parseoptions(ui, cmdoptions, args)
387
386
388 if len(args) == 0:
387 if len(args) == 0:
389 raise error.Abort(_("a repository to clone must be specified"))
388 raise error.Abort(_("a repository to clone must be specified"))
390
389
391 cmd = Command('clone')
390 cmd = Command('clone')
392 cmd.append(args[0])
391 cmd.append(args[0])
393 if len(args) > 1:
392 if len(args) > 1:
394 cmd.append(args[1])
393 cmd.append(args[1])
395
394
396 if opts.get('bare'):
395 if opts.get('bare'):
397 cmd['-U'] = None
396 cmd['-U'] = None
398 ui.status(_("note: Mercurial does not have bare clones. "
397 ui.status(_("note: Mercurial does not have bare clones. "
399 "-U will clone the repo without checking out a commit\n\n"))
398 "-U will clone the repo without checking out a commit\n\n"))
400 elif opts.get('no_checkout'):
399 elif opts.get('no_checkout'):
401 cmd['-U'] = None
400 cmd['-U'] = None
402
401
403 if opts.get('branch'):
402 if opts.get('branch'):
404 cocmd = Command("update")
403 cocmd = Command("update")
405 cocmd.append(opts.get('branch'))
404 cocmd.append(opts.get('branch'))
406 cmd = cmd & cocmd
405 cmd = cmd & cocmd
407
406
408 ui.status((bytes(cmd)), "\n")
407 ui.status((bytes(cmd)), "\n")
409
408
410 def commit(ui, repo, *args, **kwargs):
409 def commit(ui, repo, *args, **kwargs):
411 cmdoptions = [
410 cmdoptions = [
412 ('a', 'all', None, ''),
411 ('a', 'all', None, ''),
413 ('m', 'message', '', ''),
412 ('m', 'message', '', ''),
414 ('p', 'patch', None, ''),
413 ('p', 'patch', None, ''),
415 ('C', 'reuse-message', '', ''),
414 ('C', 'reuse-message', '', ''),
416 ('F', 'file', '', ''),
415 ('F', 'file', '', ''),
417 ('', 'author', '', ''),
416 ('', 'author', '', ''),
418 ('', 'date', '', ''),
417 ('', 'date', '', ''),
419 ('', 'amend', None, ''),
418 ('', 'amend', None, ''),
420 ('', 'no-edit', None, ''),
419 ('', 'no-edit', None, ''),
421 ]
420 ]
422 args, opts = parseoptions(ui, cmdoptions, args)
421 args, opts = parseoptions(ui, cmdoptions, args)
423
422
424 cmd = Command('commit')
423 cmd = Command('commit')
425 if opts.get('patch'):
424 if opts.get('patch'):
426 cmd = Command('commit --interactive')
425 cmd = Command('commit --interactive')
427
426
428 if opts.get('amend'):
427 if opts.get('amend'):
429 if opts.get('no_edit'):
428 if opts.get('no_edit'):
430 cmd = Command('amend')
429 cmd = Command('amend')
431 else:
430 else:
432 cmd['--amend'] = None
431 cmd['--amend'] = None
433
432
434 if opts.get('reuse_message'):
433 if opts.get('reuse_message'):
435 cmd['-M'] = opts.get('reuse_message')
434 cmd['-M'] = opts.get('reuse_message')
436
435
437 if opts.get('message'):
436 if opts.get('message'):
438 cmd['-m'] = "'%s'" % (opts.get('message'),)
437 cmd['-m'] = "'%s'" % (opts.get('message'),)
439
438
440 if opts.get('all'):
439 if opts.get('all'):
441 ui.status(_("note: Mercurial doesn't have a staging area, "
440 ui.status(_("note: Mercurial doesn't have a staging area, "
442 "so there is no --all. -A will add and remove files "
441 "so there is no --all. -A will add and remove files "
443 "for you though.\n\n"))
442 "for you though.\n\n"))
444
443
445 if opts.get('file'):
444 if opts.get('file'):
446 cmd['-l'] = opts.get('file')
445 cmd['-l'] = opts.get('file')
447
446
448 if opts.get('author'):
447 if opts.get('author'):
449 cmd['-u'] = opts.get('author')
448 cmd['-u'] = opts.get('author')
450
449
451 if opts.get('date'):
450 if opts.get('date'):
452 cmd['-d'] = opts.get('date')
451 cmd['-d'] = opts.get('date')
453
452
454 cmd.extend(args)
453 cmd.extend(args)
455
454
456 ui.status((bytes(cmd)), "\n")
455 ui.status((bytes(cmd)), "\n")
457
456
458 def deprecated(ui, repo, *args, **kwargs):
457 def deprecated(ui, repo, *args, **kwargs):
459 ui.warn(_('this command has been deprecated in the git project, '
458 ui.warn(_('this command has been deprecated in the git project, '
460 'thus isn\'t supported by this tool.\n\n'))
459 'thus isn\'t supported by this tool.\n\n'))
461
460
462 def diff(ui, repo, *args, **kwargs):
461 def diff(ui, repo, *args, **kwargs):
463 cmdoptions = [
462 cmdoptions = [
464 ('a', 'all', None, ''),
463 ('a', 'all', None, ''),
465 ('', 'cached', None, ''),
464 ('', 'cached', None, ''),
466 ('R', 'reverse', None, ''),
465 ('R', 'reverse', None, ''),
467 ]
466 ]
468 args, opts = parseoptions(ui, cmdoptions, args)
467 args, opts = parseoptions(ui, cmdoptions, args)
469
468
470 cmd = Command('diff')
469 cmd = Command('diff')
471
470
472 if opts.get('cached'):
471 if opts.get('cached'):
473 ui.status(_('note: Mercurial has no concept of a staging area, '
472 ui.status(_('note: Mercurial has no concept of a staging area, '
474 'so --cached does nothing.\n\n'))
473 'so --cached does nothing.\n\n'))
475
474
476 if opts.get('reverse'):
475 if opts.get('reverse'):
477 cmd['--reverse'] = None
476 cmd['--reverse'] = None
478
477
479 for a in list(args):
478 for a in list(args):
480 args.remove(a)
479 args.remove(a)
481 try:
480 try:
482 repo.revs(a)
481 repo.revs(a)
483 cmd['-r'] = a
482 cmd['-r'] = a
484 except Exception:
483 except Exception:
485 cmd.append(a)
484 cmd.append(a)
486
485
487 ui.status((bytes(cmd)), "\n")
486 ui.status((bytes(cmd)), "\n")
488
487
489 def difftool(ui, repo, *args, **kwargs):
488 def difftool(ui, repo, *args, **kwargs):
490 ui.status(_('Mercurial does not enable external difftool by default. You '
489 ui.status(_('Mercurial does not enable external difftool by default. You '
491 'need to enable the extdiff extension in your .hgrc file by adding\n'
490 'need to enable the extdiff extension in your .hgrc file by adding\n'
492 'extdiff =\n'
491 'extdiff =\n'
493 'to the [extensions] section and then running\n\n'
492 'to the [extensions] section and then running\n\n'
494 'hg extdiff -p <program>\n\n'
493 'hg extdiff -p <program>\n\n'
495 'See \'hg help extdiff\' and \'hg help -e extdiff\' for more '
494 'See \'hg help extdiff\' and \'hg help -e extdiff\' for more '
496 'information.\n'))
495 'information.\n'))
497
496
498 def fetch(ui, repo, *args, **kwargs):
497 def fetch(ui, repo, *args, **kwargs):
499 cmdoptions = [
498 cmdoptions = [
500 ('', 'all', None, ''),
499 ('', 'all', None, ''),
501 ('f', 'force', None, ''),
500 ('f', 'force', None, ''),
502 ]
501 ]
503 args, opts = parseoptions(ui, cmdoptions, args)
502 args, opts = parseoptions(ui, cmdoptions, args)
504
503
505 cmd = Command('pull')
504 cmd = Command('pull')
506
505
507 if len(args) > 0:
506 if len(args) > 0:
508 cmd.append(args[0])
507 cmd.append(args[0])
509 if len(args) > 1:
508 if len(args) > 1:
510 ui.status(_("note: Mercurial doesn't have refspecs. "
509 ui.status(_("note: Mercurial doesn't have refspecs. "
511 "-r can be used to specify which commits you want to "
510 "-r can be used to specify which commits you want to "
512 "pull. -B can be used to specify which bookmark you "
511 "pull. -B can be used to specify which bookmark you "
513 "want to pull.\n\n"))
512 "want to pull.\n\n"))
514 for v in args[1:]:
513 for v in args[1:]:
515 if v in repo._bookmarks:
514 if v in repo._bookmarks:
516 cmd['-B'] = v
515 cmd['-B'] = v
517 else:
516 else:
518 cmd['-r'] = v
517 cmd['-r'] = v
519
518
520 ui.status((bytes(cmd)), "\n")
519 ui.status((bytes(cmd)), "\n")
521
520
522 def grep(ui, repo, *args, **kwargs):
521 def grep(ui, repo, *args, **kwargs):
523 cmdoptions = [
522 cmdoptions = [
524 ]
523 ]
525 args, opts = parseoptions(ui, cmdoptions, args)
524 args, opts = parseoptions(ui, cmdoptions, args)
526
525
527 cmd = Command('grep')
526 cmd = Command('grep')
528
527
529 # For basic usage, git grep and hg grep are the same. They both have the
528 # For basic usage, git grep and hg grep are the same. They both have the
530 # pattern first, followed by paths.
529 # pattern first, followed by paths.
531 cmd.extend(args)
530 cmd.extend(args)
532
531
533 ui.status((bytes(cmd)), "\n")
532 ui.status((bytes(cmd)), "\n")
534
533
535 def init(ui, repo, *args, **kwargs):
534 def init(ui, repo, *args, **kwargs):
536 cmdoptions = [
535 cmdoptions = [
537 ]
536 ]
538 args, opts = parseoptions(ui, cmdoptions, args)
537 args, opts = parseoptions(ui, cmdoptions, args)
539
538
540 cmd = Command('init')
539 cmd = Command('init')
541
540
542 if len(args) > 0:
541 if len(args) > 0:
543 cmd.append(args[0])
542 cmd.append(args[0])
544
543
545 ui.status((bytes(cmd)), "\n")
544 ui.status((bytes(cmd)), "\n")
546
545
547 def log(ui, repo, *args, **kwargs):
546 def log(ui, repo, *args, **kwargs):
548 cmdoptions = [
547 cmdoptions = [
549 ('', 'follow', None, ''),
548 ('', 'follow', None, ''),
550 ('', 'decorate', None, ''),
549 ('', 'decorate', None, ''),
551 ('n', 'number', '', ''),
550 ('n', 'number', '', ''),
552 ('1', '1', None, ''),
551 ('1', '1', None, ''),
553 ('', 'pretty', '', ''),
552 ('', 'pretty', '', ''),
554 ('', 'format', '', ''),
553 ('', 'format', '', ''),
555 ('', 'oneline', None, ''),
554 ('', 'oneline', None, ''),
556 ('', 'stat', None, ''),
555 ('', 'stat', None, ''),
557 ('', 'graph', None, ''),
556 ('', 'graph', None, ''),
558 ('p', 'patch', None, ''),
557 ('p', 'patch', None, ''),
559 ]
558 ]
560 args, opts = parseoptions(ui, cmdoptions, args)
559 args, opts = parseoptions(ui, cmdoptions, args)
561 ui.status(_('note: -v prints the entire commit message like Git does. To '
560 ui.status(_('note: -v prints the entire commit message like Git does. To '
562 'print just the first line, drop the -v.\n\n'))
561 'print just the first line, drop the -v.\n\n'))
563 ui.status(_("note: see hg help revset for information on how to filter "
562 ui.status(_("note: see hg help revset for information on how to filter "
564 "log output.\n\n"))
563 "log output.\n\n"))
565
564
566 cmd = Command('log')
565 cmd = Command('log')
567 cmd['-v'] = None
566 cmd['-v'] = None
568
567
569 if opts.get('number'):
568 if opts.get('number'):
570 cmd['-l'] = opts.get('number')
569 cmd['-l'] = opts.get('number')
571 if opts.get('1'):
570 if opts.get('1'):
572 cmd['-l'] = '1'
571 cmd['-l'] = '1'
573 if opts.get('stat'):
572 if opts.get('stat'):
574 cmd['--stat'] = None
573 cmd['--stat'] = None
575 if opts.get('graph'):
574 if opts.get('graph'):
576 cmd['-G'] = None
575 cmd['-G'] = None
577 if opts.get('patch'):
576 if opts.get('patch'):
578 cmd['-p'] = None
577 cmd['-p'] = None
579
578
580 if opts.get('pretty') or opts.get('format') or opts.get('oneline'):
579 if opts.get('pretty') or opts.get('format') or opts.get('oneline'):
581 format = opts.get('format', '')
580 format = opts.get('format', '')
582 if 'format:' in format:
581 if 'format:' in format:
583 ui.status(_("note: --format format:??? equates to Mercurial's "
582 ui.status(_("note: --format format:??? equates to Mercurial's "
584 "--template. See hg help templates for more info.\n\n"))
583 "--template. See hg help templates for more info.\n\n"))
585 cmd['--template'] = '???'
584 cmd['--template'] = '???'
586 else:
585 else:
587 ui.status(_("note: --pretty/format/oneline equate to Mercurial's "
586 ui.status(_("note: --pretty/format/oneline equate to Mercurial's "
588 "--style or --template. See hg help templates for "
587 "--style or --template. See hg help templates for "
589 "more info.\n\n"))
588 "more info.\n\n"))
590 cmd['--style'] = '???'
589 cmd['--style'] = '???'
591
590
592 if len(args) > 0:
591 if len(args) > 0:
593 if '..' in args[0]:
592 if '..' in args[0]:
594 since, until = args[0].split('..')
593 since, until = args[0].split('..')
595 cmd['-r'] = "'%s::%s'" % (since, until)
594 cmd['-r'] = "'%s::%s'" % (since, until)
596 del args[0]
595 del args[0]
597 cmd.extend(args)
596 cmd.extend(args)
598
597
599 ui.status((bytes(cmd)), "\n")
598 ui.status((bytes(cmd)), "\n")
600
599
601 def lsfiles(ui, repo, *args, **kwargs):
600 def lsfiles(ui, repo, *args, **kwargs):
602 cmdoptions = [
601 cmdoptions = [
603 ('c', 'cached', None, ''),
602 ('c', 'cached', None, ''),
604 ('d', 'deleted', None, ''),
603 ('d', 'deleted', None, ''),
605 ('m', 'modified', None, ''),
604 ('m', 'modified', None, ''),
606 ('o', 'others', None, ''),
605 ('o', 'others', None, ''),
607 ('i', 'ignored', None, ''),
606 ('i', 'ignored', None, ''),
608 ('s', 'stage', None, ''),
607 ('s', 'stage', None, ''),
609 ('z', '_zero', None, ''),
608 ('z', '_zero', None, ''),
610 ]
609 ]
611 args, opts = parseoptions(ui, cmdoptions, args)
610 args, opts = parseoptions(ui, cmdoptions, args)
612
611
613 if (opts.get('modified') or opts.get('deleted')
612 if (opts.get('modified') or opts.get('deleted')
614 or opts.get('others') or opts.get('ignored')):
613 or opts.get('others') or opts.get('ignored')):
615 cmd = Command('status')
614 cmd = Command('status')
616 if opts.get('deleted'):
615 if opts.get('deleted'):
617 cmd['-d'] = None
616 cmd['-d'] = None
618 if opts.get('modified'):
617 if opts.get('modified'):
619 cmd['-m'] = None
618 cmd['-m'] = None
620 if opts.get('others'):
619 if opts.get('others'):
621 cmd['-o'] = None
620 cmd['-o'] = None
622 if opts.get('ignored'):
621 if opts.get('ignored'):
623 cmd['-i'] = None
622 cmd['-i'] = None
624 else:
623 else:
625 cmd = Command('files')
624 cmd = Command('files')
626 if opts.get('stage'):
625 if opts.get('stage'):
627 ui.status(_("note: Mercurial doesn't have a staging area, ignoring "
626 ui.status(_("note: Mercurial doesn't have a staging area, ignoring "
628 "--stage\n"))
627 "--stage\n"))
629 if opts.get('_zero'):
628 if opts.get('_zero'):
630 cmd['-0'] = None
629 cmd['-0'] = None
631 cmd.append('.')
630 cmd.append('.')
632 for include in args:
631 for include in args:
633 cmd['-I'] = procutil.shellquote(include)
632 cmd['-I'] = procutil.shellquote(include)
634
633
635 ui.status((bytes(cmd)), "\n")
634 ui.status((bytes(cmd)), "\n")
636
635
637 def merge(ui, repo, *args, **kwargs):
636 def merge(ui, repo, *args, **kwargs):
638 cmdoptions = [
637 cmdoptions = [
639 ]
638 ]
640 args, opts = parseoptions(ui, cmdoptions, args)
639 args, opts = parseoptions(ui, cmdoptions, args)
641
640
642 cmd = Command('merge')
641 cmd = Command('merge')
643
642
644 if len(args) > 0:
643 if len(args) > 0:
645 cmd.append(args[len(args) - 1])
644 cmd.append(args[len(args) - 1])
646
645
647 ui.status((bytes(cmd)), "\n")
646 ui.status((bytes(cmd)), "\n")
648
647
649 def mergebase(ui, repo, *args, **kwargs):
648 def mergebase(ui, repo, *args, **kwargs):
650 cmdoptions = []
649 cmdoptions = []
651 args, opts = parseoptions(ui, cmdoptions, args)
650 args, opts = parseoptions(ui, cmdoptions, args)
652
651
653 if len(args) != 2:
652 if len(args) != 2:
654 args = ['A', 'B']
653 args = ['A', 'B']
655
654
656 cmd = Command("log -T '{node}\\n' -r 'ancestor(%s,%s)'"
655 cmd = Command("log -T '{node}\\n' -r 'ancestor(%s,%s)'"
657 % (args[0], args[1]))
656 % (args[0], args[1]))
658
657
659 ui.status(_('note: ancestors() is part of the revset language.\n'),
658 ui.status(_('note: ancestors() is part of the revset language.\n'),
660 _("(learn more about revsets with 'hg help revsets')\n\n"))
659 _("(learn more about revsets with 'hg help revsets')\n\n"))
661 ui.status((bytes(cmd)), "\n")
660 ui.status((bytes(cmd)), "\n")
662
661
663 def mergetool(ui, repo, *args, **kwargs):
662 def mergetool(ui, repo, *args, **kwargs):
664 cmdoptions = []
663 cmdoptions = []
665 args, opts = parseoptions(ui, cmdoptions, args)
664 args, opts = parseoptions(ui, cmdoptions, args)
666
665
667 cmd = Command("resolve")
666 cmd = Command("resolve")
668
667
669 if len(args) == 0:
668 if len(args) == 0:
670 cmd['--all'] = None
669 cmd['--all'] = None
671 cmd.extend(args)
670 cmd.extend(args)
672 ui.status((bytes(cmd)), "\n")
671 ui.status((bytes(cmd)), "\n")
673
672
674 def mv(ui, repo, *args, **kwargs):
673 def mv(ui, repo, *args, **kwargs):
675 cmdoptions = [
674 cmdoptions = [
676 ('f', 'force', None, ''),
675 ('f', 'force', None, ''),
677 ]
676 ]
678 args, opts = parseoptions(ui, cmdoptions, args)
677 args, opts = parseoptions(ui, cmdoptions, args)
679
678
680 cmd = Command('mv')
679 cmd = Command('mv')
681 cmd.extend(args)
680 cmd.extend(args)
682
681
683 if opts.get('force'):
682 if opts.get('force'):
684 cmd['-f'] = None
683 cmd['-f'] = None
685
684
686 ui.status((bytes(cmd)), "\n")
685 ui.status((bytes(cmd)), "\n")
687
686
688 def pull(ui, repo, *args, **kwargs):
687 def pull(ui, repo, *args, **kwargs):
689 cmdoptions = [
688 cmdoptions = [
690 ('', 'all', None, ''),
689 ('', 'all', None, ''),
691 ('f', 'force', None, ''),
690 ('f', 'force', None, ''),
692 ('r', 'rebase', None, ''),
691 ('r', 'rebase', None, ''),
693 ]
692 ]
694 args, opts = parseoptions(ui, cmdoptions, args)
693 args, opts = parseoptions(ui, cmdoptions, args)
695
694
696 cmd = Command('pull')
695 cmd = Command('pull')
697 cmd['--rebase'] = None
696 cmd['--rebase'] = None
698
697
699 if len(args) > 0:
698 if len(args) > 0:
700 cmd.append(args[0])
699 cmd.append(args[0])
701 if len(args) > 1:
700 if len(args) > 1:
702 ui.status(_("note: Mercurial doesn't have refspecs. "
701 ui.status(_("note: Mercurial doesn't have refspecs. "
703 "-r can be used to specify which commits you want to "
702 "-r can be used to specify which commits you want to "
704 "pull. -B can be used to specify which bookmark you "
703 "pull. -B can be used to specify which bookmark you "
705 "want to pull.\n\n"))
704 "want to pull.\n\n"))
706 for v in args[1:]:
705 for v in args[1:]:
707 if v in repo._bookmarks:
706 if v in repo._bookmarks:
708 cmd['-B'] = v
707 cmd['-B'] = v
709 else:
708 else:
710 cmd['-r'] = v
709 cmd['-r'] = v
711
710
712 ui.status((bytes(cmd)), "\n")
711 ui.status((bytes(cmd)), "\n")
713
712
714 def push(ui, repo, *args, **kwargs):
713 def push(ui, repo, *args, **kwargs):
715 cmdoptions = [
714 cmdoptions = [
716 ('', 'all', None, ''),
715 ('', 'all', None, ''),
717 ('f', 'force', None, ''),
716 ('f', 'force', None, ''),
718 ]
717 ]
719 args, opts = parseoptions(ui, cmdoptions, args)
718 args, opts = parseoptions(ui, cmdoptions, args)
720
719
721 cmd = Command('push')
720 cmd = Command('push')
722
721
723 if len(args) > 0:
722 if len(args) > 0:
724 cmd.append(args[0])
723 cmd.append(args[0])
725 if len(args) > 1:
724 if len(args) > 1:
726 ui.status(_("note: Mercurial doesn't have refspecs. "
725 ui.status(_("note: Mercurial doesn't have refspecs. "
727 "-r can be used to specify which commits you want "
726 "-r can be used to specify which commits you want "
728 "to push. -B can be used to specify which bookmark "
727 "to push. -B can be used to specify which bookmark "
729 "you want to push.\n\n"))
728 "you want to push.\n\n"))
730 for v in args[1:]:
729 for v in args[1:]:
731 if v in repo._bookmarks:
730 if v in repo._bookmarks:
732 cmd['-B'] = v
731 cmd['-B'] = v
733 else:
732 else:
734 cmd['-r'] = v
733 cmd['-r'] = v
735
734
736 if opts.get('force'):
735 if opts.get('force'):
737 cmd['-f'] = None
736 cmd['-f'] = None
738
737
739 ui.status((bytes(cmd)), "\n")
738 ui.status((bytes(cmd)), "\n")
740
739
741 def rebase(ui, repo, *args, **kwargs):
740 def rebase(ui, repo, *args, **kwargs):
742 cmdoptions = [
741 cmdoptions = [
743 ('', 'all', None, ''),
742 ('', 'all', None, ''),
744 ('i', 'interactive', None, ''),
743 ('i', 'interactive', None, ''),
745 ('', 'onto', '', ''),
744 ('', 'onto', '', ''),
746 ('', 'abort', None, ''),
745 ('', 'abort', None, ''),
747 ('', 'continue', None, ''),
746 ('', 'continue', None, ''),
748 ('', 'skip', None, ''),
747 ('', 'skip', None, ''),
749 ]
748 ]
750 args, opts = parseoptions(ui, cmdoptions, args)
749 args, opts = parseoptions(ui, cmdoptions, args)
751
750
752 if opts.get('interactive'):
751 if opts.get('interactive'):
753 ui.status(_("note: hg histedit does not perform a rebase. "
752 ui.status(_("note: hg histedit does not perform a rebase. "
754 "It just edits history.\n\n"))
753 "It just edits history.\n\n"))
755 cmd = Command('histedit')
754 cmd = Command('histedit')
756 if len(args) > 0:
755 if len(args) > 0:
757 ui.status(_("also note: 'hg histedit' will automatically detect"
756 ui.status(_("also note: 'hg histedit' will automatically detect"
758 " your stack, so no second argument is necessary.\n\n"))
757 " your stack, so no second argument is necessary.\n\n"))
759 ui.status((bytes(cmd)), "\n")
758 ui.status((bytes(cmd)), "\n")
760 return
759 return
761
760
762 if opts.get('skip'):
761 if opts.get('skip'):
763 cmd = Command('revert --all -r .')
762 cmd = Command('revert --all -r .')
764 ui.status((bytes(cmd)), "\n")
763 ui.status((bytes(cmd)), "\n")
765
764
766 cmd = Command('rebase')
765 cmd = Command('rebase')
767
766
768 if opts.get('continue') or opts.get('skip'):
767 if opts.get('continue') or opts.get('skip'):
769 cmd['--continue'] = None
768 cmd['--continue'] = None
770 if opts.get('abort'):
769 if opts.get('abort'):
771 cmd['--abort'] = None
770 cmd['--abort'] = None
772
771
773 if opts.get('onto'):
772 if opts.get('onto'):
774 ui.status(_("note: if you're trying to lift a commit off one branch, "
773 ui.status(_("note: if you're trying to lift a commit off one branch, "
775 "try hg rebase -d <destination commit> -s <commit to be "
774 "try hg rebase -d <destination commit> -s <commit to be "
776 "lifted>\n\n"))
775 "lifted>\n\n"))
777 cmd['-d'] = convert(opts.get('onto'))
776 cmd['-d'] = convert(opts.get('onto'))
778 if len(args) < 2:
777 if len(args) < 2:
779 raise error.Abort(_("expected format: git rebase --onto X Y Z"))
778 raise error.Abort(_("expected format: git rebase --onto X Y Z"))
780 cmd['-s'] = "'::%s - ::%s'" % (convert(args[1]), convert(args[0]))
779 cmd['-s'] = "'::%s - ::%s'" % (convert(args[1]), convert(args[0]))
781 else:
780 else:
782 if len(args) == 1:
781 if len(args) == 1:
783 cmd['-d'] = convert(args[0])
782 cmd['-d'] = convert(args[0])
784 elif len(args) == 2:
783 elif len(args) == 2:
785 cmd['-d'] = convert(args[0])
784 cmd['-d'] = convert(args[0])
786 cmd['-b'] = convert(args[1])
785 cmd['-b'] = convert(args[1])
787
786
788 ui.status((bytes(cmd)), "\n")
787 ui.status((bytes(cmd)), "\n")
789
788
790 def reflog(ui, repo, *args, **kwargs):
789 def reflog(ui, repo, *args, **kwargs):
791 cmdoptions = [
790 cmdoptions = [
792 ('', 'all', None, ''),
791 ('', 'all', None, ''),
793 ]
792 ]
794 args, opts = parseoptions(ui, cmdoptions, args)
793 args, opts = parseoptions(ui, cmdoptions, args)
795
794
796 cmd = Command('journal')
795 cmd = Command('journal')
797 if opts.get('all'):
796 if opts.get('all'):
798 cmd['--all'] = None
797 cmd['--all'] = None
799 if len(args) > 0:
798 if len(args) > 0:
800 cmd.append(args[0])
799 cmd.append(args[0])
801
800
802 ui.status(bytes(cmd), "\n\n")
801 ui.status(bytes(cmd), "\n\n")
803 ui.status(_("note: in hg commits can be deleted from repo but we always"
802 ui.status(_("note: in hg commits can be deleted from repo but we always"
804 " have backups.\n"))
803 " have backups.\n"))
805
804
806 def reset(ui, repo, *args, **kwargs):
805 def reset(ui, repo, *args, **kwargs):
807 cmdoptions = [
806 cmdoptions = [
808 ('', 'soft', None, ''),
807 ('', 'soft', None, ''),
809 ('', 'hard', None, ''),
808 ('', 'hard', None, ''),
810 ('', 'mixed', None, ''),
809 ('', 'mixed', None, ''),
811 ]
810 ]
812 args, opts = parseoptions(ui, cmdoptions, args)
811 args, opts = parseoptions(ui, cmdoptions, args)
813
812
814 commit = convert(args[0] if len(args) > 0 else '.')
813 commit = convert(args[0] if len(args) > 0 else '.')
815 hard = opts.get('hard')
814 hard = opts.get('hard')
816
815
817 if opts.get('mixed'):
816 if opts.get('mixed'):
818 ui.status(_('note: --mixed has no meaning since Mercurial has no '
817 ui.status(_('note: --mixed has no meaning since Mercurial has no '
819 'staging area\n\n'))
818 'staging area\n\n'))
820 if opts.get('soft'):
819 if opts.get('soft'):
821 ui.status(_('note: --soft has no meaning since Mercurial has no '
820 ui.status(_('note: --soft has no meaning since Mercurial has no '
822 'staging area\n\n'))
821 'staging area\n\n'))
823
822
824 cmd = Command('update')
823 cmd = Command('update')
825 if hard:
824 if hard:
826 cmd.append('--clean')
825 cmd.append('--clean')
827
826
828 cmd.append(commit)
827 cmd.append(commit)
829
828
830 ui.status((bytes(cmd)), "\n")
829 ui.status((bytes(cmd)), "\n")
831
830
832 def revert(ui, repo, *args, **kwargs):
831 def revert(ui, repo, *args, **kwargs):
833 cmdoptions = [
832 cmdoptions = [
834 ]
833 ]
835 args, opts = parseoptions(ui, cmdoptions, args)
834 args, opts = parseoptions(ui, cmdoptions, args)
836
835
837 if len(args) > 1:
836 if len(args) > 1:
838 ui.status(_("note: hg backout doesn't support multiple commits at "
837 ui.status(_("note: hg backout doesn't support multiple commits at "
839 "once\n\n"))
838 "once\n\n"))
840
839
841 cmd = Command('backout')
840 cmd = Command('backout')
842 if args:
841 if args:
843 cmd.append(args[0])
842 cmd.append(args[0])
844
843
845 ui.status((bytes(cmd)), "\n")
844 ui.status((bytes(cmd)), "\n")
846
845
847 def revparse(ui, repo, *args, **kwargs):
846 def revparse(ui, repo, *args, **kwargs):
848 cmdoptions = [
847 cmdoptions = [
849 ('', 'show-cdup', None, ''),
848 ('', 'show-cdup', None, ''),
850 ('', 'show-toplevel', None, ''),
849 ('', 'show-toplevel', None, ''),
851 ]
850 ]
852 args, opts = parseoptions(ui, cmdoptions, args)
851 args, opts = parseoptions(ui, cmdoptions, args)
853
852
854 if opts.get('show_cdup') or opts.get('show_toplevel'):
853 if opts.get('show_cdup') or opts.get('show_toplevel'):
855 cmd = Command('root')
854 cmd = Command('root')
856 if opts.get('show_cdup'):
855 if opts.get('show_cdup'):
857 ui.status(_("note: hg root prints the root of the repository\n\n"))
856 ui.status(_("note: hg root prints the root of the repository\n\n"))
858 ui.status((bytes(cmd)), "\n")
857 ui.status((bytes(cmd)), "\n")
859 else:
858 else:
860 ui.status(_("note: see hg help revset for how to refer to commits\n"))
859 ui.status(_("note: see hg help revset for how to refer to commits\n"))
861
860
862 def rm(ui, repo, *args, **kwargs):
861 def rm(ui, repo, *args, **kwargs):
863 cmdoptions = [
862 cmdoptions = [
864 ('f', 'force', None, ''),
863 ('f', 'force', None, ''),
865 ('n', 'dry-run', None, ''),
864 ('n', 'dry-run', None, ''),
866 ]
865 ]
867 args, opts = parseoptions(ui, cmdoptions, args)
866 args, opts = parseoptions(ui, cmdoptions, args)
868
867
869 cmd = Command('rm')
868 cmd = Command('rm')
870 cmd.extend(args)
869 cmd.extend(args)
871
870
872 if opts.get('force'):
871 if opts.get('force'):
873 cmd['-f'] = None
872 cmd['-f'] = None
874 if opts.get('dry_run'):
873 if opts.get('dry_run'):
875 cmd['-n'] = None
874 cmd['-n'] = None
876
875
877 ui.status((bytes(cmd)), "\n")
876 ui.status((bytes(cmd)), "\n")
878
877
879 def show(ui, repo, *args, **kwargs):
878 def show(ui, repo, *args, **kwargs):
880 cmdoptions = [
879 cmdoptions = [
881 ('', 'name-status', None, ''),
880 ('', 'name-status', None, ''),
882 ('', 'pretty', '', ''),
881 ('', 'pretty', '', ''),
883 ('U', 'unified', int, ''),
882 ('U', 'unified', int, ''),
884 ]
883 ]
885 args, opts = parseoptions(ui, cmdoptions, args)
884 args, opts = parseoptions(ui, cmdoptions, args)
886
885
887 if opts.get('name_status'):
886 if opts.get('name_status'):
888 if opts.get('pretty') == 'format:':
887 if opts.get('pretty') == 'format:':
889 cmd = Command('status')
888 cmd = Command('status')
890 cmd['--change'] = '.'
889 cmd['--change'] = '.'
891 else:
890 else:
892 cmd = Command('log')
891 cmd = Command('log')
893 cmd.append('--style status')
892 cmd.append('--style status')
894 cmd.append('-r .')
893 cmd.append('-r .')
895 elif len(args) > 0:
894 elif len(args) > 0:
896 if ispath(repo, args[0]):
895 if ispath(repo, args[0]):
897 cmd = Command('cat')
896 cmd = Command('cat')
898 else:
897 else:
899 cmd = Command('export')
898 cmd = Command('export')
900 cmd.extend(args)
899 cmd.extend(args)
901 if opts.get('unified'):
900 if opts.get('unified'):
902 cmd.append('--config diff.unified=%d' % (opts['unified'],))
901 cmd.append('--config diff.unified=%d' % (opts['unified'],))
903 elif opts.get('unified'):
902 elif opts.get('unified'):
904 cmd = Command('export')
903 cmd = Command('export')
905 cmd.append('--config diff.unified=%d' % (opts['unified'],))
904 cmd.append('--config diff.unified=%d' % (opts['unified'],))
906 else:
905 else:
907 cmd = Command('export')
906 cmd = Command('export')
908
907
909 ui.status((bytes(cmd)), "\n")
908 ui.status((bytes(cmd)), "\n")
910
909
911 def stash(ui, repo, *args, **kwargs):
910 def stash(ui, repo, *args, **kwargs):
912 cmdoptions = [
911 cmdoptions = [
913 ]
912 ]
914 args, opts = parseoptions(ui, cmdoptions, args)
913 args, opts = parseoptions(ui, cmdoptions, args)
915
914
916 cmd = Command('shelve')
915 cmd = Command('shelve')
917 action = args[0] if len(args) > 0 else None
916 action = args[0] if len(args) > 0 else None
918
917
919 if action == 'list':
918 if action == 'list':
920 cmd['-l'] = None
919 cmd['-l'] = None
921 elif action == 'drop':
920 elif action == 'drop':
922 cmd['-d'] = None
921 cmd['-d'] = None
923 if len(args) > 1:
922 if len(args) > 1:
924 cmd.append(args[1])
923 cmd.append(args[1])
925 else:
924 else:
926 cmd.append('<shelve name>')
925 cmd.append('<shelve name>')
927 elif action == 'pop' or action == 'apply':
926 elif action == 'pop' or action == 'apply':
928 cmd = Command('unshelve')
927 cmd = Command('unshelve')
929 if len(args) > 1:
928 if len(args) > 1:
930 cmd.append(args[1])
929 cmd.append(args[1])
931 if action == 'apply':
930 if action == 'apply':
932 cmd['--keep'] = None
931 cmd['--keep'] = None
933 elif (action == 'branch' or action == 'show' or action == 'clear'
932 elif (action == 'branch' or action == 'show' or action == 'clear'
934 or action == 'create'):
933 or action == 'create'):
935 ui.status(_("note: Mercurial doesn't have equivalents to the "
934 ui.status(_("note: Mercurial doesn't have equivalents to the "
936 "git stash branch, show, clear, or create actions.\n\n"))
935 "git stash branch, show, clear, or create actions.\n\n"))
937 return
936 return
938 else:
937 else:
939 if len(args) > 0:
938 if len(args) > 0:
940 if args[0] != 'save':
939 if args[0] != 'save':
941 cmd['--name'] = args[0]
940 cmd['--name'] = args[0]
942 elif len(args) > 1:
941 elif len(args) > 1:
943 cmd['--name'] = args[1]
942 cmd['--name'] = args[1]
944
943
945 ui.status((bytes(cmd)), "\n")
944 ui.status((bytes(cmd)), "\n")
946
945
947 def status(ui, repo, *args, **kwargs):
946 def status(ui, repo, *args, **kwargs):
948 cmdoptions = [
947 cmdoptions = [
949 ('', 'ignored', None, ''),
948 ('', 'ignored', None, ''),
950 ]
949 ]
951 args, opts = parseoptions(ui, cmdoptions, args)
950 args, opts = parseoptions(ui, cmdoptions, args)
952
951
953 cmd = Command('status')
952 cmd = Command('status')
954 cmd.extend(args)
953 cmd.extend(args)
955
954
956 if opts.get('ignored'):
955 if opts.get('ignored'):
957 cmd['-i'] = None
956 cmd['-i'] = None
958
957
959 ui.status((bytes(cmd)), "\n")
958 ui.status((bytes(cmd)), "\n")
960
959
961 def svn(ui, repo, *args, **kwargs):
960 def svn(ui, repo, *args, **kwargs):
962 if not args:
961 if not args:
963 raise error.Abort(_('missing svn command'))
962 raise error.Abort(_('missing svn command'))
964 svncmd = args[0]
963 svncmd = args[0]
965 if svncmd not in gitsvncommands:
964 if svncmd not in gitsvncommands:
966 raise error.Abort(_('unknown git svn command "%s"') % (svncmd))
965 raise error.Abort(_('unknown git svn command "%s"') % (svncmd))
967
966
968 args = args[1:]
967 args = args[1:]
969 return gitsvncommands[svncmd](ui, repo, *args, **kwargs)
968 return gitsvncommands[svncmd](ui, repo, *args, **kwargs)
970
969
971 def svndcommit(ui, repo, *args, **kwargs):
970 def svndcommit(ui, repo, *args, **kwargs):
972 cmdoptions = [
971 cmdoptions = [
973 ]
972 ]
974 args, opts = parseoptions(ui, cmdoptions, args)
973 args, opts = parseoptions(ui, cmdoptions, args)
975
974
976 cmd = Command('push')
975 cmd = Command('push')
977
976
978 ui.status((bytes(cmd)), "\n")
977 ui.status((bytes(cmd)), "\n")
979
978
980 def svnfetch(ui, repo, *args, **kwargs):
979 def svnfetch(ui, repo, *args, **kwargs):
981 cmdoptions = [
980 cmdoptions = [
982 ]
981 ]
983 args, opts = parseoptions(ui, cmdoptions, args)
982 args, opts = parseoptions(ui, cmdoptions, args)
984
983
985 cmd = Command('pull')
984 cmd = Command('pull')
986 cmd.append('default-push')
985 cmd.append('default-push')
987
986
988 ui.status((bytes(cmd)), "\n")
987 ui.status((bytes(cmd)), "\n")
989
988
990 def svnfindrev(ui, repo, *args, **kwargs):
989 def svnfindrev(ui, repo, *args, **kwargs):
991 cmdoptions = [
990 cmdoptions = [
992 ]
991 ]
993 args, opts = parseoptions(ui, cmdoptions, args)
992 args, opts = parseoptions(ui, cmdoptions, args)
994
993
995 if not args:
994 if not args:
996 raise error.Abort(_('missing find-rev argument'))
995 raise error.Abort(_('missing find-rev argument'))
997
996
998 cmd = Command('log')
997 cmd = Command('log')
999 cmd['-r'] = args[0]
998 cmd['-r'] = args[0]
1000
999
1001 ui.status((bytes(cmd)), "\n")
1000 ui.status((bytes(cmd)), "\n")
1002
1001
1003 def svnrebase(ui, repo, *args, **kwargs):
1002 def svnrebase(ui, repo, *args, **kwargs):
1004 cmdoptions = [
1003 cmdoptions = [
1005 ('l', 'local', None, ''),
1004 ('l', 'local', None, ''),
1006 ]
1005 ]
1007 args, opts = parseoptions(ui, cmdoptions, args)
1006 args, opts = parseoptions(ui, cmdoptions, args)
1008
1007
1009 pullcmd = Command('pull')
1008 pullcmd = Command('pull')
1010 pullcmd.append('default-push')
1009 pullcmd.append('default-push')
1011 rebasecmd = Command('rebase')
1010 rebasecmd = Command('rebase')
1012 rebasecmd.append('tip')
1011 rebasecmd.append('tip')
1013
1012
1014 cmd = pullcmd & rebasecmd
1013 cmd = pullcmd & rebasecmd
1015
1014
1016 ui.status((bytes(cmd)), "\n")
1015 ui.status((bytes(cmd)), "\n")
1017
1016
1018 def tag(ui, repo, *args, **kwargs):
1017 def tag(ui, repo, *args, **kwargs):
1019 cmdoptions = [
1018 cmdoptions = [
1020 ('f', 'force', None, ''),
1019 ('f', 'force', None, ''),
1021 ('l', 'list', None, ''),
1020 ('l', 'list', None, ''),
1022 ('d', 'delete', None, ''),
1021 ('d', 'delete', None, ''),
1023 ]
1022 ]
1024 args, opts = parseoptions(ui, cmdoptions, args)
1023 args, opts = parseoptions(ui, cmdoptions, args)
1025
1024
1026 if opts.get('list'):
1025 if opts.get('list'):
1027 cmd = Command('tags')
1026 cmd = Command('tags')
1028 else:
1027 else:
1029 cmd = Command('tag')
1028 cmd = Command('tag')
1030
1029
1031 if not args:
1030 if not args:
1032 raise error.Abort(_('missing tag argument'))
1031 raise error.Abort(_('missing tag argument'))
1033
1032
1034 cmd.append(args[0])
1033 cmd.append(args[0])
1035 if len(args) > 1:
1034 if len(args) > 1:
1036 cmd['-r'] = args[1]
1035 cmd['-r'] = args[1]
1037
1036
1038 if opts.get('delete'):
1037 if opts.get('delete'):
1039 cmd['--remove'] = None
1038 cmd['--remove'] = None
1040
1039
1041 if opts.get('force'):
1040 if opts.get('force'):
1042 cmd['-f'] = None
1041 cmd['-f'] = None
1043
1042
1044 ui.status((bytes(cmd)), "\n")
1043 ui.status((bytes(cmd)), "\n")
1045
1044
1046 gitcommands = {
1045 gitcommands = {
1047 'add': add,
1046 'add': add,
1048 'am': am,
1047 'am': am,
1049 'apply': apply,
1048 'apply': apply,
1050 'bisect': bisect,
1049 'bisect': bisect,
1051 'blame': blame,
1050 'blame': blame,
1052 'branch': branch,
1051 'branch': branch,
1053 'checkout': checkout,
1052 'checkout': checkout,
1054 'cherry-pick': cherrypick,
1053 'cherry-pick': cherrypick,
1055 'clean': clean,
1054 'clean': clean,
1056 'clone': clone,
1055 'clone': clone,
1057 'commit': commit,
1056 'commit': commit,
1058 'diff': diff,
1057 'diff': diff,
1059 'difftool': difftool,
1058 'difftool': difftool,
1060 'fetch': fetch,
1059 'fetch': fetch,
1061 'grep': grep,
1060 'grep': grep,
1062 'init': init,
1061 'init': init,
1063 'log': log,
1062 'log': log,
1064 'ls-files': lsfiles,
1063 'ls-files': lsfiles,
1065 'merge': merge,
1064 'merge': merge,
1066 'merge-base': mergebase,
1065 'merge-base': mergebase,
1067 'mergetool': mergetool,
1066 'mergetool': mergetool,
1068 'mv': mv,
1067 'mv': mv,
1069 'pull': pull,
1068 'pull': pull,
1070 'push': push,
1069 'push': push,
1071 'rebase': rebase,
1070 'rebase': rebase,
1072 'reflog': reflog,
1071 'reflog': reflog,
1073 'reset': reset,
1072 'reset': reset,
1074 'revert': revert,
1073 'revert': revert,
1075 'rev-parse': revparse,
1074 'rev-parse': revparse,
1076 'rm': rm,
1075 'rm': rm,
1077 'show': show,
1076 'show': show,
1078 'stash': stash,
1077 'stash': stash,
1079 'status': status,
1078 'status': status,
1080 'svn': svn,
1079 'svn': svn,
1081 'tag': tag,
1080 'tag': tag,
1082 'whatchanged': deprecated,
1081 'whatchanged': deprecated,
1083 }
1082 }
1084
1083
1085 gitsvncommands = {
1084 gitsvncommands = {
1086 'dcommit': svndcommit,
1085 'dcommit': svndcommit,
1087 'fetch': svnfetch,
1086 'fetch': svnfetch,
1088 'find-rev': svnfindrev,
1087 'find-rev': svnfindrev,
1089 'rebase': svnrebase,
1088 'rebase': svnrebase,
1090 }
1089 }
@@ -1,296 +1,296 b''
1 $ cat >> $HGRCPATH << EOF
1 $ cat >> $HGRCPATH << EOF
2 > [extensions]
2 > [extensions]
3 > githelp =
3 > githelp =
4 > EOF
4 > EOF
5
5
6 $ hg init repo
6 $ hg init repo
7 $ cd repo
7 $ cd repo
8 $ echo foo > test_file
8 $ echo foo > test_file
9 $ mkdir dir
9 $ mkdir dir
10 $ echo foo > dir/file
10 $ echo foo > dir/file
11 $ echo foo > removed_file
11 $ echo foo > removed_file
12 $ echo foo > deleted_file
12 $ echo foo > deleted_file
13 $ hg add -q .
13 $ hg add -q .
14 $ hg commit -m 'bar'
14 $ hg commit -m 'bar'
15 $ hg bookmark both
15 $ hg bookmark both
16 $ touch both
16 $ touch both
17 $ touch untracked_file
17 $ touch untracked_file
18 $ hg remove removed_file
18 $ hg remove removed_file
19 $ rm deleted_file
19 $ rm deleted_file
20
20
21 githelp on a single command should succeed
21 githelp on a single command should succeed
22 $ hg githelp -- commit
22 $ hg githelp -- commit
23 hg commit
23 hg commit
24 $ hg githelp -- git commit
24 $ hg githelp -- git commit
25 hg commit
25 hg commit
26
26
27 githelp should fail nicely if we don't give it arguments
27 githelp should fail nicely if we don't give it arguments
28 $ hg githelp
28 $ hg githelp
29 abort: missing git command - usage: hg githelp -- <git command>
29 abort: missing git command - usage: hg githelp -- <git command>
30 [255]
30 [255]
31 $ hg githelp -- git
31 $ hg githelp -- git
32 abort: missing git command - usage: hg githelp -- <git command>
32 abort: missing git command - usage: hg githelp -- <git command>
33 [255]
33 [255]
34
34
35 githelp on a command with options should succeed
35 githelp on a command with options should succeed
36 $ hg githelp -- commit -pm "abc"
36 $ hg githelp -- commit -pm "abc"
37 hg commit --interactive -m 'abc'
37 hg commit --interactive -m 'abc'
38
38
39 githelp on a command with standalone unrecognized option should succeed with warning
39 githelp on a command with standalone unrecognized option should succeed with warning
40 $ hg githelp -- commit -p -v
40 $ hg githelp -- commit -p -v
41 ignoring unknown option -v
41 ignoring unknown option -v
42 hg commit --interactive
42 hg commit --interactive
43
43
44 githelp on a command with unrecognized option packed with other options should fail with error
44 githelp on a command with unrecognized option packed with other options should fail with error
45 $ hg githelp -- commit -pv
45 $ hg githelp -- commit -pv
46 abort: unknown option v packed with other options
46 abort: unknown option 'v' packed with other options
47 Please try passing the option as it's own flag: -v
47 (please try passing the option as its own flag: -v)
48 [255]
48 [255]
49
49
50 githelp for git rebase --skip
50 githelp for git rebase --skip
51 $ hg githelp -- git rebase --skip
51 $ hg githelp -- git rebase --skip
52 hg revert --all -r .
52 hg revert --all -r .
53 hg rebase --continue
53 hg rebase --continue
54
54
55 githelp for git commit --amend (hg commit --amend pulls up an editor)
55 githelp for git commit --amend (hg commit --amend pulls up an editor)
56 $ hg githelp -- commit --amend
56 $ hg githelp -- commit --amend
57 hg commit --amend
57 hg commit --amend
58
58
59 githelp for git commit --amend --no-edit (hg amend does not pull up an editor)
59 githelp for git commit --amend --no-edit (hg amend does not pull up an editor)
60 $ hg githelp -- commit --amend --no-edit
60 $ hg githelp -- commit --amend --no-edit
61 hg amend
61 hg amend
62
62
63 githelp for git checkout -- . (checking out a directory)
63 githelp for git checkout -- . (checking out a directory)
64 $ hg githelp -- checkout -- .
64 $ hg githelp -- checkout -- .
65 note: use --no-backup to avoid creating .orig files
65 note: use --no-backup to avoid creating .orig files
66
66
67 hg revert .
67 hg revert .
68
68
69 githelp for git checkout "HEAD^" (should still work to pass a rev)
69 githelp for git checkout "HEAD^" (should still work to pass a rev)
70 $ hg githelp -- checkout "HEAD^"
70 $ hg githelp -- checkout "HEAD^"
71 hg update .^
71 hg update .^
72
72
73 githelp checkout: args after -- should be treated as paths no matter what
73 githelp checkout: args after -- should be treated as paths no matter what
74 $ hg githelp -- checkout -- HEAD
74 $ hg githelp -- checkout -- HEAD
75 note: use --no-backup to avoid creating .orig files
75 note: use --no-backup to avoid creating .orig files
76
76
77 hg revert HEAD
77 hg revert HEAD
78
78
79 githelp for git checkout with rev and path
79 githelp for git checkout with rev and path
80 $ hg githelp -- checkout "HEAD^" -- file.txt
80 $ hg githelp -- checkout "HEAD^" -- file.txt
81 note: use --no-backup to avoid creating .orig files
81 note: use --no-backup to avoid creating .orig files
82
82
83 hg revert -r .^ file.txt
83 hg revert -r .^ file.txt
84
84
85 githelp for git with rev and path, without separator
85 githelp for git with rev and path, without separator
86 $ hg githelp -- checkout "HEAD^" file.txt
86 $ hg githelp -- checkout "HEAD^" file.txt
87 note: use --no-backup to avoid creating .orig files
87 note: use --no-backup to avoid creating .orig files
88
88
89 hg revert -r .^ file.txt
89 hg revert -r .^ file.txt
90
90
91 githelp for checkout with a file as first argument
91 githelp for checkout with a file as first argument
92 $ hg githelp -- checkout test_file
92 $ hg githelp -- checkout test_file
93 note: use --no-backup to avoid creating .orig files
93 note: use --no-backup to avoid creating .orig files
94
94
95 hg revert test_file
95 hg revert test_file
96
96
97 githelp for checkout with a removed file as first argument
97 githelp for checkout with a removed file as first argument
98 $ hg githelp -- checkout removed_file
98 $ hg githelp -- checkout removed_file
99 note: use --no-backup to avoid creating .orig files
99 note: use --no-backup to avoid creating .orig files
100
100
101 hg revert removed_file
101 hg revert removed_file
102
102
103 githelp for checkout with a deleted file as first argument
103 githelp for checkout with a deleted file as first argument
104 $ hg githelp -- checkout deleted_file
104 $ hg githelp -- checkout deleted_file
105 note: use --no-backup to avoid creating .orig files
105 note: use --no-backup to avoid creating .orig files
106
106
107 hg revert deleted_file
107 hg revert deleted_file
108
108
109 githelp for checkout with a untracked file as first argument
109 githelp for checkout with a untracked file as first argument
110 $ hg githelp -- checkout untracked_file
110 $ hg githelp -- checkout untracked_file
111 note: use --no-backup to avoid creating .orig files
111 note: use --no-backup to avoid creating .orig files
112
112
113 hg revert untracked_file
113 hg revert untracked_file
114
114
115 githelp for checkout with a directory as first argument
115 githelp for checkout with a directory as first argument
116 $ hg githelp -- checkout dir
116 $ hg githelp -- checkout dir
117 note: use --no-backup to avoid creating .orig files
117 note: use --no-backup to avoid creating .orig files
118
118
119 hg revert dir
119 hg revert dir
120
120
121 githelp for checkout when not in repo root
121 githelp for checkout when not in repo root
122 $ cd dir
122 $ cd dir
123 $ hg githelp -- checkout file
123 $ hg githelp -- checkout file
124 note: use --no-backup to avoid creating .orig files
124 note: use --no-backup to avoid creating .orig files
125
125
126 hg revert file
126 hg revert file
127
127
128 $ cd ..
128 $ cd ..
129
129
130 githelp for checkout with an argument that is both a file and a revision
130 githelp for checkout with an argument that is both a file and a revision
131 $ hg githelp -- checkout both
131 $ hg githelp -- checkout both
132 hg update both
132 hg update both
133
133
134 githelp for checkout with the -p option
134 githelp for checkout with the -p option
135 $ hg githelp -- git checkout -p xyz
135 $ hg githelp -- git checkout -p xyz
136 hg revert -i -r xyz
136 hg revert -i -r xyz
137
137
138 $ hg githelp -- git checkout -p xyz -- abc
138 $ hg githelp -- git checkout -p xyz -- abc
139 note: use --no-backup to avoid creating .orig files
139 note: use --no-backup to avoid creating .orig files
140
140
141 hg revert -i -r xyz abc
141 hg revert -i -r xyz abc
142
142
143 githelp for checkout with the -f option and a rev
143 githelp for checkout with the -f option and a rev
144 $ hg githelp -- git checkout -f xyz
144 $ hg githelp -- git checkout -f xyz
145 hg update -C xyz
145 hg update -C xyz
146 $ hg githelp -- git checkout --force xyz
146 $ hg githelp -- git checkout --force xyz
147 hg update -C xyz
147 hg update -C xyz
148
148
149 githelp for checkout with the -f option without an arg
149 githelp for checkout with the -f option without an arg
150 $ hg githelp -- git checkout -f
150 $ hg githelp -- git checkout -f
151 hg revert --all
151 hg revert --all
152 $ hg githelp -- git checkout --force
152 $ hg githelp -- git checkout --force
153 hg revert --all
153 hg revert --all
154
154
155 githelp for grep with pattern and path
155 githelp for grep with pattern and path
156 $ hg githelp -- grep shrubbery flib/intern/
156 $ hg githelp -- grep shrubbery flib/intern/
157 hg grep shrubbery flib/intern/
157 hg grep shrubbery flib/intern/
158
158
159 githelp for reset, checking ~ in git becomes ~1 in mercurial
159 githelp for reset, checking ~ in git becomes ~1 in mercurial
160 $ hg githelp -- reset HEAD~
160 $ hg githelp -- reset HEAD~
161 hg update .~1
161 hg update .~1
162 $ hg githelp -- reset "HEAD^"
162 $ hg githelp -- reset "HEAD^"
163 hg update .^
163 hg update .^
164 $ hg githelp -- reset HEAD~3
164 $ hg githelp -- reset HEAD~3
165 hg update .~3
165 hg update .~3
166
166
167 $ hg githelp -- reset --mixed HEAD
167 $ hg githelp -- reset --mixed HEAD
168 note: --mixed has no meaning since Mercurial has no staging area
168 note: --mixed has no meaning since Mercurial has no staging area
169
169
170 hg update .
170 hg update .
171 $ hg githelp -- reset --soft HEAD
171 $ hg githelp -- reset --soft HEAD
172 note: --soft has no meaning since Mercurial has no staging area
172 note: --soft has no meaning since Mercurial has no staging area
173
173
174 hg update .
174 hg update .
175 $ hg githelp -- reset --hard HEAD
175 $ hg githelp -- reset --hard HEAD
176 hg update --clean .
176 hg update --clean .
177
177
178 githelp for git show --name-status
178 githelp for git show --name-status
179 $ hg githelp -- git show --name-status
179 $ hg githelp -- git show --name-status
180 hg log --style status -r .
180 hg log --style status -r .
181
181
182 githelp for git show --pretty=format: --name-status
182 githelp for git show --pretty=format: --name-status
183 $ hg githelp -- git show --pretty=format: --name-status
183 $ hg githelp -- git show --pretty=format: --name-status
184 hg status --change .
184 hg status --change .
185
185
186 githelp for show with no arguments
186 githelp for show with no arguments
187 $ hg githelp -- show
187 $ hg githelp -- show
188 hg export
188 hg export
189
189
190 githelp for show with a path
190 githelp for show with a path
191 $ hg githelp -- show test_file
191 $ hg githelp -- show test_file
192 hg cat test_file
192 hg cat test_file
193
193
194 githelp for show with not a path:
194 githelp for show with not a path:
195 $ hg githelp -- show rev
195 $ hg githelp -- show rev
196 hg export rev
196 hg export rev
197
197
198 githelp for show with many arguments
198 githelp for show with many arguments
199 $ hg githelp -- show argone argtwo
199 $ hg githelp -- show argone argtwo
200 hg export argone argtwo
200 hg export argone argtwo
201 $ hg githelp -- show test_file argone argtwo
201 $ hg githelp -- show test_file argone argtwo
202 hg cat test_file argone argtwo
202 hg cat test_file argone argtwo
203
203
204 githelp for show with --unified options
204 githelp for show with --unified options
205 $ hg githelp -- show --unified=10
205 $ hg githelp -- show --unified=10
206 hg export --config diff.unified=10
206 hg export --config diff.unified=10
207 $ hg githelp -- show -U100
207 $ hg githelp -- show -U100
208 hg export --config diff.unified=100
208 hg export --config diff.unified=100
209
209
210 githelp for show with a path and --unified
210 githelp for show with a path and --unified
211 $ hg githelp -- show -U20 test_file
211 $ hg githelp -- show -U20 test_file
212 hg cat test_file --config diff.unified=20
212 hg cat test_file --config diff.unified=20
213
213
214 githelp for stash drop without name
214 githelp for stash drop without name
215 $ hg githelp -- git stash drop
215 $ hg githelp -- git stash drop
216 hg shelve -d <shelve name>
216 hg shelve -d <shelve name>
217
217
218 githelp for stash drop with name
218 githelp for stash drop with name
219 $ hg githelp -- git stash drop xyz
219 $ hg githelp -- git stash drop xyz
220 hg shelve -d xyz
220 hg shelve -d xyz
221
221
222 githelp for whatchanged should show deprecated message
222 githelp for whatchanged should show deprecated message
223 $ hg githelp -- whatchanged -p
223 $ hg githelp -- whatchanged -p
224 this command has been deprecated in the git project, thus isn't supported by this tool.
224 this command has been deprecated in the git project, thus isn't supported by this tool.
225
225
226
226
227 githelp for git branch -m renaming
227 githelp for git branch -m renaming
228 $ hg githelp -- git branch -m old new
228 $ hg githelp -- git branch -m old new
229 hg bookmark -m old new
229 hg bookmark -m old new
230
230
231 When the old name is omitted, git branch -m new renames the current branch.
231 When the old name is omitted, git branch -m new renames the current branch.
232 $ hg githelp -- git branch -m new
232 $ hg githelp -- git branch -m new
233 hg bookmark -m `hg log -T"{activebookmark}" -r .` new
233 hg bookmark -m `hg log -T"{activebookmark}" -r .` new
234
234
235 Branch deletion in git strips commits
235 Branch deletion in git strips commits
236 $ hg githelp -- git branch -d
236 $ hg githelp -- git branch -d
237 hg strip -B
237 hg strip -B
238 $ hg githelp -- git branch -d feature
238 $ hg githelp -- git branch -d feature
239 hg strip -B feature -B
239 hg strip -B feature -B
240 $ hg githelp -- git branch --delete experiment1 experiment2
240 $ hg githelp -- git branch --delete experiment1 experiment2
241 hg strip -B experiment1 -B experiment2 -B
241 hg strip -B experiment1 -B experiment2 -B
242
242
243 githelp for reuse message using the shorthand
243 githelp for reuse message using the shorthand
244 $ hg githelp -- git commit -C deadbeef
244 $ hg githelp -- git commit -C deadbeef
245 hg commit -M deadbeef
245 hg commit -M deadbeef
246
246
247 githelp for reuse message using the the long version
247 githelp for reuse message using the the long version
248 $ hg githelp -- git commit --reuse-message deadbeef
248 $ hg githelp -- git commit --reuse-message deadbeef
249 hg commit -M deadbeef
249 hg commit -M deadbeef
250
250
251 githelp for apply with no options
251 githelp for apply with no options
252 $ hg githelp -- apply
252 $ hg githelp -- apply
253 hg import --no-commit
253 hg import --no-commit
254
254
255 githelp for apply with directory strip custom
255 githelp for apply with directory strip custom
256 $ hg githelp -- apply -p 5
256 $ hg githelp -- apply -p 5
257 hg import --no-commit -p 5
257 hg import --no-commit -p 5
258
258
259 git merge-base
259 git merge-base
260 $ hg githelp -- git merge-base --is-ancestor
260 $ hg githelp -- git merge-base --is-ancestor
261 ignoring unknown option --is-ancestor
261 ignoring unknown option --is-ancestor
262 note: ancestors() is part of the revset language.
262 note: ancestors() is part of the revset language.
263 (learn more about revsets with 'hg help revsets')
263 (learn more about revsets with 'hg help revsets')
264
264
265 hg log -T '{node}\n' -r 'ancestor(A,B)'
265 hg log -T '{node}\n' -r 'ancestor(A,B)'
266
266
267 githelp for git blame
267 githelp for git blame
268 $ hg githelp -- git blame
268 $ hg githelp -- git blame
269 hg annotate -udl
269 hg annotate -udl
270
270
271 githelp for add
271 githelp for add
272
272
273 $ hg githelp -- git add
273 $ hg githelp -- git add
274 hg add
274 hg add
275
275
276 $ hg githelp -- git add -p
276 $ hg githelp -- git add -p
277 note: Mercurial will commit when complete, as there is no staging area in Mercurial
277 note: Mercurial will commit when complete, as there is no staging area in Mercurial
278
278
279 hg commit --interactive
279 hg commit --interactive
280
280
281 $ hg githelp -- git add --all
281 $ hg githelp -- git add --all
282 note: use hg addremove to remove files that have been deleted.
282 note: use hg addremove to remove files that have been deleted.
283
283
284 hg add
284 hg add
285
285
286 githelp for reflog
286 githelp for reflog
287
287
288 $ hg githelp -- git reflog
288 $ hg githelp -- git reflog
289 hg journal
289 hg journal
290
290
291 note: in hg commits can be deleted from repo but we always have backups.
291 note: in hg commits can be deleted from repo but we always have backups.
292
292
293 $ hg githelp -- git reflog --all
293 $ hg githelp -- git reflog --all
294 hg journal --all
294 hg journal --all
295
295
296 note: in hg commits can be deleted from repo but we always have backups.
296 note: in hg commits can be deleted from repo but we always have backups.
General Comments 0
You need to be logged in to leave comments. Login now