##// END OF EJS Templates
cmdutil: look commit template definition up by specified 'editform'...
FUJIWARA Katsunori -
r22012:9d92b9d1 default
parent child Browse files
Show More
@@ -2193,9 +2193,15 b' def commitforceeditor(repo, ctx, subs, f'
2193 editform=''):
2193 editform=''):
2194 if not extramsg:
2194 if not extramsg:
2195 extramsg = _("Leave message empty to abort commit.")
2195 extramsg = _("Leave message empty to abort commit.")
2196 tmpl = repo.ui.config('committemplate', 'changeset', '').strip()
2196
2197 if tmpl:
2197 forms = [e for e in editform.split('.') if e]
2198 committext = buildcommittemplate(repo, ctx, subs, extramsg, tmpl)
2198 forms.insert(0, 'changeset')
2199 while forms:
2200 tmpl = repo.ui.config('committemplate', '.'.join(forms))
2201 if tmpl:
2202 committext = buildcommittemplate(repo, ctx, subs, extramsg, tmpl)
2203 break
2204 forms.pop()
2199 else:
2205 else:
2200 committext = buildcommittext(repo, ctx, subs, extramsg)
2206 committext = buildcommittext(repo, ctx, subs, extramsg)
2201
2207
@@ -388,6 +388,37 b' required):'
388 - :hg:`tag`
388 - :hg:`tag`
389 - :hg:`transplant`
389 - :hg:`transplant`
390
390
391 Configuring items below instead of ``changeset`` allows showing
392 customized message only for specific actions, or showing different
393 messages for each actions.
394
395 - ``changeset.backout`` for :hg:`backout`
396 - ``changeset.commit.amend`` for :hg:`commit --amend`
397 - ``changeset.commit.normal`` for :hg:`commit` without ``--amend``
398 - ``changeset.fetch`` for :hg:`fetch` (impling merge commit)
399 - ``changeset.gpg.sign`` for :hg:`sign`
400 - ``changeset.graft`` for :hg:`graft`
401 - ``changeset.histedit.edit`` for ``edit`` of :hg:`histedit`
402 - ``changeset.histedit.fold`` for ``fold`` of :hg:`histedit`
403 - ``changeset.histedit.mess`` for ``mess`` of :hg:`histedit`
404 - ``changeset.histedit.pick`` for ``pick`` of :hg:`histedit`
405 - ``changeset.import.bypass`` for :hg:`import --bypass`
406 - ``changeset.import.normal`` for :hg:`import` without ``--bypass``
407 - ``changeset.mq.qnew`` for :hg:`qnew`
408 - ``changeset.mq.qfold`` for :hg:`qfold`
409 - ``changeset.mq.qrefresh`` for :hg:`qrefresh`
410 - ``changeset.rebase.collapse`` for :hg:`rebase --collapse`
411 - ``changeset.rebase.normal`` for :hg:`rebase` without ``--collapse``
412 - ``changeset.shelve.shelve`` for :hg:`shelve`
413 - ``changeset.tag.add`` for :hg:`tag` without ``--remove``
414 - ``changeset.tag.remove`` for :hg:`tag --remove`
415 - ``changeset.transplant`` for :hg:`transplant`
416
417 These dot-separated lists of names are treated as hierarchical ones.
418 For example, ``changeset.tag.remove`` customizes the commit message
419 only for :hg:`tag --remove`, but ``changeset.tag`` customizes the
420 commit message for :hg:`tag` regardless of ``--remove`` option.
421
391 ``decode/encode``
422 ``decode/encode``
392 -----------------
423 -----------------
393
424
@@ -359,6 +359,20 b' specific template keywords work well'
359
359
360 $ cat >> .hg/hgrc <<EOF
360 $ cat >> .hg/hgrc <<EOF
361 > [committemplate]
361 > [committemplate]
362 > changeset.commit.normal = HG: this is "commit.normal" template
363 > HG: {extramsg}
364 > {if(currentbookmark,
365 > "HG: bookmark '{currentbookmark}' is activated\n",
366 > "HG: no bookmark is activated\n")}{subrepos %
367 > "HG: subrepo '{subrepo}' is changed\n"}
368 >
369 > changeset.commit = HG: this is "commit" template
370 > HG: {extramsg}
371 > {if(currentbookmark,
372 > "HG: bookmark '{currentbookmark}' is activated\n",
373 > "HG: no bookmark is activated\n")}{subrepos %
374 > "HG: subrepo '{subrepo}' is changed\n"}
375 >
362 > changeset = HG: this is customized commit template
376 > changeset = HG: this is customized commit template
363 > HG: {extramsg}
377 > HG: {extramsg}
364 > {if(currentbookmark,
378 > {if(currentbookmark,
@@ -373,7 +387,7 b' specific template keywords work well'
373 $ echo 'sub2 = sub2' >> .hgsub
387 $ echo 'sub2 = sub2' >> .hgsub
374
388
375 $ HGEDITOR=cat hg commit -S -q
389 $ HGEDITOR=cat hg commit -S -q
376 HG: this is customized commit template
390 HG: this is "commit.normal" template
377 HG: Leave message empty to abort commit.
391 HG: Leave message empty to abort commit.
378 HG: bookmark 'currentbookmark' is activated
392 HG: bookmark 'currentbookmark' is activated
379 HG: subrepo 'sub' is changed
393 HG: subrepo 'sub' is changed
@@ -381,9 +395,28 b' specific template keywords work well'
381 abort: empty commit message
395 abort: empty commit message
382 [255]
396 [255]
383
397
398 $ cat >> .hg/hgrc <<EOF
399 > [committemplate]
400 > changeset.commit.normal =
401 > # now, "changeset.commit" should be chosen for "hg commit"
402 > EOF
403
384 $ hg bookmark --inactive currentbookmark
404 $ hg bookmark --inactive currentbookmark
385 $ hg forget .hgsub
405 $ hg forget .hgsub
386 $ HGEDITOR=cat hg commit -q
406 $ HGEDITOR=cat hg commit -q
407 HG: this is "commit" template
408 HG: Leave message empty to abort commit.
409 HG: no bookmark is activated
410 abort: empty commit message
411 [255]
412
413 $ cat >> .hg/hgrc <<EOF
414 > [committemplate]
415 > changeset.commit =
416 > # now, "changeset" should be chosen for "hg commit"
417 > EOF
418
419 $ HGEDITOR=cat hg commit -q
387 HG: this is customized commit template
420 HG: this is customized commit template
388 HG: Leave message empty to abort commit.
421 HG: Leave message empty to abort commit.
389 HG: no bookmark is activated
422 HG: no bookmark is activated
General Comments 0
You need to be logged in to leave comments. Login now