summaryrefslogtreecommitdiff
path: root/lorry
diff options
context:
space:
mode:
authorBen Hutchings <ben.hutchings@codethink.co.uk>2020-09-29 17:37:27 +0100
committerBen Hutchings <ben.hutchings@codethink.co.uk>2020-10-01 14:22:30 +0100
commit9b3e1939465593b72957b882765623ae416d7796 (patch)
tree5664b912674f6d8d6fb200375a91fcccb212d626 /lorry
parent641ebd75f9868753ba472e780062a7f2aed5abbb (diff)
downloadlorry-9b3e1939465593b72957b882765623ae416d7796.tar.gz
lorry: Install and use fudge_user_ids plugin for hg-fast-export
Mercurial allows arbitrary strings as user (committer) ids, while Git requires a name and email address, and specific punctuation around the address. hg-fast-export has some provision for automatically fixing-up invalid committer and author ids, but it doesn't catch everything. Its maintainer does not want to extend this, so we use a plugin instead. * Add a plugin (fudge_user_ids) that should fix up all invalid ids. * In setup.py: - Compile it at build time - Install it under a private data directory (/usr/share/lorry) - Clean up the bytecode * In gitify_hg, check whether hg-fast-export supports plugins, and where our plugins are. If this succeeds, add --plugin-path and --plugin options to enable fudge_user_ids. Closes #11.
Diffstat (limited to 'lorry')
-rwxr-xr-xlorry24
1 files changed, 23 insertions, 1 deletions
diff --git a/lorry b/lorry
index 81fdeb3..0e047db 100755
--- a/lorry
+++ b/lorry
@@ -766,8 +766,30 @@ class Lorry(cliapp.Application):
self.prune_unreachable_marks(gitdir,
os.path.join(gitdir, 'hg2git-marks'))
+ # Enable the fudge_user_ids plugin if possible
+ plugin_options = []
+ exit, out, _ = self.runcmd_unchecked(['hg-fast-export', '--help'])
+ if exit == 0 and b'--plugin' in out:
+ for plugin_path in [
+ # Check under same directory as us, in case we are
+ # not yet installed
+ os.path.join(os.path.dirname(__file__),
+ 'hg-fast-export/plugins'),
+ # Try walking from <prefix>/bin/lorry to
+ # <prefix>/share/lorry/...
+ os.path.join(os.path.dirname(__file__),
+ '../share/lorry/hg-fast-export/plugins')
+ ]:
+ if os.path.exists(plugin_path):
+ plugin_options += [
+ '--plugin-path', plugin_path,
+ '--plugin', 'fudge_user_ids'
+ ]
+ break
+
self.progress('.. fast-exporting into git')
- self.run_program(['hg-fast-export', '-r', '../hg', '--quiet', '--force'],
+ self.run_program(['hg-fast-export', '-r', '../hg', '--quiet', '--force',
+ *plugin_options],
cwd=gitdir)
def gitify_archive(self, archive_type, project_name, dirname, gitdir, spec):