Mercurial > public > mercurial-scm > hg-stable
comparison hgext/githelp.py @ 36268:257f3651ada9
githelp: cast commands to bytes
This is more compatible with Python 3.
Differential Revision: https://phab.mercurial-scm.org/D2165
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Sun, 11 Feb 2018 17:23:58 -0800 |
parents | f50067fbeead |
children | a8a902d7176e |
comparison
equal
deleted
inserted
replaced
36267:6ea0b78ddcac | 36268:257f3651ada9 |
---|---|
20 import getopt | 20 import getopt |
21 import re | 21 import re |
22 | 22 |
23 from mercurial.i18n import _ | 23 from mercurial.i18n import _ |
24 from mercurial import ( | 24 from mercurial import ( |
25 encoding, | |
25 error, | 26 error, |
26 fancyopts, | 27 fancyopts, |
27 registrar, | 28 registrar, |
28 util, | 29 util, |
29 ) | 30 ) |
107 def __init__(self, name): | 108 def __init__(self, name): |
108 self.name = name | 109 self.name = name |
109 self.args = [] | 110 self.args = [] |
110 self.opts = {} | 111 self.opts = {} |
111 | 112 |
112 def __str__(self): | 113 def __bytes__(self): |
113 cmd = "hg " + self.name | 114 cmd = "hg " + self.name |
114 if self.opts: | 115 if self.opts: |
115 for k, values in sorted(self.opts.iteritems()): | 116 for k, values in sorted(self.opts.iteritems()): |
116 for v in values: | 117 for v in values: |
117 if v: | 118 if v: |
121 if self.args: | 122 if self.args: |
122 cmd += " " | 123 cmd += " " |
123 cmd += " ".join(self.args) | 124 cmd += " ".join(self.args) |
124 return cmd | 125 return cmd |
125 | 126 |
127 __str__ = encoding.strmethod(__bytes__) | |
128 | |
126 def append(self, value): | 129 def append(self, value): |
127 self.args.append(value) | 130 self.args.append(value) |
128 | 131 |
129 def extend(self, values): | 132 def extend(self, values): |
130 self.args.extend(values) | 133 self.args.extend(values) |
165 cmd.extend(args) | 168 cmd.extend(args) |
166 else: | 169 else: |
167 ui.status(_("note: use hg addremove to remove files that have " | 170 ui.status(_("note: use hg addremove to remove files that have " |
168 "been deleted.\n\n")) | 171 "been deleted.\n\n")) |
169 | 172 |
170 ui.status((str(cmd)), "\n") | 173 ui.status((bytes(cmd)), "\n") |
171 | 174 |
172 def am(ui, repo, *args, **kwargs): | 175 def am(ui, repo, *args, **kwargs): |
173 cmdoptions=[ | 176 cmdoptions=[ |
174 ] | 177 ] |
175 args, opts = parseoptions(ui, cmdoptions, args) | 178 args, opts = parseoptions(ui, cmdoptions, args) |
176 cmd = Command('import') | 179 cmd = Command('import') |
177 ui.status(str(cmd), "\n") | 180 ui.status(bytes(cmd), "\n") |
178 | 181 |
179 def apply(ui, repo, *args, **kwargs): | 182 def apply(ui, repo, *args, **kwargs): |
180 cmdoptions = [ | 183 cmdoptions = [ |
181 ('p', 'p', int, ''), | 184 ('p', 'p', int, ''), |
182 ] | 185 ] |
185 cmd = Command('import --no-commit') | 188 cmd = Command('import --no-commit') |
186 if (opts.get('p')): | 189 if (opts.get('p')): |
187 cmd['-p'] = opts.get('p') | 190 cmd['-p'] = opts.get('p') |
188 cmd.extend(args) | 191 cmd.extend(args) |
189 | 192 |
190 ui.status((str(cmd)), "\n") | 193 ui.status((bytes(cmd)), "\n") |
191 | 194 |
192 def bisect(ui, repo, *args, **kwargs): | 195 def bisect(ui, repo, *args, **kwargs): |
193 ui.status(_("See 'hg help bisect' for how to use bisect.\n\n")) | 196 ui.status(_("See 'hg help bisect' for how to use bisect.\n\n")) |
194 | 197 |
195 def blame(ui, repo, *args, **kwargs): | 198 def blame(ui, repo, *args, **kwargs): |
196 cmdoptions = [ | 199 cmdoptions = [ |
197 ] | 200 ] |
198 args, opts = parseoptions(ui, cmdoptions, args) | 201 args, opts = parseoptions(ui, cmdoptions, args) |
199 cmd = Command('annotate -udl') | 202 cmd = Command('annotate -udl') |
200 cmd.extend([convert(v) for v in args]) | 203 cmd.extend([convert(v) for v in args]) |
201 ui.status((str(cmd)), "\n") | 204 ui.status((bytes(cmd)), "\n") |
202 | 205 |
203 def branch(ui, repo, *args, **kwargs): | 206 def branch(ui, repo, *args, **kwargs): |
204 cmdoptions = [ | 207 cmdoptions = [ |
205 ('', 'set-upstream', None, ''), | 208 ('', 'set-upstream', None, ''), |
206 ('', 'set-upstream-to', '', ''), | 209 ('', 'set-upstream-to', '', ''), |
237 if len(args) > 1: | 240 if len(args) > 1: |
238 cmd['-r'] = args[1] | 241 cmd['-r'] = args[1] |
239 cmd.append(args[0]) | 242 cmd.append(args[0]) |
240 elif len(args) == 1: | 243 elif len(args) == 1: |
241 cmd.append(args[0]) | 244 cmd.append(args[0]) |
242 ui.status((str(cmd)), "\n") | 245 ui.status((bytes(cmd)), "\n") |
243 | 246 |
244 def ispath(repo, string): | 247 def ispath(repo, string): |
245 """ | 248 """ |
246 The first argument to git checkout can either be a revision or a path. Let's | 249 The first argument to git checkout can either be a revision or a path. Let's |
247 generally assume it's a revision, unless it's obviously a path. There are | 250 generally assume it's a revision, unless it's obviously a path. There are |
328 cmd = Command('revert') | 331 cmd = Command('revert') |
329 cmd['--all'] = None | 332 cmd['--all'] = None |
330 else: | 333 else: |
331 raise error.Abort("a commit must be specified") | 334 raise error.Abort("a commit must be specified") |
332 | 335 |
333 ui.status((str(cmd)), "\n") | 336 ui.status((bytes(cmd)), "\n") |
334 | 337 |
335 def cherrypick(ui, repo, *args, **kwargs): | 338 def cherrypick(ui, repo, *args, **kwargs): |
336 cmdoptions = [ | 339 cmdoptions = [ |
337 ('', 'continue', None, ''), | 340 ('', 'continue', None, ''), |
338 ('', 'abort', None, ''), | 341 ('', 'abort', None, ''), |
350 ui.status(_("note: hg graft does not have --abort.\n\n")) | 353 ui.status(_("note: hg graft does not have --abort.\n\n")) |
351 return | 354 return |
352 else: | 355 else: |
353 cmd.extend(args) | 356 cmd.extend(args) |
354 | 357 |
355 ui.status((str(cmd)), "\n") | 358 ui.status((bytes(cmd)), "\n") |
356 | 359 |
357 def clean(ui, repo, *args, **kwargs): | 360 def clean(ui, repo, *args, **kwargs): |
358 cmdoptions = [ | 361 cmdoptions = [ |
359 ('d', 'd', None, ''), | 362 ('d', 'd', None, ''), |
360 ('f', 'force', None, ''), | 363 ('f', 'force', None, ''), |
365 cmd = Command('purge') | 368 cmd = Command('purge') |
366 if opts.get('x'): | 369 if opts.get('x'): |
367 cmd['--all'] = None | 370 cmd['--all'] = None |
368 cmd.extend(args) | 371 cmd.extend(args) |
369 | 372 |
370 ui.status((str(cmd)), "\n") | 373 ui.status((bytes(cmd)), "\n") |
371 | 374 |
372 def clone(ui, repo, *args, **kwargs): | 375 def clone(ui, repo, *args, **kwargs): |
373 cmdoptions = [ | 376 cmdoptions = [ |
374 ('', 'bare', None, ''), | 377 ('', 'bare', None, ''), |
375 ('n', 'no-checkout', None, ''), | 378 ('n', 'no-checkout', None, ''), |
395 if opts.get('branch'): | 398 if opts.get('branch'): |
396 cocmd = Command("update") | 399 cocmd = Command("update") |
397 cocmd.append(opts.get('branch')) | 400 cocmd.append(opts.get('branch')) |
398 cmd = cmd & cocmd | 401 cmd = cmd & cocmd |
399 | 402 |
400 ui.status((str(cmd)), "\n") | 403 ui.status((bytes(cmd)), "\n") |
401 | 404 |
402 def commit(ui, repo, *args, **kwargs): | 405 def commit(ui, repo, *args, **kwargs): |
403 cmdoptions = [ | 406 cmdoptions = [ |
404 ('a', 'all', None, ''), | 407 ('a', 'all', None, ''), |
405 ('m', 'message', '', ''), | 408 ('m', 'message', '', ''), |
443 if opts.get('date'): | 446 if opts.get('date'): |
444 cmd['-d'] = opts.get('date') | 447 cmd['-d'] = opts.get('date') |
445 | 448 |
446 cmd.extend(args) | 449 cmd.extend(args) |
447 | 450 |
448 ui.status((str(cmd)), "\n") | 451 ui.status((bytes(cmd)), "\n") |
449 | 452 |
450 def deprecated(ui, repo, *args, **kwargs): | 453 def deprecated(ui, repo, *args, **kwargs): |
451 ui.warn(_('This command has been deprecated in the git project, ' + | 454 ui.warn(_('This command has been deprecated in the git project, ' + |
452 'thus isn\'t supported by this tool.\n\n')) | 455 'thus isn\'t supported by this tool.\n\n')) |
453 | 456 |
474 repo.revs(a) | 477 repo.revs(a) |
475 cmd['-r'] = a | 478 cmd['-r'] = a |
476 except Exception: | 479 except Exception: |
477 cmd.append(a) | 480 cmd.append(a) |
478 | 481 |
479 ui.status((str(cmd)), "\n") | 482 ui.status((bytes(cmd)), "\n") |
480 | 483 |
481 def difftool(ui, repo, *args, **kwargs): | 484 def difftool(ui, repo, *args, **kwargs): |
482 ui.status(_('Mercurial does not enable external difftool by default. You ' | 485 ui.status(_('Mercurial does not enable external difftool by default. You ' |
483 'need to enable the extdiff extension in your .hgrc file by adding\n' | 486 'need to enable the extdiff extension in your .hgrc file by adding\n' |
484 'extdiff =\n' | 487 'extdiff =\n' |
507 if v in repo._bookmarks: | 510 if v in repo._bookmarks: |
508 cmd['-B'] = v | 511 cmd['-B'] = v |
509 else: | 512 else: |
510 cmd['-r'] = v | 513 cmd['-r'] = v |
511 | 514 |
512 ui.status((str(cmd)), "\n") | 515 ui.status((bytes(cmd)), "\n") |
513 | 516 |
514 def grep(ui, repo, *args, **kwargs): | 517 def grep(ui, repo, *args, **kwargs): |
515 cmdoptions = [ | 518 cmdoptions = [ |
516 ] | 519 ] |
517 args, opts = parseoptions(ui, cmdoptions, args) | 520 args, opts = parseoptions(ui, cmdoptions, args) |
520 | 523 |
521 # For basic usage, git grep and hg grep are the same. They both have the | 524 # For basic usage, git grep and hg grep are the same. They both have the |
522 # pattern first, followed by paths. | 525 # pattern first, followed by paths. |
523 cmd.extend(args) | 526 cmd.extend(args) |
524 | 527 |
525 ui.status((str(cmd)), "\n") | 528 ui.status((bytes(cmd)), "\n") |
526 | 529 |
527 def init(ui, repo, *args, **kwargs): | 530 def init(ui, repo, *args, **kwargs): |
528 cmdoptions = [ | 531 cmdoptions = [ |
529 ] | 532 ] |
530 args, opts = parseoptions(ui, cmdoptions, args) | 533 args, opts = parseoptions(ui, cmdoptions, args) |
532 cmd = Command('init') | 535 cmd = Command('init') |
533 | 536 |
534 if len(args) > 0: | 537 if len(args) > 0: |
535 cmd.append(args[0]) | 538 cmd.append(args[0]) |
536 | 539 |
537 ui.status((str(cmd)), "\n") | 540 ui.status((bytes(cmd)), "\n") |
538 | 541 |
539 def log(ui, repo, *args, **kwargs): | 542 def log(ui, repo, *args, **kwargs): |
540 cmdoptions = [ | 543 cmdoptions = [ |
541 ('', 'follow', None, ''), | 544 ('', 'follow', None, ''), |
542 ('', 'decorate', None, ''), | 545 ('', 'decorate', None, ''), |
586 since, until = args[0].split('..') | 589 since, until = args[0].split('..') |
587 cmd['-r'] = "'%s::%s'" % (since, until) | 590 cmd['-r'] = "'%s::%s'" % (since, until) |
588 del args[0] | 591 del args[0] |
589 cmd.extend(args) | 592 cmd.extend(args) |
590 | 593 |
591 ui.status((str(cmd)), "\n") | 594 ui.status((bytes(cmd)), "\n") |
592 | 595 |
593 def lsfiles(ui, repo, *args, **kwargs): | 596 def lsfiles(ui, repo, *args, **kwargs): |
594 cmdoptions = [ | 597 cmdoptions = [ |
595 ('c', 'cached', None, ''), | 598 ('c', 'cached', None, ''), |
596 ('d', 'deleted', None, ''), | 599 ('d', 'deleted', None, ''), |
622 cmd['-0'] = None | 625 cmd['-0'] = None |
623 cmd.append('.') | 626 cmd.append('.') |
624 for include in args: | 627 for include in args: |
625 cmd['-I'] = util.shellquote(include) | 628 cmd['-I'] = util.shellquote(include) |
626 | 629 |
627 ui.status((str(cmd)), "\n") | 630 ui.status((bytes(cmd)), "\n") |
628 | 631 |
629 def merge(ui, repo, *args, **kwargs): | 632 def merge(ui, repo, *args, **kwargs): |
630 cmdoptions = [ | 633 cmdoptions = [ |
631 ] | 634 ] |
632 args, opts = parseoptions(ui, cmdoptions, args) | 635 args, opts = parseoptions(ui, cmdoptions, args) |
634 cmd = Command('merge') | 637 cmd = Command('merge') |
635 | 638 |
636 if len(args) > 0: | 639 if len(args) > 0: |
637 cmd.append(args[len(args) - 1]) | 640 cmd.append(args[len(args) - 1]) |
638 | 641 |
639 ui.status((str(cmd)), "\n") | 642 ui.status((bytes(cmd)), "\n") |
640 | 643 |
641 def mergebase(ui, repo, *args, **kwargs): | 644 def mergebase(ui, repo, *args, **kwargs): |
642 cmdoptions = [] | 645 cmdoptions = [] |
643 args, opts = parseoptions(ui, cmdoptions, args) | 646 args, opts = parseoptions(ui, cmdoptions, args) |
644 | 647 |
648 cmd = Command("log -T '{node}\\n' -r 'ancestor(%s,%s)'" | 651 cmd = Command("log -T '{node}\\n' -r 'ancestor(%s,%s)'" |
649 % (args[0], args[1])) | 652 % (args[0], args[1])) |
650 | 653 |
651 ui.status(_('NOTE: ancestors() is part of the revset language.\n'), | 654 ui.status(_('NOTE: ancestors() is part of the revset language.\n'), |
652 _("Learn more about revsets with 'hg help revsets'\n\n")) | 655 _("Learn more about revsets with 'hg help revsets'\n\n")) |
653 ui.status((str(cmd)), "\n") | 656 ui.status((bytes(cmd)), "\n") |
654 | 657 |
655 def mergetool(ui, repo, *args, **kwargs): | 658 def mergetool(ui, repo, *args, **kwargs): |
656 cmdoptions = [] | 659 cmdoptions = [] |
657 args, opts = parseoptions(ui, cmdoptions, args) | 660 args, opts = parseoptions(ui, cmdoptions, args) |
658 | 661 |
659 cmd = Command("resolve") | 662 cmd = Command("resolve") |
660 | 663 |
661 if len(args) == 0: | 664 if len(args) == 0: |
662 cmd['--all'] = None | 665 cmd['--all'] = None |
663 cmd.extend(args) | 666 cmd.extend(args) |
664 ui.status((str(cmd)), "\n") | 667 ui.status((bytes(cmd)), "\n") |
665 | 668 |
666 def mv(ui, repo, *args, **kwargs): | 669 def mv(ui, repo, *args, **kwargs): |
667 cmdoptions = [ | 670 cmdoptions = [ |
668 ('f', 'force', None, ''), | 671 ('f', 'force', None, ''), |
669 ] | 672 ] |
673 cmd.extend(args) | 676 cmd.extend(args) |
674 | 677 |
675 if opts.get('force'): | 678 if opts.get('force'): |
676 cmd['-f'] = None | 679 cmd['-f'] = None |
677 | 680 |
678 ui.status((str(cmd)), "\n") | 681 ui.status((bytes(cmd)), "\n") |
679 | 682 |
680 def pull(ui, repo, *args, **kwargs): | 683 def pull(ui, repo, *args, **kwargs): |
681 cmdoptions = [ | 684 cmdoptions = [ |
682 ('', 'all', None, ''), | 685 ('', 'all', None, ''), |
683 ('f', 'force', None, ''), | 686 ('f', 'force', None, ''), |
699 if v in repo._bookmarks: | 702 if v in repo._bookmarks: |
700 cmd['-B'] = v | 703 cmd['-B'] = v |
701 else: | 704 else: |
702 cmd['-r'] = v | 705 cmd['-r'] = v |
703 | 706 |
704 ui.status((str(cmd)), "\n") | 707 ui.status((bytes(cmd)), "\n") |
705 | 708 |
706 def push(ui, repo, *args, **kwargs): | 709 def push(ui, repo, *args, **kwargs): |
707 cmdoptions = [ | 710 cmdoptions = [ |
708 ('', 'all', None, ''), | 711 ('', 'all', None, ''), |
709 ('f', 'force', None, ''), | 712 ('f', 'force', None, ''), |
726 cmd['-r'] = v | 729 cmd['-r'] = v |
727 | 730 |
728 if opts.get('force'): | 731 if opts.get('force'): |
729 cmd['-f'] = None | 732 cmd['-f'] = None |
730 | 733 |
731 ui.status((str(cmd)), "\n") | 734 ui.status((bytes(cmd)), "\n") |
732 | 735 |
733 def rebase(ui, repo, *args, **kwargs): | 736 def rebase(ui, repo, *args, **kwargs): |
734 cmdoptions = [ | 737 cmdoptions = [ |
735 ('', 'all', None, ''), | 738 ('', 'all', None, ''), |
736 ('i', 'interactive', None, ''), | 739 ('i', 'interactive', None, ''), |
746 "It just edits history.\n\n")) | 749 "It just edits history.\n\n")) |
747 cmd = Command('histedit') | 750 cmd = Command('histedit') |
748 if len(args) > 0: | 751 if len(args) > 0: |
749 ui.status(_("also note: 'hg histedit' will automatically detect" | 752 ui.status(_("also note: 'hg histedit' will automatically detect" |
750 " your stack, so no second argument is necessary.\n\n")) | 753 " your stack, so no second argument is necessary.\n\n")) |
751 ui.status((str(cmd)), "\n") | 754 ui.status((bytes(cmd)), "\n") |
752 return | 755 return |
753 | 756 |
754 if opts.get('skip'): | 757 if opts.get('skip'): |
755 cmd = Command('revert --all -r .') | 758 cmd = Command('revert --all -r .') |
756 ui.status((str(cmd)), "\n") | 759 ui.status((bytes(cmd)), "\n") |
757 | 760 |
758 cmd = Command('rebase') | 761 cmd = Command('rebase') |
759 | 762 |
760 if opts.get('continue') or opts.get('skip'): | 763 if opts.get('continue') or opts.get('skip'): |
761 cmd['--continue'] = None | 764 cmd['--continue'] = None |
775 cmd['-d'] = convert(args[0]) | 778 cmd['-d'] = convert(args[0]) |
776 elif len(args) == 2: | 779 elif len(args) == 2: |
777 cmd['-d'] = convert(args[0]) | 780 cmd['-d'] = convert(args[0]) |
778 cmd['-b'] = convert(args[1]) | 781 cmd['-b'] = convert(args[1]) |
779 | 782 |
780 ui.status((str(cmd)), "\n") | 783 ui.status((bytes(cmd)), "\n") |
781 | 784 |
782 def reflog(ui, repo, *args, **kwargs): | 785 def reflog(ui, repo, *args, **kwargs): |
783 cmdoptions = [ | 786 cmdoptions = [ |
784 ('', 'all', None, ''), | 787 ('', 'all', None, ''), |
785 ] | 788 ] |
789 if opts.get('all'): | 792 if opts.get('all'): |
790 cmd['--all'] = None | 793 cmd['--all'] = None |
791 if len(args) > 0: | 794 if len(args) > 0: |
792 cmd.append(args[0]) | 795 cmd.append(args[0]) |
793 | 796 |
794 ui.status(str(cmd), "\n\n") | 797 ui.status(bytes(cmd), "\n\n") |
795 ui.status(_("note: in hg commits can be deleted from repo but we always" | 798 ui.status(_("note: in hg commits can be deleted from repo but we always" |
796 " have backups.\n")) | 799 " have backups.\n")) |
797 | 800 |
798 def reset(ui, repo, *args, **kwargs): | 801 def reset(ui, repo, *args, **kwargs): |
799 cmdoptions = [ | 802 cmdoptions = [ |
817 if hard: | 820 if hard: |
818 cmd.append('--clean') | 821 cmd.append('--clean') |
819 | 822 |
820 cmd.append(commit) | 823 cmd.append(commit) |
821 | 824 |
822 ui.status((str(cmd)), "\n") | 825 ui.status((bytes(cmd)), "\n") |
823 | 826 |
824 def revert(ui, repo, *args, **kwargs): | 827 def revert(ui, repo, *args, **kwargs): |
825 cmdoptions = [ | 828 cmdoptions = [ |
826 ] | 829 ] |
827 args, opts = parseoptions(ui, cmdoptions, args) | 830 args, opts = parseoptions(ui, cmdoptions, args) |
832 | 835 |
833 cmd = Command('backout') | 836 cmd = Command('backout') |
834 if args: | 837 if args: |
835 cmd.append(args[0]) | 838 cmd.append(args[0]) |
836 | 839 |
837 ui.status((str(cmd)), "\n") | 840 ui.status((bytes(cmd)), "\n") |
838 | 841 |
839 def revparse(ui, repo, *args, **kwargs): | 842 def revparse(ui, repo, *args, **kwargs): |
840 cmdoptions = [ | 843 cmdoptions = [ |
841 ('', 'show-cdup', None, ''), | 844 ('', 'show-cdup', None, ''), |
842 ('', 'show-toplevel', None, ''), | 845 ('', 'show-toplevel', None, ''), |
845 | 848 |
846 if opts.get('show_cdup') or opts.get('show_toplevel'): | 849 if opts.get('show_cdup') or opts.get('show_toplevel'): |
847 cmd = Command('root') | 850 cmd = Command('root') |
848 if opts.get('show_cdup'): | 851 if opts.get('show_cdup'): |
849 ui.status(_("note: hg root prints the root of the repository\n\n")) | 852 ui.status(_("note: hg root prints the root of the repository\n\n")) |
850 ui.status((str(cmd)), "\n") | 853 ui.status((bytes(cmd)), "\n") |
851 else: | 854 else: |
852 ui.status(_("note: see hg help revset for how to refer to commits\n")) | 855 ui.status(_("note: see hg help revset for how to refer to commits\n")) |
853 | 856 |
854 def rm(ui, repo, *args, **kwargs): | 857 def rm(ui, repo, *args, **kwargs): |
855 cmdoptions = [ | 858 cmdoptions = [ |
864 if opts.get('force'): | 867 if opts.get('force'): |
865 cmd['-f'] = None | 868 cmd['-f'] = None |
866 if opts.get('dry_run'): | 869 if opts.get('dry_run'): |
867 cmd['-n'] = None | 870 cmd['-n'] = None |
868 | 871 |
869 ui.status((str(cmd)), "\n") | 872 ui.status((bytes(cmd)), "\n") |
870 | 873 |
871 def show(ui, repo, *args, **kwargs): | 874 def show(ui, repo, *args, **kwargs): |
872 cmdoptions = [ | 875 cmdoptions = [ |
873 ('', 'name-status', None, ''), | 876 ('', 'name-status', None, ''), |
874 ('', 'pretty', '', ''), | 877 ('', 'pretty', '', ''), |
896 cmd = Command('export') | 899 cmd = Command('export') |
897 cmd.append('--config diff.unified=%d' % (opts['unified'],)) | 900 cmd.append('--config diff.unified=%d' % (opts['unified'],)) |
898 else: | 901 else: |
899 cmd = Command('export') | 902 cmd = Command('export') |
900 | 903 |
901 ui.status((str(cmd)), "\n") | 904 ui.status((bytes(cmd)), "\n") |
902 | 905 |
903 def stash(ui, repo, *args, **kwargs): | 906 def stash(ui, repo, *args, **kwargs): |
904 cmdoptions = [ | 907 cmdoptions = [ |
905 ] | 908 ] |
906 args, opts = parseoptions(ui, cmdoptions, args) | 909 args, opts = parseoptions(ui, cmdoptions, args) |
932 if args[0] != 'save': | 935 if args[0] != 'save': |
933 cmd['--name'] = args[0] | 936 cmd['--name'] = args[0] |
934 elif len(args) > 1: | 937 elif len(args) > 1: |
935 cmd['--name'] = args[1] | 938 cmd['--name'] = args[1] |
936 | 939 |
937 ui.status((str(cmd)), "\n") | 940 ui.status((bytes(cmd)), "\n") |
938 | 941 |
939 def status(ui, repo, *args, **kwargs): | 942 def status(ui, repo, *args, **kwargs): |
940 cmdoptions = [ | 943 cmdoptions = [ |
941 ('', 'ignored', None, ''), | 944 ('', 'ignored', None, ''), |
942 ] | 945 ] |
946 cmd.extend(args) | 949 cmd.extend(args) |
947 | 950 |
948 if opts.get('ignored'): | 951 if opts.get('ignored'): |
949 cmd['-i'] = None | 952 cmd['-i'] = None |
950 | 953 |
951 ui.status((str(cmd)), "\n") | 954 ui.status((bytes(cmd)), "\n") |
952 | 955 |
953 def svn(ui, repo, *args, **kwargs): | 956 def svn(ui, repo, *args, **kwargs): |
954 svncmd = args[0] | 957 svncmd = args[0] |
955 if not svncmd in gitsvncommands: | 958 if not svncmd in gitsvncommands: |
956 ui.warn(_("error: unknown git svn command %s\n") % (svncmd)) | 959 ui.warn(_("error: unknown git svn command %s\n") % (svncmd)) |
963 ] | 966 ] |
964 args, opts = parseoptions(ui, cmdoptions, args) | 967 args, opts = parseoptions(ui, cmdoptions, args) |
965 | 968 |
966 cmd = Command('push') | 969 cmd = Command('push') |
967 | 970 |
968 ui.status((str(cmd)), "\n") | 971 ui.status((bytes(cmd)), "\n") |
969 | 972 |
970 def svnfetch(ui, repo, *args, **kwargs): | 973 def svnfetch(ui, repo, *args, **kwargs): |
971 cmdoptions = [ | 974 cmdoptions = [ |
972 ] | 975 ] |
973 args, opts = parseoptions(ui, cmdoptions, args) | 976 args, opts = parseoptions(ui, cmdoptions, args) |
974 | 977 |
975 cmd = Command('pull') | 978 cmd = Command('pull') |
976 cmd.append('default-push') | 979 cmd.append('default-push') |
977 | 980 |
978 ui.status((str(cmd)), "\n") | 981 ui.status((bytes(cmd)), "\n") |
979 | 982 |
980 def svnfindrev(ui, repo, *args, **kwargs): | 983 def svnfindrev(ui, repo, *args, **kwargs): |
981 cmdoptions = [ | 984 cmdoptions = [ |
982 ] | 985 ] |
983 args, opts = parseoptions(ui, cmdoptions, args) | 986 args, opts = parseoptions(ui, cmdoptions, args) |
984 | 987 |
985 cmd = Command('log') | 988 cmd = Command('log') |
986 cmd['-r'] = args[0] | 989 cmd['-r'] = args[0] |
987 | 990 |
988 ui.status((str(cmd)), "\n") | 991 ui.status((bytes(cmd)), "\n") |
989 | 992 |
990 def svnrebase(ui, repo, *args, **kwargs): | 993 def svnrebase(ui, repo, *args, **kwargs): |
991 cmdoptions = [ | 994 cmdoptions = [ |
992 ('l', 'local', None, ''), | 995 ('l', 'local', None, ''), |
993 ] | 996 ] |
998 rebasecmd = Command('rebase') | 1001 rebasecmd = Command('rebase') |
999 rebasecmd.append('tip') | 1002 rebasecmd.append('tip') |
1000 | 1003 |
1001 cmd = pullcmd & rebasecmd | 1004 cmd = pullcmd & rebasecmd |
1002 | 1005 |
1003 ui.status((str(cmd)), "\n") | 1006 ui.status((bytes(cmd)), "\n") |
1004 | 1007 |
1005 def tag(ui, repo, *args, **kwargs): | 1008 def tag(ui, repo, *args, **kwargs): |
1006 cmdoptions = [ | 1009 cmdoptions = [ |
1007 ('f', 'force', None, ''), | 1010 ('f', 'force', None, ''), |
1008 ('l', 'list', None, ''), | 1011 ('l', 'list', None, ''), |
1022 cmd['--remove'] = None | 1025 cmd['--remove'] = None |
1023 | 1026 |
1024 if opts.get('force'): | 1027 if opts.get('force'): |
1025 cmd['-f'] = None | 1028 cmd['-f'] = None |
1026 | 1029 |
1027 ui.status((str(cmd)), "\n") | 1030 ui.status((bytes(cmd)), "\n") |
1028 | 1031 |
1029 gitcommands = { | 1032 gitcommands = { |
1030 'add': add, | 1033 'add': add, |
1031 'am': am, | 1034 'am': am, |
1032 'apply': apply, | 1035 'apply': apply, |