In mercurial, how to get list of all files added by a particular user? Would greatly appreciate if this can be generated for a specific branch.
List all the files added (not modified) by user eve on any branch:
hg log --rev 'user(eve) and adds("glob:**")' --template '{file_adds}\n'
List all the files added (not modified) by user eve on branch pizza:
hg log --rev 'user(eve) and adds("glob:**") and branch(pizza)' --template '{file_adds}\n'
To learn more, see hg help revsets and hg help templating. Mercurial is a fantastic tool.
Related
Is there a way to get a copy of a hg repository as it was at a particular date?
For example, in subversion I would use:
svn checkout -r {2012-04-04} ...
And it would check out a revision as it appeared on the fourth of April.
In git its a little more complicated, but can be done:
git checkout `git rev-list -n 1 --before="2012-04-04" master`
Can you do the same thing in hg?
(EDIT: My love of revsets has caused me to overlook the obvious answer: hg update --date 2012-04-04 should get you the tipmost revision as of that date.)
If you have the whole repository cloned already (date specifications don't seem to work with clone), you can do
hg update --rev "date('< 2012-04-04')"
If there's a possibility that the repository had multiple heads/branches at the date you want, you'll have to AND in some more conditions to narrow it down to the right changeset:
hg update --rev "date('< 2012-04-04') and branch(v1.1)"
Check out hg help revsets and hg help dates for more information.
Later, if you want to go back to the tip, just
hg update
At the moment I am looking at transitioning from subversion to Mercurial at work, and as such the Mercurial repository is not yet published.
I have used the authormap argument to transform our usernames to the Mercurial format, which went fine.
Unfortunately two people have been commiting under the same name. The repository is not very large, so I would like to change the authors to match the right people. For that reason I would like to ask:
Is there any way to change the author for a specific changeset, or a list of changesets?
You can use the bundled extension Mercurial Queues (MQ) to change commit authors. Note that MQ will only work as long as history is linear. If there are branches you need to first rebase them off to a temporary side branch, and then after editing rebase them back.
First qimport the changes up till the first changeset you want to modify:
hg qinit
hg qimport -g -r <first-revnr>:tip
Then use qpop or qgoto to navigate to the respective changesets:
hg qgoto <revnr>.diff
And then use qrefresh to change the user info on the currently active changeset:
hg qrefresh -u "Some User <user#example.com>"
You can verify with hg log whether the user was correctly updated. After this, repeat for all other changesets.
When you are done, qpush all patches and use qfinish to finalize the repository.
hg qpush -a
hg qfinish -a
You could as well use the evolve extension. After setting up the extension
hg amend -U && hg prev
for a stack of commits and then hg evolve --all at the end.
Evolve introduces a meta-graph that says which commit replaces which commit.
So when we do hg amend -U a bunch of times, we create commits with a different author that replaced the old commits. hg evolve --all the will use the replacement information to figure out where to move commits that were based on our pre-replaced commits.
Credits to mercurial developers on IRC #mercurial.
I'm looking for a way to view all of a repository's branches and each file that has changed in that branch. I'm not interested in the file level changes as this report is for simple auditing.
Can this be done?
hg log -b <branchname> --template "{files} "
Plus some post-processing, because output will be like this
lang/UTF-8/serendipity_lang_ru.inc.php lang/UTF-8/serendipity_lang_ru.inc.php lang/UTF-8/serendipity_lang_ru.inc.php lang/UTF-8/serendipity_lang_ru.inc.php plugins/serendipity_event_assigncategories/UTF-8/lang_ru.inc.php plugins/serendipity_event_entryproperties/UTF-8/lang_ru.inc.php plugins/serendipity_event_freetag/UTF-8/lang_ru.inc.php plugins/serendipity_event_gravatar/UTF-8/lang_ru.inc.php plugins/serendipity_event_relatedlinks/UTF-8/lang_ru.inc.php plugins/serendipity_event_nl2br/UTF-8/lang_ru.inc.php plugins/serendipity_event_freetag/UTF-8/lang_ru.inc.php
Use hg status to get information about files that have changed between revisions. See the revset language for how to select the revisions.
If you want to see file changes between the first and last changesets on branch B:
$ hg status --rev "min(branch(B)):max(branch(B))"
You can even make an alias for this:
[alias]
audit = status --rev "min(branch($1)):max(branch($1))"
and then use hg audit B to get the same result.
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.
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).