Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Editing the author for specific changesets

Tags:

mercurial

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?

like image 896
FrederikNS Avatar asked Feb 01 '12 10:02

FrederikNS


2 Answers

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 <[email protected]>"

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
like image 176
Laurens Holst Avatar answered Sep 20 '22 15:09

Laurens Holst


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.

like image 20
Arun Avatar answered Sep 20 '22 15:09

Arun