##// END OF EJS Templates
fix some things people wanted to be cleaner....
Vadim Gelfer -
r1913:74cf2b2f default
parent child Browse files
Show More
@@ -296,9 +296,9 b' heads::'
296
296
297 options:
297 options:
298 -b, --branches show branches
298 -b, --branches show branches
299 --map-file <file> display using template map file
300 -r, --rev <rev> show only heads which are descendants of rev
299 -r, --rev <rev> show only heads which are descendants of rev
301 -t, --template <tpl> display using template
300 --style <style> display using style map file
301 --template <tpl> display using template
302
302
303 identify::
303 identify::
304 Print a short summary of the current state of the repo.
304 Print a short summary of the current state of the repo.
@@ -338,10 +338,10 b' incoming [-p] [source]::'
338
338
339 options:
339 options:
340 -M, --no-merges do not show merges
340 -M, --no-merges do not show merges
341 --map-file <file> display using template map file
342 -n, --newest-first show newest records first
341 -n, --newest-first show newest records first
343 -p, --patch show patch
342 -p, --patch show patch
344 -t, --template <tpl> display using template
343 --style <style> display using style map file
344 --template <tpl> display using template
345
345
346 aliases: in
346 aliases: in
347
347
@@ -389,12 +389,12 b' log [-r revision ...] [-p] [files]::'
389 -b, --branch show branches
389 -b, --branch show branches
390 -k, --keyword <str> search for keywords
390 -k, --keyword <str> search for keywords
391 -l, --limit <num> print no more than this many changes
391 -l, --limit <num> print no more than this many changes
392 --map-file <file> display using template map file
393 -M, --no-merges do not show merges
392 -M, --no-merges do not show merges
394 -m, --only-merges only show merges
393 -m, --only-merges only show merges
395 -r, --rev <A> show the specified revision or range
394 -r, --rev <A> show the specified revision or range
396 -p, --patch show patch
395 -p, --patch show patch
397 -t, --template <tpl> display using template
396 --style <style> display using style map file
397 --template <tpl> display using template
398
398
399 aliases: history
399 aliases: history
400
400
@@ -413,10 +413,10 b' outgoing [-p] [dest]::'
413
413
414 options:
414 options:
415 -M, --no-merges do not show merges
415 -M, --no-merges do not show merges
416 --map-file <file> display using template map file
417 -p, --patch show patch
416 -p, --patch show patch
418 -n, --newest-first show newest records first
417 -n, --newest-first show newest records first
419 -t, --template <tpl> display using template
418 --style <style> display using style map file
419 --template <tpl> display using template
420
420
421 aliases: out
421 aliases: out
422
422
@@ -425,8 +425,8 b' parents::'
425
425
426 options:
426 options:
427 -b, --branches show branches
427 -b, --branches show branches
428 --map-file <file> display using template map file
428 --style <style> display using style map file
429 -t, --template <tpl> display using template
429 --template <tpl> display using template
430
430
431 paths [NAME]::
431 paths [NAME]::
432 Show definition of symbolic path name NAME. If no name is given, show
432 Show definition of symbolic path name NAME. If no name is given, show
@@ -635,9 +635,9 b' tip [-p]::'
635
635
636 options:
636 options:
637 -b, --branches show branches
637 -b, --branches show branches
638 --map-file <file> display using template map file
639 -p, --patch show patch
638 -p, --patch show patch
640 -t, --template <tpl> display using template
639 --style <style> display using style map file
640 --template <tpl> display using template
641
641
642 unbundle <file>::
642 unbundle <file>::
643 (EXPERIMENTAL)
643 (EXPERIMENTAL)
@@ -341,13 +341,15 b' class changeset_templater(object):'
341 '''use templater module to format changeset information.'''
341 '''use templater module to format changeset information.'''
342
342
343 def __init__(self, ui, repo, mapfile):
343 def __init__(self, ui, repo, mapfile):
344 self.t = templater.templater(mapfile, templater.common_filters)
344 self.t = templater.templater(mapfile, templater.common_filters,
345 cache={'parent': '{rev}:{node|short} ',
346 'manifest': '{rev}:{node|short}'})
345 self.ui = ui
347 self.ui = ui
346 self.repo = repo
348 self.repo = repo
347
349
348 def use_template(self, t):
350 def use_template(self, t):
349 '''set template string to use'''
351 '''set template string to use'''
350 self.t.cache['template'] = t
352 self.t.cache['changelog'] = t
351
353
352 def write(self, thing):
354 def write(self, thing):
353 '''write expanded template.
355 '''write expanded template.
@@ -396,7 +398,11 b' class changeset_templater(object):'
396 yield self.t(noname, **args)
398 yield self.t(noname, **args)
397 return
399 return
398 if name not in self.t:
400 if name not in self.t:
401 if isinstance(values[0], str):
399 yield ' '.join(values)
402 yield ' '.join(values)
403 else:
404 for v in values:
405 yield dict(v, **args)
400 return
406 return
401 startname = 'start_' + names
407 startname = 'start_' + names
402 if startname in self.t:
408 if startname in self.t:
@@ -483,7 +489,11 b' class changeset_templater(object):'
483 }
489 }
484
490
485 try:
491 try:
486 self.write(self.t('template', **props))
492 if self.ui.verbose and 'changelog_verbose' in self.t:
493 key = 'changelog_verbose'
494 else:
495 key = 'changelog'
496 self.write(self.t(key, **props))
487 except KeyError, inst:
497 except KeyError, inst:
488 raise util.Abort(_("%s: no key named '%s'") % (self.t.mapfile,
498 raise util.Abort(_("%s: no key named '%s'") % (self.t.mapfile,
489 inst.args[0]))
499 inst.args[0]))
@@ -560,7 +570,7 b' class changeset_printer(object):'
560
570
561 def show_changeset(ui, repo, opts):
571 def show_changeset(ui, repo, opts):
562 '''show one changeset. uses template or regular display. caller
572 '''show one changeset. uses template or regular display. caller
563 can pass in 'map_file' and 'template' options in opts.'''
573 can pass in 'style' and 'template' options in opts.'''
564
574
565 tmpl = opts.get('template')
575 tmpl = opts.get('template')
566 if tmpl:
576 if tmpl:
@@ -568,7 +578,7 b' def show_changeset(ui, repo, opts):'
568 else:
578 else:
569 tmpl = ui.config('ui', 'logtemplate')
579 tmpl = ui.config('ui', 'logtemplate')
570 if tmpl: tmpl = templater.parsestring(tmpl)
580 if tmpl: tmpl = templater.parsestring(tmpl)
571 mapfile = opts.get('map_file') or ui.config('ui', 'logmap')
581 mapfile = opts.get('style') or ui.config('ui', 'logmap')
572 if tmpl or mapfile:
582 if tmpl or mapfile:
573 if mapfile:
583 if mapfile:
574 if not os.path.isfile(mapfile):
584 if not os.path.isfile(mapfile):
@@ -2655,9 +2665,9 b' table = {'
2655 "heads":
2665 "heads":
2656 (heads,
2666 (heads,
2657 [('b', 'branches', None, _('show branches')),
2667 [('b', 'branches', None, _('show branches')),
2658 ('', 'map-file', '', _('display using template map file')),
2668 ('', 'style', '', _('display using template map file')),
2659 ('r', 'rev', '', _('show only heads which are descendants of rev')),
2669 ('r', 'rev', '', _('show only heads which are descendants of rev')),
2660 ('t', 'template', '', _('display with template'))],
2670 ('', 'template', '', _('display with template'))],
2661 _('hg heads [-b] [-r <rev>]')),
2671 _('hg heads [-b] [-r <rev>]')),
2662 "help": (help_, [], _('hg help [COMMAND]')),
2672 "help": (help_, [], _('hg help [COMMAND]')),
2663 "identify|id": (identify, [], _('hg identify')),
2673 "identify|id": (identify, [], _('hg identify')),
@@ -2672,10 +2682,10 b' table = {'
2672 _('hg import [-f] [-p NUM] [-b BASE] PATCH...')),
2682 _('hg import [-f] [-p NUM] [-b BASE] PATCH...')),
2673 "incoming|in": (incoming,
2683 "incoming|in": (incoming,
2674 [('M', 'no-merges', None, _('do not show merges')),
2684 [('M', 'no-merges', None, _('do not show merges')),
2675 ('', 'map-file', '', _('display using template map file')),
2685 ('', 'style', '', _('display using template map file')),
2676 ('n', 'newest-first', None, _('show newest record first')),
2686 ('n', 'newest-first', None, _('show newest record first')),
2677 ('p', 'patch', None, _('show patch')),
2687 ('p', 'patch', None, _('show patch')),
2678 ('t', 'template', '', _('display with template'))],
2688 ('', 'template', '', _('display with template'))],
2679 _('hg incoming [-p] [-n] [-M] [SOURCE]')),
2689 _('hg incoming [-p] [-n] [-M] [SOURCE]')),
2680 "^init": (init, [], _('hg init [DEST]')),
2690 "^init": (init, [], _('hg init [DEST]')),
2681 "locate":
2691 "locate":
@@ -2697,24 +2707,24 b' table = {'
2697 ('l', 'limit', '', _('limit number of changes displayed')),
2707 ('l', 'limit', '', _('limit number of changes displayed')),
2698 ('r', 'rev', [], _('show the specified revision or range')),
2708 ('r', 'rev', [], _('show the specified revision or range')),
2699 ('M', 'no-merges', None, _('do not show merges')),
2709 ('M', 'no-merges', None, _('do not show merges')),
2700 ('', 'map-file', '', _('display using template map file')),
2710 ('', 'style', '', _('display using template map file')),
2701 ('m', 'only-merges', None, _('show only merges')),
2711 ('m', 'only-merges', None, _('show only merges')),
2702 ('p', 'patch', None, _('show patch')),
2712 ('p', 'patch', None, _('show patch')),
2703 ('t', 'template', '', _('display with template'))],
2713 ('', 'template', '', _('display with template'))],
2704 _('hg log [-I] [-X] [-r REV]... [-p] [FILE]')),
2714 _('hg log [-I] [-X] [-r REV]... [-p] [FILE]')),
2705 "manifest": (manifest, [], _('hg manifest [REV]')),
2715 "manifest": (manifest, [], _('hg manifest [REV]')),
2706 "outgoing|out": (outgoing,
2716 "outgoing|out": (outgoing,
2707 [('M', 'no-merges', None, _('do not show merges')),
2717 [('M', 'no-merges', None, _('do not show merges')),
2708 ('p', 'patch', None, _('show patch')),
2718 ('p', 'patch', None, _('show patch')),
2709 ('', 'map-file', '', _('display using template map file')),
2719 ('', 'style', '', _('display using template map file')),
2710 ('n', 'newest-first', None, _('show newest record first')),
2720 ('n', 'newest-first', None, _('show newest record first')),
2711 ('t', 'template', '', _('display with template'))],
2721 ('', 'template', '', _('display with template'))],
2712 _('hg outgoing [-p] [-n] [-M] [DEST]')),
2722 _('hg outgoing [-p] [-n] [-M] [DEST]')),
2713 "^parents":
2723 "^parents":
2714 (parents,
2724 (parents,
2715 [('b', 'branches', None, _('show branches')),
2725 [('b', 'branches', None, _('show branches')),
2716 ('', 'map-file', '', _('display using template map file')),
2726 ('', 'style', '', _('display using template map file')),
2717 ('t', 'template', '', _('display with template'))],
2727 ('', 'template', '', _('display with template'))],
2718 _('hg parents [-b] [REV]')),
2728 _('hg parents [-b] [REV]')),
2719 "paths": (paths, [], _('hg paths [NAME]')),
2729 "paths": (paths, [], _('hg paths [NAME]')),
2720 "^pull":
2730 "^pull":
@@ -2776,7 +2786,7 b' table = {'
2776 _('name to show in web pages (default: working dir)')),
2786 _('name to show in web pages (default: working dir)')),
2777 ('', 'pid-file', '', _('name of file to write process ID to')),
2787 ('', 'pid-file', '', _('name of file to write process ID to')),
2778 ('', 'stdio', None, _('for remote clients')),
2788 ('', 'stdio', None, _('for remote clients')),
2779 ('t', 'templates', '', _('web templates to use')),
2789 ('', 'templates', '', _('web templates to use')),
2780 ('', 'style', '', _('template style to use')),
2790 ('', 'style', '', _('template style to use')),
2781 ('6', 'ipv6', None, _('use IPv6 in addition to IPv4'))],
2791 ('6', 'ipv6', None, _('use IPv6 in addition to IPv4'))],
2782 _('hg serve [OPTION]...')),
2792 _('hg serve [OPTION]...')),
@@ -2805,9 +2815,9 b' table = {'
2805 "tip":
2815 "tip":
2806 (tip,
2816 (tip,
2807 [('b', 'branches', None, _('show branches')),
2817 [('b', 'branches', None, _('show branches')),
2808 ('', 'map-file', '', _('display using template map file')),
2818 ('', 'style', '', _('display using template map file')),
2809 ('p', 'patch', None, _('show patch')),
2819 ('p', 'patch', None, _('show patch')),
2810 ('t', 'template', '', _('display with template'))],
2820 ('', 'template', '', _('display with template'))],
2811 _('hg [-b] [-p] tip')),
2821 _('hg [-b] [-p] tip')),
2812 "unbundle":
2822 "unbundle":
2813 (unbundle,
2823 (unbundle,
@@ -2818,11 +2828,11 b' table = {'
2818 "^update|up|checkout|co":
2828 "^update|up|checkout|co":
2819 (update,
2829 (update,
2820 [('b', 'branch', '', _('checkout the head of a specific branch')),
2830 [('b', 'branch', '', _('checkout the head of a specific branch')),
2821 ('', 'map-file', '', _('display using template map file')),
2831 ('', 'style', '', _('display using template map file')),
2822 ('m', 'merge', None, _('allow merging of branches')),
2832 ('m', 'merge', None, _('allow merging of branches')),
2823 ('C', 'clean', None, _('overwrite locally modified files')),
2833 ('C', 'clean', None, _('overwrite locally modified files')),
2824 ('f', 'force', None, _('force a merge with outstanding changes')),
2834 ('f', 'force', None, _('force a merge with outstanding changes')),
2825 ('t', 'template', '', _('display with template'))],
2835 ('', 'template', '', _('display with template'))],
2826 _('hg update [-b TAG] [-m] [-C] [-f] [REV]')),
2836 _('hg update [-b TAG] [-m] [-C] [-f] [REV]')),
2827 "verify": (verify, [], _('hg verify')),
2837 "verify": (verify, [], _('hg verify')),
2828 "version": (show_version, [], _('hg version')),
2838 "version": (show_version, [], _('hg version')),
@@ -59,7 +59,7 b' class templater(object):'
59 filter uses function to transform value. syntax is
59 filter uses function to transform value. syntax is
60 {key|filter1|filter2|...}.'''
60 {key|filter1|filter2|...}.'''
61
61
62 def __init__(self, mapfile, filters={}, defaults={}):
62 def __init__(self, mapfile, filters={}, cache={}):
63 '''set up template engine.
63 '''set up template engine.
64 mapfile is name of file to read map definitions from.
64 mapfile is name of file to read map definitions from.
65 filters is dict of functions. each transforms a value into another.
65 filters is dict of functions. each transforms a value into another.
@@ -69,7 +69,8 b' class templater(object):'
69 self.map = {}
69 self.map = {}
70 self.base = (mapfile and os.path.dirname(mapfile)) or ''
70 self.base = (mapfile and os.path.dirname(mapfile)) or ''
71 self.filters = filters
71 self.filters = filters
72 self.defaults = defaults
72 self.defaults = {}
73 self.cache = cache
73
74
74 if not mapfile:
75 if not mapfile:
75 return
76 return
@@ -1,4 +1,4 b''
1 template = '{rev}{tags}{parents} {node|short} {date|isodate} {author|user}\n {desc|firstline|strip}\n\n'
1 changelog = '{rev}{tags}{parents} {node|short} {date|isodate} {author|user}\n {desc|firstline|strip}\n\n'
2 start_tags = '['
2 start_tags = '['
3 tag = '{tag},'
3 tag = '{tag},'
4 last_tag = '{tag}]'
4 last_tag = '{tag}]'
@@ -1,4 +1,4 b''
1 template = 'changeset: {rev}:{node}\n{tags}{parents}{manifest}user: {author}\ndate: {date|date}\nfiles: {files}\n{file_adds}{file_dels}description:\n{desc|strip}\n\n\n'
1 changelog = 'changeset: {rev}:{node}\n{tags}{parents}{manifest}user: {author}\ndate: {date|date}\nfiles: {files}\n{file_adds}{file_dels}description:\n{desc|strip}\n\n\n'
2 start_file_adds = 'files+: '
2 start_file_adds = 'files+: '
3 file_add = ' {file_add}'
3 file_add = ' {file_add}'
4 end_file_adds = '\n'
4 end_file_adds = '\n'
General Comments 0
You need to be logged in to leave comments. Login now