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