Mercurial > hg
comparison mercurial/cmdutil.py @ 32878:a3a36bcf122e
commit: select template by spec.ref name
And load all templates defined in [committemplate] since the selected
template is no longer be named as 'changeset'.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sat, 22 Apr 2017 20:29:45 +0900 |
parents | 388e1242ed9e |
children | 5694311db6ed |
comparison
equal
deleted
inserted
replaced
32877:388e1242ed9e | 32878:a3a36bcf122e |
---|---|
2913 | 2913 |
2914 forms = [e for e in editform.split('.') if e] | 2914 forms = [e for e in editform.split('.') if e] |
2915 forms.insert(0, 'changeset') | 2915 forms.insert(0, 'changeset') |
2916 templatetext = None | 2916 templatetext = None |
2917 while forms: | 2917 while forms: |
2918 tmpl = repo.ui.config('committemplate', '.'.join(forms)) | 2918 ref = '.'.join(forms) |
2919 if tmpl: | 2919 if repo.ui.config('committemplate', ref): |
2920 tmpl = templater.unquotestring(tmpl) | |
2921 templatetext = committext = buildcommittemplate( | 2920 templatetext = committext = buildcommittemplate( |
2922 repo, ctx, subs, extramsg, tmpl) | 2921 repo, ctx, subs, extramsg, ref) |
2923 break | 2922 break |
2924 forms.pop() | 2923 forms.pop() |
2925 else: | 2924 else: |
2926 committext = buildcommittext(repo, ctx, subs, extramsg) | 2925 committext = buildcommittext(repo, ctx, subs, extramsg) |
2927 | 2926 |
2955 if unchangedmessagedetection and editortext == templatetext: | 2954 if unchangedmessagedetection and editortext == templatetext: |
2956 raise error.Abort(_("commit message unchanged")) | 2955 raise error.Abort(_("commit message unchanged")) |
2957 | 2956 |
2958 return text | 2957 return text |
2959 | 2958 |
2960 def buildcommittemplate(repo, ctx, subs, extramsg, tmpl): | 2959 def buildcommittemplate(repo, ctx, subs, extramsg, ref): |
2961 ui = repo.ui | 2960 ui = repo.ui |
2962 spec = logtemplatespec(tmpl, None) | 2961 spec = formatter.templatespec(ref, None, None) |
2963 t = changeset_templater(ui, repo, spec, None, {}, False) | 2962 t = changeset_templater(ui, repo, spec, None, {}, False) |
2964 | 2963 t.t.cache.update((k, templater.unquotestring(v)) |
2965 for k, v in repo.ui.configitems('committemplate'): | 2964 for k, v in repo.ui.configitems('committemplate')) |
2966 if k != 'changeset': | |
2967 t.t.cache[k] = v | |
2968 | 2965 |
2969 if not extramsg: | 2966 if not extramsg: |
2970 extramsg = '' # ensure that extramsg is string | 2967 extramsg = '' # ensure that extramsg is string |
2971 | 2968 |
2972 ui.pushbuffer() | 2969 ui.pushbuffer() |