# Splitauthor

Splitauthor is a thin wrapper around hg convert that allows you to conditionally set different author maps based on the commit Conversions are Only Mercurial-to-Mercurial conversions are supported; if you are converting from some other system, then you may have to do a non conditional convert to Mercurial and then do a conditional conversion on the new repository.

To use, you need two author maps, the "default" and the "special" one. The default one is used when the supplied regex is not matched, the special one is used when a match is made. It is important to specify a file for both maps, even if the file is empty for the default map. (It's a very thin wrapper and a NULL argument will create problems, but Mercurial can deal with empty maps without difficulty).

Currently, only two maps are supported; however, it possible to do more complicated maps, much in the same way that if...else can be used repeatedly to simulate switch -- simply perform a series of conversions (potentially with an empty default map), with each conversion handling one particular condition.

The program is currently split into two files, splitauthor.sh and filter-revisions.awk. You can use testregex.sh to test whether your regex matches the revisions you want (the local commit message will be prefixed by the local revision number just for the output):

user@localhost$path/to/testregex.sh "your.regex" path/to/repo  If you don't provide the path to the repository, the script will attempt to run on the local directory. The regex is handled for both shell scripts by the shared awk script, so testregex.sh and splitauthor.sh will match exactly the same changesets. After you've got your regex down, then it's time to do things for real: user@localhost$ path/to/splitauthor.sh  source-repo dest-repo "your.regex" default.map special.map  # [args to pass to hg convert]


It's that simple. For one of my projects, when I had just converted to Mercurial, but before I managed to convince my coauthors to convert, I would check in all the changes they sent me with something like "Mark's first set of changes.", for which I could use the regex "^Mark's.*changes"

Like hg convert in general, the operation is by default non destructive and changes are only made in the destination repository. (If you force some destructive option, that's all on you.) So, if it doesn't quite work the way you like, you've lost nothing and can try again if you so desire.