Svnstat for Mercurial - mercurial

Is there a utility for Mercurial which does something like svnstat does for subversion?

The maillist post found here summarizes a few possibilties to generate reports for mercurial repositories.
The mercurial activity extension mentioned there is under active development and looks promising.

You can get a text graph showing the differences between two revisions
hg diff -r REV -r REV --stat
So that:
hg diff -r 0 -r tip --stat
shows info across the whole repo, but only on a file by file basis.
Alternately there are the hg activity, hg chart, and hg churn extensions.

Related

How to see changes in subrepos between commits

I have a mercurial repo with subrepos (also mercurial). Imagine the situation where I have changed the subrepos and the main repo. Now I want to see the changes between several commits including the changes in the subrepos.
Is it possible?
I use TortoiseHG and diffmerge. In diffmerege calling for visual diff from TortoiseHg, I can't see the changes in the subrepos between several commits.
In the command line you can do the following. Let us say you want to see all the changes of a subrepo named example between the changesets (in the main repo) c608f6017bd7 and 72d284a44170.
In the main repo
hg diff -rc608f6017bd7:72d284a44170 .hgsubstate | grep example
will return the changesets of the subrepo example, something like:
-001fc0acef220bcd42898ef3932dee8330ea64c0 example
+77f9db4d51c4b483607178aba91c872b0adedf1e example
Now you can see the logs and the diffs of the subrepo changes with:
cd example
hg log -r001fc0acef220bcd42898ef3932dee8330ea64c0:77f9db4d51c4b483607178aba91c872b0adedf1e
hg diff -r001fc0acef220bcd42898ef3932dee8330ea64c0:77f9db4d51c4b483607178aba91c872b0adedf1e
If you need it often, you can create a bash script named sublog like:
#!/bin/bash
r=$(hg diff -r$1:$2 .hgsubstate | grep $3 | cut -c 2-41 | tr '\n' ':' | sed 's/:$//'; echo '')
cd $3
hg log -r:$r
and use it like:
sublog c608f6017bd7 72d284a44170 example
I can only tell you how to achieve it on the command line - but that is readily available with tortoiseHG, too:
Most commands can be made aware of subrepositories by using the -S or --subrepos flag. As such, in order to see the diff between two changesets X and Y, including those on all subrepositories, do at the main repository:
hg diff -S -rX:Y
Mind, of course, that it will not show a diff in the subrepositories if there was no change of the sub-repository version(s) committed to the main one.
With the versions of TortoiseHg I've used (which doesn't include the last few releases), I haven't seen a way of doing what you're asking about. There are a few options though:
you can type commands directly in the output log window in TortoiseHg, so you can do hg diff -S -rX:Y there.
Archive the versions of the parent repo which you want to diff to some directories (hg archive --repository <path-to-repo> -r <rev> -S -t files -- <outputfolderpath>, or in TortoiseHg, right-click the changeset, select Export -> Archive). Then use diffmerge on the archive directories. This is a bit tedious (especially if you want to diff many changesets), but you will get a "deep" visual diff.

Diff after committing locally

I just cloned a repo from their remote.
I built the software, changed about 4 files, committed them locally and now want to create a patch that I can show them.
When I run :
hg diff -U8p abc efg pqr > patch_file
I don't see the changes I made. Does hg diff only compare the current files with the last committed files?
How do I get this to work?
To diff the working directory against a particular revision REV, use
hg diff -r REV
To compare two revisions against each other, use
hg diff -r REV1 -r REV2
To figure out which revisions to compare, examine the output of hg log. If you'll be doing this a lot and the base revision is fixed, give it a name (e.g., whatipulled) with
hg tag -r REV whatipulled
You can then specify whatipulled as the revision, instead of a numeric rev id (or a hash).
To export your diffs in a richer format, including commit comments etc., you can also use the following which is designed for this purpose:
hg export -r REV
There's also hg bundle -r REV, which produces a binary file with similar information.
But if you're sending changes back to the parent repo, the best method is to use hg push. It communicates your changesets directly to the parent; you don't even need to know which changesets need pushing. Of course, you must have the right to push to the parent repo.
hg push [ parent_repo_url ]
(If you pulled from it, mercurial should already know the path and you can leave it out).
If the parent repo is on bitbucket and you don't have pu, you can set up your own account on bitbucket, pull/push to that from your local repo, and then issue a "pull request" to the project repo, asking them to pull from you.
All of the above have options to control their behavior, which see.
From hg help diff
If only one revision is specified then that revision is compared to the working directory
In your diff for -r you must to use old tip (latest "not your" changeset) and update to tip (your latest changeset) before diffing.
If some binary data was modified in your changesets, don't forget to use -g option
hg up & hg diff -r <CSET> -g > some.patch
Improved diff for any active changeset and without hand-work for detecting base changeset (for linear history == in single branch)
hg diff -r "parent(min(outgoing()))" -r tip
By default, hg diff compares the currently checked out file with the last commit. You can change this by adding options:
-r REV compares the currently checked out files with a specific revision REV.
-c REV shows the changes made by revision REV
So in your case hg diff -c 123 ... would give you the diff for commit 123.
My guess is that hg outgoing is exactly what you want -- it compares what you've committed locally with what is at the default remote server and shows you a list of those changesets or with -p the commits.
That does, however, shows each changeset separately. If you want to see all the changes combined, you'd have to do hg diff -r HERE -r THERE or since -r HERE is a default, hg diff -r THERE
I see you've asked in a comment "How do I know what THERE is", where THERE is the last changeset remote has, and you can get that answer by doing hg outgoing. If hg outgoing shows it would send changesets 66, 67, and 68, then you want to do hg diff -r 65 to compare what's already there (65) with what's local (68).

Tag diffing in mercurial

In mercurial is there a way to diff between 2 different tags?
I have tagged my builds and have a couple commits in between builds and want to figure out the differences between the 2 builds.
hg diff -r tag1:tag2
That's all there is to it.
This answer in the Kiln StackExchange seems quite complete (based on hg diff and hg log):
To see all of the changesets that were introduced between, say, the tags v1.0 and v1.1, run:
hg log -r v1.0:v1.1
To see the net sum of differences introduced in those revisions, you'd instead run:
hg diff -r v1.0:v1.1
Mercurial can even format this output in changelog-style, if you want. Simply add the --style changelog parameter:
hg log -r v1.0:v1.1 --style changelog

Mercurial - view diff of all files in all changesets listed in hg out?

We have repositories proj & proj_v1. When we do this:
cd c:\proj
hg fetch ..\proj_v1
hg out
We see a list of changesets from proj_v1 that we pulled into proj along with an "auto merge" changeset from the requisite merge.
What Mercurial command can you use to see a diff of all files in all changesets that are listed in the output of hg out?
We'd like to review all changes that would be pushed to proj when we do an hg push.
Would something like hg out -p work for you?
Use: hg out -p (or --patch).

How to let Mercurial show "hg out --patch" diff as visual diff?

It looks like hg out --patch or hg out -p is a good way to see what code is pushed out to the repo (when it is pushed)... but the diff is in text format. Is there a way to make it use kdiff3 as well?
hg outgoing --patch shows the changes in each changeset separately, which probably isn't what you want if you're looking for a visual representation. You more likely want the GUI equivalent of hg diff -r your_latest_changeset -r remote_servers_latest_changeset where the latest changesets are the respective tip revisions if you're not using named branches. You can get that in your favorite GUI using the extdiff extension yielding a final command like:
hg extdiff -p kdiff3 -r your_latest_changeset -r remote_servers_latest_changeset
$ hg out --patch | mdr
Will give you a graphical view
You'll need MDR (mac and win)