Can I change the username in the mercury change set?

I did not set the username on my development computer and made several commits. Can I retroactively change the username so that it clears who made these changes?

+60
mercurial
Apr 09 '09 at 4:37
source share
4 answers

If you have not published your repository, this should not be too complicated. You should use Convert Extension to Mercurial, which allows you to "filter" the existing repository to create a new one. the --authors switch allows you to edit the author for each commit as it is filtered.

If you published your repository, think about influencing your users, the mercurial wiki has reasons not to edit the story .

Enable the extension by adding these lines to your .hgrc:

[extensions] hgext.convert= 

Write a file to map the old name to the new name (authors.convert.list):

 user@ubuntu=real.name@my.example.com 

Run the conversion:

 hg convert --authors authors.convert.list SOURCE DEST 

I just checked it works for me :).

+75
Apr 16 '09 at 19:09
source share

I tried several different methods (including the Convert Extension , which I found created an unrelated repository). The recommendations of the Mercurial wiki for editing history using MQ were most helpful. (Of course, the usual warnings about changing any public history are a bad idea, but the local changes that you only have are OK for editing).

I briefly outline the main steps here and clarify the mechanics of changing the author. Assuming that the first erroneous author was fixed in the BAD edition (and you did not publish anything anywhere), you should be able to do the following (suppose you are in the root of the repository):

Enable MQ by adding it to $ HOME / .hg / hgrc

 [extensions] hgext.mq= 

Convert recent changes to patches:

 $ hg qimport -r BAD:tip 

(Now they can be found in .hg/patches )

Do not use all patches (suppose they were applied and canceled them) to get your repository in check state before BAD :

 $ hg qpop -a 

If you look at your patches, you will see that the author is encoded as a comment line in all corrections:

 $ grep User .hg/patches/* .hg/patches/102.diff:# User Firstname Lastname <f.lastname@oops.wrongurl.example.com> 

Now use your favorite search / replace tool to fix corrections (I use Perl here). Suppose you want the commit name to be f.lastname@righturl.example.com :

 $ perl -pi -e 's/f\.lastname\@oops\.wrongurl\.example\.com/f.lastname\@righturl.example.com/' .hg/patches/*.diff 

Now verify that you have successfully changed the author’s name and reapplied the corrections:

 $ hg qpush -a 

Then convert the applied fixes to the necessary changes:

 $ hg qfinish -a 

And you're done. Your repository is still displayed as linked, so you won’t receive complaints that you clicked.

+11
Oct 15 '13 at 3:43 on
source share

If you have one outgoing change set, there is a very simple way to do this:

 $ hg ci --amend --user "My Name <mymail@example.org>" -X "**" 

The -X "**" option may be omitted if you do not have local changes.

+7
Jul 31 '15 at 7:33
source share

I used the histedit extension, which allowed me to change the author without making new repositions such as "convert", or resorting to "mq".

First, in your Mercurial configuration file, make sure your username is set correctly and enable the histedit extension:

 [ui] username = Your Name <your.name@domain.org> [extensions] histedit = 

Then, if you want to change version 40, use:

 hg histedit -r 40 

In the file that appears, in the line corresponding to revision 40, change the word pick to edit . Save and close the file.

Now hg commit . You will need to re-enter the commit message and save.

Finally, hg histedit --continue .

The end will appear with your new username . A side effect is also a temporary fixation mark.

+6
Jan 31 '15 at 4:28
source share



All Articles