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