Enhancing 'log' so it prints more info depending on an extension

Yann E. MORIN yann.morin.1998 at anciens.enib.fr
Wed Sep 23 17:31:16 CDT 2009


Hello All!

In this thread [1], I found that 'log' was missing some usefull info
that is stored by the 'transplant' extension. Namely, the transplanted
changeset's source is not printed.

I think it would be nice if the source was printed by the 'log' command,
like both parents of a merge are. Of course 'parent' is reserved for
merges and we should find another label (such as 'transplant source',
or name it...).

I was wondering what would be the best way to do this, and I came up with
the following solutions:

1) override the 'log' command in the 'transplant' extension
   - the 'log' command calls the original 'log' command,
   - then print additional info

1bis) completely rewrite the 'log' command
   - duplicate the code in 'log'
   - ugly... :-(

2) register callbacks
   - on load, an extension registers a 'log-callback'
   - when run, the 'log' command prints its traditional data
   - then calls each 'log-callback' in turn
     - each extension prints its own data

In the case of the 'transplant' extension, the extra information would be
the original changeset hash, that is stored in the 'extra' field labeled
'transplant_source'.

I've had a look at how the 'graphlog' extension handles it, and it seems
to me that it overloads the 'log' commands with its own. And if I just
do it the same in the 'transplant' extension, then it should be quite
easy to add some info to 'log' output, and I was going this way...

What I wonder about is, what happens when two or more extensions try to
override the same command? Which is called? If both are called, which is
called first?

Regards,
Yann E. MORIN.

[1] http://www.selenic.com/pipermail/mercurial/2009-September/thread.html#27647

-- 
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +0/33 662376056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| --==< ^_^ >==-- `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
`------------------------------^-------^------------------^--------------------'




More information about the Mercurial-devel mailing list