Mercurial: change username of some commits not yet pushed?

I made a few commits, but later realized that I didn't have the correct username setting. I changed it and made some more commits with the correct username. Is there a way to change the first commits to use the new username before pushing all of them?

+3


source to share


2 answers


Here's how I would achieve my goal, it relies on mq

extension
, the Mercurial patch queue. (Updated to include @ MarkTolonen's wonderful comment )

Step 0. Back up your work! (you can create a local drop clone to try this)

  • Include the extension mq

    in your config files (see help here )
  • use hg qimport

    to import the changes you want to change into the patch queue.
  • use hg qpop -a

    to pull these patches from the applied patch of patches.
  • press the first patch with hg qpush

  • use hg qref -U

    to update the author of the patch to the current user (or use hg qref -u <username>

    to install it explicitly)
  • repeat steps 4 and 5. for each patch in the queue.
  • double check your work. Is your username correct in the log?
  • use hg qfin -a

    to complete patches in changesets.
  • you should now be ready to push the updated changes to the public repo



My initial steps involved manually configuring the user in a text editor instead of steps 4-6 above:

and. open the folder .hg\patches

, you should have a file ###.diff

for each changeset
B. open them in a text editor of your choice
C. edit the line at the top that starts with # User <your old user name>


 and update it as # User <your new user name>


D. save patches
E. use hg push -a

to put them back on the application stack

+2


source


Probably the easiest (and fastest) way is to convert your repository from Mercurial to Mercurial with a special one --authormap

to replace the old username with the new one



+1


source







All Articles