6

Related here. Instructions here guide with example:

john=John Smith <John.Smith@someplace.net>
tom=Tom Johnson <Tom.Johnson@bigcity.com>

but what does it mean? Suppose I want to replace "hh <right@gmail.com>" with "hhh <right@gmail.com>", what would that line look like? What do the terms username, mapping and filename mean? I can find this part "username mapping filename" from "convert/__init__.py":

cmdtable = {
    "convert":
        (convert,
         [('A', 'authors', '', _('username mapping filename')),
          ('d', 'dest-type', '', _('destination repository type')),
          ('', 'filemap', '', _('remap file names using contents of file')),
          ('r', 'rev', '', _('import up to target revision REV')),

It makes an object where the authors are stored as dict, convcmd.py line 79:

class converter(object):
    def __init__(self, ui, source, dest, revmapfile, opts):

        self.source = source
        self.dest = dest
        self.ui = ui
        self.opts = opts
        self.commitcache = {}
        self.authors = {}
        self.authorfile = None

it splits the each line in authorfile with "=" but from this onwards I am lost how does it work. So what is the authors.file to fix wrong authors supposingly meant to look like? If you can, please point me to the source line because I find the docs very unreadable.

[Update]

I have tried all kind of options for the file but the "$ hg status"/"$ hg log --template '{author}\n'" won't get changed. Either I need to do something odd after the command "$ hg convert --authors conversionAuthors ." or I cannot match the authors. How can I know "exact match"? How can I know whether I succeed?

Community
  • 1
  • 1
hhh
  • 50,788
  • 62
  • 179
  • 282

1 Answers1

7

The convert extension uses a literal text substitution.

A quick experiment shows if you want to replace hh <right@gmail.com>, you simply create an author map file with these contents:

hh <right@gmail.com> = hhh <right@gmail.com>

The left-hand side must be an exact match for the author you want to replace. If it is not an exact match, no substitution is performed.

Tim Henigan
  • 60,452
  • 11
  • 85
  • 78
  • @Tim Henigan: how can you check whether it is an exact match? – hhh Apr 06 '11 at 16:52
  • 1
    @hhh: Simply look at the log output. You can see just the author portion of the commit log using `hg log --template "{author}\n" -r `. – Tim Henigan Apr 06 '11 at 16:54
  • @Tim Henigan: syntax err with the "-r " – hhh Apr 06 '11 at 16:56
  • @hhh: You need to replace `` with the actual revision you want to see...or you can leave off the `-r ` if you want to list the author of every commit in your repo. This output is simply intended to show the exact author string for the changesets in your repo. – Tim Henigan Apr 06 '11 at 17:00
  • @Tim Henigan: if the command succeed, do the changes will appear with `"$ hg status"`? The command returns no information about the mail in `""`, I used an email so I am wondering whether the email should be there or is it different email. – hhh Apr 06 '11 at 17:01
  • @hhh: When you run the `convert` command, it rewrites the repo history. If successful, it creates a brand new repo that has all the same changesets, but the author names that you specified are changed (as are the changeset hashes, if I recall). `hg status` will not show any changes. You must inspect `hg log` to see the changed authors. – Tim Henigan Apr 06 '11 at 17:08
  • @hhh: The `hg convert` command creates a new repository in the destination folder, but it doesn't check out a working copy. The `hg status` command shows nothing because there is no working copy. But you can still examine the repo logs with `hg log` to verify that your changes have been made. – Karmastan Apr 06 '11 at 17:10
  • @Tim Henigan: hey! It created `".-hg"` where I can see with `"$ hg log"` that the log was changed successfully. Now I need to find out how to apply the changes to my current repo. Do I just replace the old .hg dir with the new .hg dir? When I did that it result in errs `"abort: working directory has unknown paret'18...'!"` – hhh Apr 06 '11 at 17:14
  • @hhh: Unfortunately, you cannot apply the changes to your current repo. See this related SO question: http://stackoverflow.com/questions/3950792/how-to-deal-with-committer-name-change-in-mercurial/3950827#3950827 – Tim Henigan Apr 06 '11 at 17:17
  • @Tim Henigan: do you mean that I need to delete my current repo and create a new one? I am a bit lost how I should cat with the right log-entries. – hhh Apr 06 '11 at 17:21
  • 1
    @hhh: as noted in my previous comment, the result of `convert` was a new repo (i.e. your `".-hg"`). You cannot merge this new repo with the old one. So if you *need* to change the author info, then you must delete the old repo and replace it with the new one. – Tim Henigan Apr 06 '11 at 17:32
  • 2
    Tim is spot on here. Think of 'convert' like 'translate'. It creates a new, entirely different repository based on the first. You then just start using the new one instead of the old one and anyone who had the old one needs to start using the new one too. You can move the old one to a new name and move the new one to the old name, but you've still changed all the node hashes, so they're not meaningfully mergeable nor interchangeable. – Ry4an Brase Apr 07 '11 at 14:35