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