##// END OF EJS Templates
githelp: cast commands to bytes...
Gregory Szorc -
r36248:257f3651 default
parent child Browse files
Show More
@@ -22,6 +22,7 b' 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,
@@ -109,7 +110,7 b' class Command(object):'
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()):
@@ -123,6 +124,8 b' class Command(object):'
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
@@ -167,14 +170,14 b' def add(ui, repo, *args, **kwargs):'
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 = [
@@ -187,7 +190,7 b' def apply(ui, repo, *args, **kwargs):'
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"))
@@ -198,7 +201,7 b' def blame(ui, repo, *args, **kwargs):'
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 = [
@@ -239,7 +242,7 b' def branch(ui, repo, *args, **kwargs):'
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 """
@@ -330,7 +333,7 b' def checkout(ui, repo, *args, **kwargs):'
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 = [
@@ -352,7 +355,7 b' def cherrypick(ui, repo, *args, **kwargs'
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 = [
@@ -367,7 +370,7 b' def clean(ui, repo, *args, **kwargs):'
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 = [
@@ -397,7 +400,7 b' def clone(ui, repo, *args, **kwargs):'
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 = [
@@ -445,7 +448,7 b' def commit(ui, repo, *args, **kwargs):'
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, ' +
@@ -476,7 +479,7 b' def diff(ui, repo, *args, **kwargs):'
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 '
@@ -509,7 +512,7 b' def fetch(ui, repo, *args, **kwargs):'
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 = [
@@ -522,7 +525,7 b' def grep(ui, repo, *args, **kwargs):'
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 = [
@@ -534,7 +537,7 b' def init(ui, repo, *args, **kwargs):'
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 = [
@@ -588,7 +591,7 b' def log(ui, repo, *args, **kwargs):'
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 = [
@@ -624,7 +627,7 b' def lsfiles(ui, repo, *args, **kwargs):'
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 = [
@@ -636,7 +639,7 b' def merge(ui, repo, *args, **kwargs):'
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 = []
@@ -650,7 +653,7 b' def mergebase(ui, repo, *args, **kwargs)'
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 = []
@@ -661,7 +664,7 b' def mergetool(ui, repo, *args, **kwargs)'
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 = [
@@ -675,7 +678,7 b' def mv(ui, repo, *args, **kwargs):'
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 = [
@@ -701,7 +704,7 b' def pull(ui, repo, *args, **kwargs):'
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 = [
@@ -728,7 +731,7 b' def push(ui, repo, *args, **kwargs):'
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 = [
@@ -748,12 +751,12 b' def rebase(ui, repo, *args, **kwargs):'
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
@@ -777,7 +780,7 b' def rebase(ui, repo, *args, **kwargs):'
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 = [
@@ -791,7 +794,7 b' def reflog(ui, repo, *args, **kwargs):'
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
@@ -819,7 +822,7 b' def reset(ui, repo, *args, **kwargs):'
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 = [
@@ -834,7 +837,7 b' def revert(ui, repo, *args, **kwargs):'
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 = [
@@ -847,7 +850,7 b' def revparse(ui, repo, *args, **kwargs):'
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
@@ -866,7 +869,7 b' def rm(ui, repo, *args, **kwargs):'
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 = [
@@ -898,7 +901,7 b' def show(ui, repo, *args, **kwargs):'
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 = [
@@ -934,7 +937,7 b' def stash(ui, repo, *args, **kwargs):'
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 = [
@@ -948,7 +951,7 b' def status(ui, repo, *args, **kwargs):'
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]
@@ -965,7 +968,7 b' def svndcommit(ui, repo, *args, **kwargs'
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 = [
@@ -975,7 +978,7 b' def svnfetch(ui, repo, *args, **kwargs):'
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 = [
@@ -985,7 +988,7 b' def svnfindrev(ui, repo, *args, **kwargs'
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 = [
@@ -1000,7 +1003,7 b' def svnrebase(ui, repo, *args, **kwargs)'
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 = [
@@ -1024,7 +1027,7 b' def tag(ui, repo, *args, **kwargs):'
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,
General Comments 0
You need to be logged in to leave comments. Login now