Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I show the current working revision on mercurial's "hg log"?

I want my "hg h" (an hg log alias's output) to show what my currently working revision is in the context of the history/log.

On my .hgrc I have the following:

[alias]
h = log --template "{rev} {node|short} {date|shortdate} | [{author|user}] {desc|strip|firstline} :: {tags}\n"

Here's a sample output:

$ hg h
1 f130b4194c90 2011-07-21 | [slashfoo] added a comment :: tip
0 f4b4ec3c8c95 2011-07-21 | [slashfoo] initial commit ::

But if I update to revision 0, the output is still the same:

$ hg up 0
1 files updated, 0 files merged, 0 files removed, 0 files unresolved

$ hg h
1 f130b4194c90 2011-07-21 | [slashfoo] added a comment :: tip
0 f4b4ec3c8c95 2011-07-21 | [slashfoo] initial commit ::

An example desired output would be:

$ hg h
1 f130b4194c90 2011-07-21 | [slashfoo] added a comment :: tip
0 f4b4ec3c8c95 2011-07-21 | [slashfoo] initial commit :: [working]

note: that [working] is NOT a tag, just my working revision, the one I updated-to.

Another example could be:

$ hg h
1 f130b4194c90 2011-07-21 | | [slashfoo] added a comment :: tip
0 f4b4ec3c8c95 2011-07-21 |X| [slashfoo] initial commit ::

I customized my "hg h" output using the hgbook's entry on "Customizing the output of Mercurial" http://hgbook.red-bean.com/read/customizing-the-output-of-mercurial.html

Alternatives to what I want to do could be:

  1. using graphlog extension and doing hg h -G so that an @ would denote current working revision
  2. using hg id to know what revision I am
  3. using hg parents to know what revision I am with some extra info

But only alternative #1 shows me the context, but hg log -G and aliases are a bit less "compact" than my desired output.

Here's a sample of the output of alternative #1

$ hg h -G
o  1 f130b4194c90 2011-07-21 | [slashfoo] added a comment :: tip
|
@  0 f4b4ec3c8c95 2011-07-21 | [slashfoo] initial commit ::

This question is simmilar to How can I find my working revision in mercurial but I want it in context, and in a compact manner (i.e. without -G)

like image 491
slashfoo Avatar asked Oct 11 '22 11:10

slashfoo


1 Answers

hg log --rev $(hg id -i | sed 's/.$//')

like image 162
d9k Avatar answered Oct 13 '22 01:10

d9k