diff -r ecacdd9a981b -r 56c8860d7303 README.md
--- a/README.md Thu Feb 23 13:26:27 2012 -0500
+++ b/README.md Thu Feb 23 13:49:07 2012 -0500
@@ -150,6 +150,36 @@
[git]
intree = True
+git.authors
+-----------
+
+Git uses a strict convention for "author names" when representing changesets,
+using the form `[realname] [email address]`. Mercurial encourages this
+convention as well but is not as strict, so it's not uncommon for a Mercurial
+repo to have authors listed as simple usernames. hg-git by default will
+translate such names using the email address `none@none`, which then shows up
+unpleasantly on GitHub as "illegal email address".
+
+The `git.authors` option provides for an "authors translation file" that will
+be used during outgoing transfers from mercurial to git only, by modifying
+`hgrc` as such:
+
+ [git]
+ authors = authors.txt
+
+Where `authors.txt` is the name of a text file containing author name translations,
+one per each line, using the following format:
+
+ johnny = John Smith <jsm...@foo.com>
+ dougie = Doug Johnson <dou...@bar.com>
+
+Empty lines and lines starting with a "#" are ignored.
+
+It should be noted that **this translation is on the hg->git side only**. Changesets
+coming from Git back to Mercurial will not translate back into hg usernames, so
+it's best that the same username/email combination be used on both the hg and git sides;
+the author file is mostly useful for translating legacy changesets.
+
git.branch_bookmark_suffix
---------------------------
diff -r ecacdd9a981b -r 56c8860d7303 hggit/git_handler.py
--- a/hggit/git_handler.py Thu Feb 23 13:26:27 2012 -0500
+++ b/hggit/git_handler.py Thu Feb 23 13:49:07 2012 -0500
@@ -80,6 +80,8 @@
else:
self.gitdir = self.repo.join('git')
+ self.init_author_file()
+
self.paths = ui.configitems('paths')
self.branch_bookmark_suffix = ui.config('git', 'branch_bookmark_suffix')
@@ -95,6 +97,19 @@
os.mkdir(self.gitdir)
self.git = Repo.init_bare(self.gitdir)
+ def init_author_file(self):
+ self.author_map = {}
+ if self.ui.config('git', 'authors'):
+ with open(self.repo.wjoin(
+ self.ui.config('git', 'authors')
+ )) as f:
+ for line in f:
+ line = line.strip()
+ if not line or line.startswith('#'):
+ continue
+ from_, to = re.split(r'\s*=\s*', line, 2)
+ self.author_map[from_] = to
+
## FILE LOAD AND SAVE METHODS
def map_set(self, gitsha, hgsha):
@@ -401,6 +416,10 @@
# hg authors might not have emails
author = ctx.user()
+ # see if a translation exists
+ if author in self.author_map:
+ author = self.author_map[author]
+
# check for git author pattern compliance
regex = re.compile('^(.*?) ?\<(.*?)(?:\>(.*))?$')
a = regex.match(author)
diff -r e58a6d0b80e2 -r ecacdd9a981b README.md
--- a/README.md Wed Feb 15 09:30:06 2012 +0800
+++ b/README.md Thu Feb 23 13:26:27 2012 -0500
@@ -149,3 +149,35 @@
[git]
intree = True
+
+git.branch_bookmark_suffix
+---------------------------
+
+hg-git currently does not recognize Mercurial named branches; it only supports Mercurial
+bookmarks. Therefore, when translating an hg repo over to git, you typically need
+to create bookmarks to mirror all the named branches that you'd like to see transferred
+over to git. The major caveat with this is that you can't use the same name for your
+bookmark as that of the named branch, and furthermore there's no feasible way to rename
+a branch in Mercurial. For the use case where one would like to transfer an hg
+repo over to git, and maintain the same named branches as are present on the hg side,
+the `branch_bookmark_suffix` might be all that's needed. This presents a string
+"suffix" that will be recognized on each bookmark name, and stripped off as the
+bookmark is translated to a git branch:
+
+ [git]
+ branch_bookmark_suffix=_bookmark
+
+Above, if an hg repo had a named branch called `release_6_maintenance`, you could
+then link it to a bookmark called `release_6_maintenance_bookmark`. hg-git will then
+strip off the `_bookmark` suffix from this bookmark name, and create a git branch
+called `release_6_maintenance`. When pulling back from git to hg, the `_bookmark`
+suffix is then applied back, if and only if an hg named branch of that name exists.
+E.g., when changes to the `release_6_maintenance` branch are checked into git, these
+will be placed into the `release_6_maintenance_bookmark` bookmark on hg. But if a
+new branch called `release_7_maintenance` were pulled over to hg, and there was
+not a `release_7_maintenance` named branch already, the bookmark will be named
+`release_7_maintenance` with no usage of the suffix.
+
+The `branch_bookmark_suffix` option is, like the `authors` option, intended for
+migrating legacy hg named branches. Going forward, an hg repo that is to
+be linked with a git repo should only use bookmarks for named branching.
> # HG changeset patch
> # User Mike Bayer <mik...@zzzcomputing.com>
> # Date 1330021587 18000
> # Node ID ecacdd9a981b5e9fd9442534bda7e1ad5e086e84
> # Parent e58a6d0b80e2cf8e3fb833a495df4603884132f1
> Add documentation for branch_bookmark_suffix configuration parameter
>
> diff -r e58a6d0b80e2 -r ecacdd9a981b README.md
> --- a/README.md Wed Feb 15 09:30:06 2012 +0800
> +++ b/README.md Thu Feb 23 13:26:27 2012 -0500
> @@ -149,3 +149,35 @@
>
> [git]
> intree = True
> +
> +git.branch_bookmark_suffix
> +---------------------------
> +
> +hg-git currently does not recognize Mercurial named branches;
It doesn't convert git branches to hg named branches because they're different things, but it's inaccurate to say it's ignorant of hg named branches. They get recorded as metadata in the commit object when writing to git. Can you clean this sentence up to make it less confusing?
> --
> You received this message because you are subscribed to the Google Groups "hg-git" group.
> To post to this group, send email to hg-...@googlegroups.com.
> To unsubscribe from this group, send email to hg-git+un...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/hg-git?hl=en.
>
On Feb 23, 2012, at 12:56 PM, Mike Bayer wrote:
>
> On Feb 23, 2012, at 12:56 PM, Mike Bayer wrote:
>
>> # HG changeset patch
>> # User Mike Bayer <mik...@zzzcomputing.com>
>> # Date 1330021587 18000
>> # Node ID ecacdd9a981b5e9fd9442534bda7e1ad5e086e84
>> # Parent e58a6d0b80e2cf8e3fb833a495df4603884132f1
>> Add documentation for branch_bookmark_suffix configuration parameter
>>
>> diff -r e58a6d0b80e2 -r ecacdd9a981b README.md
>> --- a/README.md Wed Feb 15 09:30:06 2012 +0800
>> +++ b/README.md Thu Feb 23 13:26:27 2012 -0500
>> @@ -149,3 +149,35 @@
>>
>> [git]
>> intree = True
>> +
>> +git.branch_bookmark_suffix
>> +---------------------------
>> +
>> +hg-git currently does not recognize Mercurial named branches;
>
> It doesn't convert git branches to hg named branches because they're different things, but it's inaccurate to say it's ignorant of hg named branches. They get recorded as metadata in the commit object when writing to git. Can you clean this sentence up to make it less confusing?
OK, how about:
hg-git does not convert between Mercurial named branches and git branches as the
two are conceptually different; instead, it uses Mercurial bookmarks to represent
the concept of a git branch. Therefore....
>
> On Feb 25, 2012, at 3:44 PM, Augie Fackler wrote:
>
>>
>> On Feb 23, 2012, at 12:56 PM, Mike Bayer wrote:
>>
>>> # HG changeset patch
>>> # User Mike Bayer <mik...@zzzcomputing.com>
>>> # Date 1330021587 18000
>>> # Node ID ecacdd9a981b5e9fd9442534bda7e1ad5e086e84
>>> # Parent e58a6d0b80e2cf8e3fb833a495df4603884132f1
>>> Add documentation for branch_bookmark_suffix configuration parameter
>>>
>>> diff -r e58a6d0b80e2 -r ecacdd9a981b README.md
>>> --- a/README.md Wed Feb 15 09:30:06 2012 +0800
>>> +++ b/README.md Thu Feb 23 13:26:27 2012 -0500
>>> @@ -149,3 +149,35 @@
>>>
>>> [git]
>>> intree = True
>>> +
>>> +git.branch_bookmark_suffix
>>> +---------------------------
>>> +
>>> +hg-git currently does not recognize Mercurial named branches;
>>
>> It doesn't convert git branches to hg named branches because they're different things, but it's inaccurate to say it's ignorant of hg named branches. They get recorded as metadata in the commit object when writing to git. Can you clean this sentence up to make it less confusing?
>
> OK, how about:
>
> hg-git does not convert between Mercurial named branches and git branches as the
> two are conceptually different; instead, it uses Mercurial bookmarks to represent
> the concept of a git branch. Therefore….
Great!