Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/cmdutil.py @ 7967:c03f42159afa
cmdutil: refactor handling of templating in show_changeset()
author | Dirkjan Ochtman <dirkjan@ochtman.nl> |
---|---|
date | Sat, 04 Apr 2009 17:55:52 +0200 |
parents | de377b1a9a84 |
children | 9ec25db32b4e |
comparison
equal
deleted
inserted
replaced
7966:aa983c3d94a9 | 7967:c03f42159afa |
---|---|
910 patch = False | 910 patch = False |
911 if opts.get('patch'): | 911 if opts.get('patch'): |
912 patch = matchfn or matchall(repo) | 912 patch = matchfn or matchall(repo) |
913 | 913 |
914 tmpl = opts.get('template') | 914 tmpl = opts.get('template') |
915 mapfile = None | 915 style = None |
916 if tmpl: | 916 if tmpl: |
917 tmpl = templater.parsestring(tmpl, quoted=False) | 917 tmpl = templater.parsestring(tmpl, quoted=False) |
918 else: | 918 else: |
919 mapfile = opts.get('style') | 919 style = opts.get('style') |
920 # ui settings | 920 |
921 if not mapfile: | 921 # ui settings |
922 tmpl = ui.config('ui', 'logtemplate') | 922 if not (tmpl or style): |
923 if tmpl: | 923 tmpl = ui.config('ui', 'logtemplate') |
924 tmpl = templater.parsestring(tmpl) | 924 if tmpl: |
925 else: | 925 tmpl = templater.parsestring(tmpl) |
926 mapfile = ui.config('ui', 'style') | 926 else: |
927 | 927 style = ui.config('ui', 'style') |
928 if tmpl or mapfile: | 928 |
929 if mapfile: | 929 if not (tmpl or style): |
930 if not os.path.split(mapfile)[0]: | 930 return changeset_printer(ui, repo, patch, opts, buffered) |
931 mapname = (templater.templatepath('map-cmdline.' + mapfile) | 931 |
932 or templater.templatepath(mapfile)) | 932 mapfile = None |
933 if mapname: mapfile = mapname | 933 if style and not tmpl: |
934 try: | 934 mapfile = style |
935 t = changeset_templater(ui, repo, patch, opts, mapfile, buffered) | 935 if not os.path.split(mapfile)[0]: |
936 except SyntaxError, inst: | 936 mapname = (templater.templatepath('map-cmdline.' + mapfile) |
937 raise util.Abort(inst.args[0]) | 937 or templater.templatepath(mapfile)) |
938 if tmpl: t.use_template(tmpl) | 938 if mapname: mapfile = mapname |
939 return t | 939 |
940 return changeset_printer(ui, repo, patch, opts, buffered) | 940 try: |
941 t = changeset_templater(ui, repo, patch, opts, mapfile, buffered) | |
942 except SyntaxError, inst: | |
943 raise util.Abort(inst.args[0]) | |
944 if tmpl: t.use_template(tmpl) | |
945 return t | |
941 | 946 |
942 def finddate(ui, repo, date): | 947 def finddate(ui, repo, date): |
943 """Find the tipmost changeset that matches the given date spec""" | 948 """Find the tipmost changeset that matches the given date spec""" |
944 df = util.matchdate(date) | 949 df = util.matchdate(date) |
945 get = util.cachefunc(lambda r: repo[r].changeset()) | 950 get = util.cachefunc(lambda r: repo[r].changeset()) |