tags:

views:

52

answers:

3

Hi all,

One thing I really miss moving from svn to mercurial is that mercurial's hg log command insists on showing all history rather than only the history of my current working revision.

For example, I'm working on a repo with a lot of check-ins to another head within my branch, and the first 20 log entries have nothing to do with my line of development.

There are a bunch of options to hg log, but...
--rev shows the revision asked for but not its ancestors
--branch doesn't work because the active head is in the same branch as mine
--prune removes all ancestors of the other head, even if they're also my ancestors
--user doesn't work because I'm not the only user in this line of development

I guess I could hg strip, but that seems like overkill...

Thoughts?
Ryan

A: 

As Niall C said, you can do this from the command line using revsets:

hg log --rev "ancestors(.)"

Also, if you have TortoiseHg, you can filter the revision graph in the Repository Explorer using the radio buttons marked "All", "Tagged", "Ancestry", "Parents", "Heads", "Merges" and so on just above your history. In this case, you would select the revision whose ancestry you are interested in and then choose the "Ancestry" option.

jammycakes
+2  A: 

If you've got Mercurial 1.6 or later, you can use revsets to do this:

hg log --rev "ancestors(.)"
hg log --rev "reverse(ancestors(.))"  # Output in the same order as vanilla hg log
Niall C.
Awesome! Just a quick note -- bash wants that enclosed in quotes
Ryan
@ryan: I'm on Windows, where they're not required (at least for this case).
Niall C.
A: 

I know revision sets is all the rage these days, but the little-known --follow flag lets you do what you want using any version of Mercurial. The hg log help says (my emphasis in bold):

[...] Use -f/--follow with a filename to follow history across renames and copies. --follow without a filename will only show ancestors or descendants of the starting revision. [...]

If no revision range is specified, the default is tip:0 unless --follow is set, in which case the working directory parent is used as the starting revision. [...]

So, in other words, adding -f will do the trick for you. You can add -f to your defaults:

[defaults]
log = -f

or you can create an alias for this:

[alias]
logf = log -f
Martin Geisler