tests/test-log-exthook.t
author Yuya Nishihara <yuya@tcha.org>
Sun, 21 Jan 2018 13:03:03 +0900
changeset 35888 c8e2d6ed1f9e
parent 33964 bfafd189edd9
child 39657 2b9f315a4217
permissions -rw-r--r--
cmdutil: drop aliases for logcmdutil functions (API) .. api:: Log-related utility functions has been renamed as follows: - cmdutil.loglimit -> logcmdutil.getlimit - cmdutil.diffordiffstat -> logcmdutil.diffordiffstat - cmdutil._changesetlabels -> logcmdutil.changesetlabels - cmdutil.changeset_printer -> logcmdutil.changesetprinter - cmdutil.jsonchangeset = logcmdutil.jsonchangeset - cmdutil.changeset_templater -> logcmdutil.changesettemplater - cmdutil.logtemplatespec -> logcmdutil.templatespec - cmdutil.makelogtemplater -> logcmdutil.maketemplater - cmdutil.show_changeset -> logcmdutil.changesetdisplayer - cmdutil.getlogrevs -> logcmdutil.getrevs - cmdutil.getloglinerangerevs -> logcmdutil.getlinerangerevs - cmdutil.displaygraph -> logcmdutil.displaygraph - cmdutil.graphlog -> logcmdutil.graphlog - cmdutil.checkunsupportedgraphflags -> logcmdutil.checkunsupportedgraphflags - cmdutil.graphrevs -> logcmdutil.graphrevs - cmdutil._makenofollowlogfilematcher -> logcmdutil._makenofollowfilematcher

Test hg log changeset printer external hook
-------------------------------------------

  $ cat > $TESTTMP/logexthook.py <<EOF
  > from __future__ import absolute_import
  > from mercurial import (
  >   commands,
  >   logcmdutil,
  >   repair,
  > )
  > def rot13description(self, ctx):
  >     summary = "summary".encode('rot13')
  >     description = ctx.description().strip().splitlines()[0].encode('rot13')
  >     self.ui.write("%s:     %s\n" % (summary, description))
  > def reposetup(ui, repo):
  >     logcmdutil.changesetprinter._exthook = rot13description
  > EOF

Prepare the repository

  $ hg init empty
  $ cd empty
  $ touch ROOT
  $ hg commit -A -m "Root" ROOT

  $ touch a b c
  $ hg commit -A -m "Add A, B, C" a b c

Check the log

  $ hg log --config extensions.t=$TESTTMP/logexthook.py
  changeset:   1:70fc82b23320
  tag:         tip
  user:        test
  date:        Thu Jan 01 00:00:00 1970 +0000
  fhzznel:     Nqq N, O, P
  summary:     Add A, B, C
  
  changeset:   0:b00443a54871
  user:        test
  date:        Thu Jan 01 00:00:00 1970 +0000
  fhzznel:     Ebbg
  summary:     Root
  
Check that exthook is working with graph log too

  $ hg log -G --config extensions.t=$TESTTMP/logexthook.py
  @  changeset:   1:70fc82b23320
  |  tag:         tip
  |  user:        test
  |  date:        Thu Jan 01 00:00:00 1970 +0000
  |  fhzznel:     Nqq N, O, P
  |  summary:     Add A, B, C
  |
  o  changeset:   0:b00443a54871
     user:        test
     date:        Thu Jan 01 00:00:00 1970 +0000
     fhzznel:     Ebbg
     summary:     Root