Search code examples
mercurial

Can I change the username on a mercurial changeset?


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?


Solution

  • 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@ubuntu=real.name@my.example.com
    

    Run the conversion:

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

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