`git.authors` config setting is not always used
I tried to convert my mercurial repo to git and I want to change my name (Mingun
) that set in mercurial commits to my git name (Mingun <my@e.mail>
). To to that I've created the git-authors.txt
file in the root of my mercurial repo:
Mingun = Mingun <my@e.mail>
Then I edited <repo>/.hg/hgrc
file:
[paths]
default = https://bitbucket.org/Mingun/peg-grammars
[git]
authors = git-authors.txt
Then I run the following commands:
$ cd <repo>
<repo> $ hg bookmarks hg
<repo> $ git init --bare ../grammars-bare-git
Initialized empty Git repository in D:/Projects/grammars-bare-git/
<repo> $ hg push --verbose ../grammars-bare-git
pushing to ../grammars-bare-git
use authors mapping file D:\Projects\grammars-hg/git-authors.txt # My addition
author mapping: "Mingun" -> "Mingun <my@e.mail>" # My addition
finding unexported changesets
total: 0 # My addition
searching for changes
remote: counting objects: 2153, done.
539 commits found
adding objects
remote: counting objects: 2153, done.
remote: found 0 deltas to reuse
added 539 commits with 820 trees and 794 blobs
adding reference ::refs/heads/hg => GIT:ef274397
adding reference ::refs/tags/ParserSupportImport => GIT:b03e4e1e
<repo> $ git clone -b hg ../grammars-bare-git ../grammars-git
After checking the commit info in git I noted that author is set to Mingun <none@none>
. I've debug a bit and found that export_hg_commit
which does the mapping is not called in my case because total
variable is 0
. In the log above you can see my debug output which is added by this patch:
diff -r cf50e7bed8a1 hggit/git_handler.py
--- a/hggit/git_handler.py Sat Jan 13 10:59:28 2024 +0100
+++ b/hggit/git_handler.py Sun Feb 25 00:16:40 2024 +0500
@@ -273,13 +273,18 @@
self.author_map = {}
authors_path = self.ui.config(b'git', b'authors')
if authors_path:
- with open(self.repo.wvfs.join(authors_path), 'rb') as f:
+ path = self.repo.wvfs.join(authors_path)
+ with open(path, 'rb') as f:
+ self.ui.note(_(b'use authors mapping file %s\n') % path)
for line in f:
line = line.strip()
if not line or line.startswith(b'#'):
continue
from_, to = RE_AUTHOR_FILE.split(line, 2)
+ self.ui.note(_(b'author mapping: "%s" -> "%s"\n') % (from_, to))
self.author_map[from_] = to
+ else:
+ self.ui.note(_(b'authors mapping file is not specified\n'))
# FILE LOAD AND SAVE METHODS
@@ -671,6 +676,7 @@
export.append(ctx)
total = len(export)
+ self.ui.note(_(b' total: %d\n') % total)
if not total:
return
@@ -729,6 +735,7 @@
commit.author_time = int(time)
commit.author_timezone = -timezone
+ self.ui.note(_(b" git author will be: %s\n") % commit.author)
if b'committer' in extra:
try:
# fixup timezone