[PATCH] convert: add config option to control saving Git committer in message
Gregory Szorc
gregory.szorc at gmail.com
Fri Jan 6 18:57:24 UTC 2017
# HG changeset patch
# User Gregory Szorc <gregory.szorc at gmail.com>
# Date 1483729033 28800
# Fri Jan 06 10:57:13 2017 -0800
# Node ID 1901566ab484a56b177b88ff080d635840e0912c
# Parent 3de9df6ee5bf7601aa3870f18304bbeb3ce351af
convert: add config option to control saving Git committer in message
As part of converting a Git repository to Mercurial at Mozilla, I
encountered a scenario where I didn't want `hg convert` to
automatically add the "committer: <committer>" line to commit messages.
While I can hack around it downstream by rewriting the Git commit
before feeding it into `hg convert`, I'd prefer to just specify a
config flag to turn it off. This patch adds that flag.
diff --git a/hgext/convert/__init__.py b/hgext/convert/__init__.py
--- a/hgext/convert/__init__.py
+++ b/hgext/convert/__init__.py
@@ -340,6 +340,11 @@ def convert(ui, src, dest=None, revmapfi
:convert.git.saverev: whether to store the original Git commit ID in the
metadata of the destination commit. The default is True.
+ :convert.git.savecommitterinmessage: whether to record the Git commit
+ "committer" in the commit message if it is different from the commit
+ "author." When enable, a ``committer: <committer>`` line is appended
+ to the commit message as necessary. The default is True.
+
:convert.git.skipsubmodules: does not convert root level .gitmodules files
or files with 160000 mode indicating a submodule. Default is False.
diff --git a/hgext/convert/git.py b/hgext/convert/git.py
--- a/hgext/convert/git.py
+++ b/hgext/convert/git.py
@@ -317,7 +317,10 @@ class convert_git(common.converter_sourc
if n in self.copyextrakeys:
extra[n] = v
- if committer and committer != author:
+ committerinmessage = self.ui.configbool('convert',
+ 'git.savecommitterinmessage',
+ True)
+ if committer and committer != author and committerinmessage:
message += "\ncommitter: %s\n" % committer
tzs, tzh, tzm = tz[-5:-4] + "1", tz[-4:-2], tz[-2:]
tz = -int(tzs) * (int(tzh) * 3600 + int(tzm))
diff --git a/tests/test-convert-git.t b/tests/test-convert-git.t
--- a/tests/test-convert-git.t
+++ b/tests/test-convert-git.t
@@ -482,6 +482,37 @@ convert author committer
+recording committer in commit message can be disabled
+
+ $ hg --config convert.git.savecommitterinmessage=false convert git-repo4 git-repo4-hg-no-committer
+ initializing destination git-repo4-hg-no-committer repository
+ scanning source...
+ sorting...
+ converting...
+ 1 addfoo
+ 0 addfoo2
+ updating bookmarks
+
+ $ hg -R git-repo4-hg-no-committer log -v
+ changeset: 1:190b2da396cc
+ bookmark: master
+ tag: tip
+ user: nottest <test at example.org>
+ date: Mon Jan 01 00:00:21 2007 +0000
+ files: foo
+ description:
+ addfoo2
+
+
+ changeset: 0:0735477b0224
+ user: test <test at example.org>
+ date: Mon Jan 01 00:00:20 2007 +0000
+ files: foo
+ description:
+ addfoo
+
+
+
--sourceorder should fail
$ hg convert --sourcesort git-repo4 git-repo4-sourcesort-hg
diff --git a/tests/test-convert.t b/tests/test-convert.t
--- a/tests/test-convert.t
+++ b/tests/test-convert.t
@@ -282,6 +282,11 @@
convert.git.saverev
whether to store the original Git commit ID in the metadata
of the destination commit. The default is True.
+ convert.git.savecommitterinmessage
+ whether to record the Git commit "committer" in the commit
+ message if it is different from the commit "author." When
+ enable, a "committer: <committer>" line is appended to the
+ commit message as necessary. The default is True.
convert.git.skipsubmodules
does not convert root level .gitmodules files or files with
160000 mode indicating a submodule. Default is False.
More information about the Mercurial-devel
mailing list