pahnin
pahnin

Reputation: 5588

Mercurial equivalent of git whatchanged?

I want to get similar output of the Git command:

$ git whatchanged <old_rev>..<new_rev> --pretty=oneline --name-status

I read that hg outgoing can help, but it doesn't have anything related to revisions in its help page:

$ hg diff <old_rev>..<new_rev> gave the differences, but the output is:

diff -r d3ed0d3eb928 -r 63329069147f hello.rb
--- a/hello.rb  Tue Jul 31 16:52:40 2012 +0530
+++ b/hello.rb  Wed Aug 01 11:15:33 2012 +0530
@@ -1,1 +1,1 @@
-print "Hello"
+print "Hello World"

while I need something similar to:

bb3b9a6bc00b7203ab6491dbd062641fa60efb95 Fix for #4 and other small errors
M       .gitignore
A       config.ru
D       db/database.db
M       views/setup.haml
1c4ff29e5c7fc707c6fe314c060cd1935b300dd9 Added keyboard shortcuts and reload
M       README.md
A       public/javascript/keys.js
d0755d0b54cb4129fbf7730fe0bdf21a3996e224 Basic player completed
M       README.md
D       public/javascript/jquery-ui-1.8.21.custom.min.js
...

which I get with git whatchanged 1c4ff29e5c7fc707c6fe314c060cd1935b300dd9 bb3b9a6bc00b7203ab6491dbd062641fa60efb95 --pretty=oneline --name-status

Upvotes: 4

Views: 429

Answers (3)

Paul S
Paul S

Reputation: 7755

If you're looking for a way of getting which files have changed, but you're not too worried about the formatting being like git, then I quite like the diffstat switch on any of the commands that normally print diffs.

# hg in --stat
# hg out --stat
# hg diff -r <old_rev>:<new_rev> --stat
... and a load more

It's not exactly the same info. It's not per changeset, and it doesn't say if a file is added / modified / deleted, but on the other hand it gives some idea of the extent of changes.

Upvotes: 1

Laurens Holst
Laurens Holst

Reputation: 21026

You could give the changelog style a try. It doesn’t look exactly the same of course, but it does list the files that were touched by the commit, which I reckon is what you are looking for. Examples:

hg log --style changelog
hg outgoing --style changelog

And as Christian said, you can customise the exact output to infinity using templates. For more information see hg help templating.

Upvotes: 2

Christian Specht
Christian Specht

Reputation: 36421

You can use hg log for this and customize the output with a template.

Example:

hg log -r <old_rev>:<new_rev> --template "{node} {desc}\n{files}\n\n"

This will look similar to your Git example.
The list of files doesn't look the same, though (no line breaks).

I never tried it myself, but it's also possible to customize the output with styles (similar to templates, but you save the style in a file and just refer to it by the name).
The documentation for this is on the same link I posted above, at the bottom of the page.
Apparently, it's possible to put line breaks between the files as well (there's an example for this on the page).

Upvotes: 1

Related Questions