Show More
@@ -936,21 +936,23 def _printbookmarks(ui, repo, fm, bmarks | |||
|
936 | 936 | fm.data(active=(activebookmarklabel in label)) |
|
937 | 937 | fm.plain('\n') |
|
938 | 938 | |
|
939 | def printbookmarks(ui, repo, fm): | |
|
939 | def printbookmarks(ui, repo, fm, names=None): | |
|
940 | 940 | """print bookmarks by the given formatter |
|
941 | 941 | |
|
942 | 942 | Provides a way for extensions to control how bookmarks are printed. |
|
943 | 943 | """ |
|
944 | 944 | marks = repo._bookmarks |
|
945 | 945 | bmarks = {} |
|
946 |
for bmark |
|
|
946 | for bmark in (names or marks): | |
|
947 | if bmark not in marks: | |
|
948 | raise error.Abort(_("bookmark '%s' does not exist") % bmark) | |
|
947 | 949 | active = repo._activebookmark |
|
948 | 950 | if bmark == active: |
|
949 | 951 | prefix, label = '*', activebookmarklabel |
|
950 | 952 | else: |
|
951 | 953 | prefix, label = ' ', '' |
|
952 | 954 | |
|
953 |
bmarks[bmark] = ( |
|
|
955 | bmarks[bmark] = (marks[bmark], prefix, label) | |
|
954 | 956 | _printbookmarks(ui, repo, fm, bmarks) |
|
955 | 957 | |
|
956 | 958 | def preparehookargs(name, old, new): |
@@ -903,6 +903,7 def bisect(ui, repo, rev=None, extra=Non | |||
|
903 | 903 | ('d', 'delete', False, _('delete a given bookmark')), |
|
904 | 904 | ('m', 'rename', '', _('rename a given bookmark'), _('OLD')), |
|
905 | 905 | ('i', 'inactive', False, _('mark a bookmark inactive')), |
|
906 | ('l', 'list', False, _('list existing bookmarks')), | |
|
906 | 907 | ('', 'active', False, _('display the active bookmark')), |
|
907 | 908 | ] + formatteropts, |
|
908 | 909 | _('hg bookmarks [OPTIONS]... [NAME]...')) |
@@ -924,7 +925,7 def bookmark(ui, repo, *names, **opts): | |||
|
924 | 925 | diverged, a new 'divergent bookmark' of the form 'name@path' will |
|
925 | 926 | be created. Using :hg:`merge` will resolve the divergence. |
|
926 | 927 | |
|
927 |
Specifying bookmark as '.' to -m |
|
|
928 | Specifying bookmark as '.' to -m/-d/-l options is equivalent to specifying | |
|
928 | 929 | the active bookmark's name. |
|
929 | 930 | |
|
930 | 931 | A bookmark named '@' has the special property that :hg:`clone` will |
@@ -963,7 +964,8 def bookmark(ui, repo, *names, **opts): | |||
|
963 | 964 | rev = opts.get('rev') |
|
964 | 965 | inactive = opts.get('inactive') # meaning add/rename to inactive bookmark |
|
965 | 966 | |
|
966 |
selactions = [k for k in ['delete', 'rename', 'active' |
|
|
967 | selactions = [k for k in ['delete', 'rename', 'active', 'list'] | |
|
968 | if opts.get(k)] | |
|
967 | 969 | if len(selactions) > 1: |
|
968 | 970 | raise error.Abort(_('--%s and --%s are incompatible') |
|
969 | 971 | % tuple(selactions[:2])) |
@@ -974,13 +976,13 def bookmark(ui, repo, *names, **opts): | |||
|
974 | 976 | elif inactive: |
|
975 | 977 | action = 'inactive' # meaning deactivate |
|
976 | 978 | else: |
|
977 |
action = |
|
|
978 | ||
|
979 | if rev and action in {'delete', 'rename', 'active'}: | |
|
979 | action = 'list' | |
|
980 | ||
|
981 | if rev and action in {'delete', 'rename', 'active', 'list'}: | |
|
980 | 982 | raise error.Abort(_("--rev is incompatible with --%s") % action) |
|
981 | 983 | if names and action == 'active': |
|
982 | 984 | raise error.Abort(_("NAMES is incompatible with --active")) |
|
983 | if inactive and action in {'delete', 'active'}: | |
|
985 | if inactive and action in {'delete', 'active', 'list'}: | |
|
984 | 986 | raise error.Abort(_("--inactive is incompatible with --%s") % action) |
|
985 | 987 | if not names and action in {'add', 'delete'}: |
|
986 | 988 | raise error.Abort(_("bookmark name required")) |
@@ -1011,9 +1013,12 def bookmark(ui, repo, *names, **opts): | |||
|
1011 | 1013 | if book is None: |
|
1012 | 1014 | return 1 |
|
1013 | 1015 | ui.write("%s\n" % book, label=bookmarks.activebookmarklabel) |
|
1014 | else: # show bookmarks | |
|
1016 | elif action == 'list': | |
|
1017 | names = pycompat.maplist(repo._bookmarks.expandname, names) | |
|
1015 | 1018 | with ui.formatter('bookmarks', opts) as fm: |
|
1016 | bookmarks.printbookmarks(ui, repo, fm) | |
|
1019 | bookmarks.printbookmarks(ui, repo, fm, names) | |
|
1020 | else: | |
|
1021 | raise error.ProgrammingError('invalid action: %s' % action) | |
|
1017 | 1022 | |
|
1018 | 1023 | @command('branch', |
|
1019 | 1024 | [('f', 'force', None, |
@@ -68,6 +68,25 list bookmarks | |||
|
68 | 68 | X 0:f7b1eb17ad24 |
|
69 | 69 | * X2 0:f7b1eb17ad24 |
|
70 | 70 | Y -1:000000000000 |
|
71 | $ hg bookmarks -l | |
|
72 | X 0:f7b1eb17ad24 | |
|
73 | * X2 0:f7b1eb17ad24 | |
|
74 | Y -1:000000000000 | |
|
75 | $ hg bookmarks -l X Y | |
|
76 | X 0:f7b1eb17ad24 | |
|
77 | Y -1:000000000000 | |
|
78 | $ hg bookmarks -l . | |
|
79 | * X2 0:f7b1eb17ad24 | |
|
80 | $ hg bookmarks -l X A Y | |
|
81 | abort: bookmark 'A' does not exist | |
|
82 | [255] | |
|
83 | $ hg bookmarks -l -r0 | |
|
84 | abort: --rev is incompatible with --list | |
|
85 | [255] | |
|
86 | $ hg bookmarks -l --inactive | |
|
87 | abort: --inactive is incompatible with --list | |
|
88 | [255] | |
|
89 | ||
|
71 | 90 |
$ |
|
72 | 91 | 0 X |
|
73 | 92 | 0 X2 |
@@ -250,7 +250,7 Show all commands + options | |||
|
250 | 250 | archive: no-decode, prefix, rev, type, subrepos, include, exclude |
|
251 | 251 | backout: merge, commit, no-commit, parent, rev, edit, tool, include, exclude, message, logfile, date, user |
|
252 | 252 | bisect: reset, good, bad, skip, extend, command, noupdate |
|
253 | bookmarks: force, rev, delete, rename, inactive, active, template | |
|
253 | bookmarks: force, rev, delete, rename, inactive, list, active, template | |
|
254 | 254 | branch: force, clean, rev |
|
255 | 255 | branches: active, closed, template |
|
256 | 256 | bundle: force, rev, branch, base, all, type, ssh, remotecmd, insecure |
General Comments 0
You need to be logged in to leave comments.
Login now