Friday, May 30, 2014

hg log --graph --template

Some differences in the --graph behaviour with modified code. Let's see the Mercurial code:

$ clone http://selenic.com/hg
$ cd hg

First with the default log command:

$ hg log --graph --template='{rev}' -r 19655:19645
o  19655
|
o    19654
|\
| o    19653
| |\
| | o  19652
| | |
| | o  19651
| | |
| | o  19650
| | |
o | |  19649
|\| |
o | |  19648
| | |
o | |  19647
| | |
o | |  19646
| | |
| o |  19645
|/|/

Nice. A little stretched. Now with one CR/LF '\n':

$ hg log --graph --template='{rev}\n' -r 19655:19645
o  19655
|
o    19654
|\
| o    19653
| |\
| | o  19652
| | |
| | o  19651
| | |
| | o  19650
| | |
o | |  19649
|\| |
o | |  19648
| | |
o | |  19647
| | |
o | |  19646
| | |
| o |  19645
|/|/

Equal. More CR/LF:

$ hg log --graph --template='{rev}\n\n' -r 19655:19645
o  19655
|
o    19654
|\
| o    19653
| |\
| | o  19652
| | |
| | o  19651
| | |
| | o  19650
| | |
o | |  19649
|\| |
o | |  19648
| | |
o | |  19647
| | |
o | |  19646
| | |
| o |  19645
|/|/

Ups! Equal again. And last:

$ hg log --graph --template='{rev}\n\n\n' -r 19655:19645
o  19655
|
|
o    19654
|\
| |
| o    19653
| |\
| | |
| | o  19652
| | |
| | |
| | o  19651
| | |
| | |
| | o  19650
| | |
| | |
o | |  19649
|\| |
| | |
o | |  19648
| | |
| | |
o | |  19647
| | |
| | |
o | |  19646
| | |
| | |
| o |  19645
|/|/
| |

Ok.

Second with the modified command:

$ ./hg log --graph --template='{rev}' -r 19655:19645
o  19655
o    19654
|\
| o    19653
| |\
| | o  19652
| | o  19651
| | o  19650
o | |  19649
|\| |
o | |  19648
o | |  19647
o | |  19646
| o |  19645
|/|/

Nice. Adjusted.

$ ./hg log --graph --template='{rev}\n' -r 19655:19645
o  19655
o    19654
|\
| o    19653
| |\
| | o  19652
| | o  19651
| | o  19650
o | |  19649
|\| |
o | |  19648
o | |  19647
o | |  19646
| o |  19645
|/|/

Ok, as '\n' is there.

$ ./hg log --graph --template='{rev}\n\n' -r 19655:19645
o  19655
|
o    19654
|\
| o    19653
| |\
| | o  19652
| | |
| | o  19651
| | |
| | o  19650
| | |
o | |  19649
|\| |
o | |  19648
| | |
o | |  19647
| | |
o | |  19646
| | |
| o |  19645
|/|/

Better.

$ ./hg log --graph --template='{rev}\n\n\n' -r 19655:19645
o  19655
|
|
o    19654
|\
| |
| o    19653
| |\
| | |
| | o  19652
| | |
| | |
| | o  19651
| | |
| | |
| | o  19650
| | |
| | |
o | |  19649
|\| |
| | |
o | |  19648
| | |
| | |
o | |  19647
| | |
| | |
o | |  19646
| | |
| | |
| o |  19645
|/|/
| |

As expected.

That's all.