Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I change the username on a mercurial changeset?

Tags:

mercurial

I didn't set the username on my development computer and made a few commits. Can I retroactively change the username so it's clear who committed these changesets?

like image 365
Dan Goldstein Avatar asked Apr 09 '09 04:04

Dan Goldstein


People also ask

How do I revert a changeset in Mercurial?

To revert a file to a specific changeset, use hg revert -r CHANGESET FILENAME . This will revert the file without committing it.

What is mercurial changeset?

A changeset (sometimes abbreviated "cset") is an atomic collection of changes to files in a repository. It contains all recorded local modification that lead to a new revision of the repository. A changeset is identified uniquely by a changeset ID. In a single repository, you can identify it using a revision number.

How do I revert a commit in TortoiseHg?

Reverting Individual Changes Click Commit Changes to Repository on the Source Control toolbar (if the toolbar is hidden, right-click the toolbar area and then click Source Control). In the TortoiseHg client's Commit dialog, right-click the needed file and then click Revert.

What is commit in Mercurial?

run the command hg commit This commits all changes to the project. With hg add we included the files, now we secure the file contents.


2 Answers

If you've not published your repository then this shouldn't be too hard. You need to use the Convert extension to Mercurial, which will let you 'filter' your existing repository to create a new one. the --authors switch lets you edit the author for each commit as it is filtered.

If you have published your repository, please consider the impact on your users, the mercurial wiki has some reasons not to edit history.

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

Run the conversion:

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

I just checked it, it works for me :).

like image 147
Andrew Aylett Avatar answered Sep 27 '22 18:09

Andrew Aylett


If you have a single outgoing changeset, there is a very simple way to do this:

$ hg ci --amend --user "My Name <[email protected]>" -X "**"

The -X "**" option can be omitted if you don't have any local changes.

like image 34
Soulman Avatar answered Sep 27 '22 17:09

Soulman