Mercurial > hg > hg-git
changeset 836:6c9c40d9e9c1
git2hg: while extracting metadata, detect which VCS commits were made in
This is currently a heuristic -- it'll be made more reliable in upcoming
patches.
author | Siddharth Agarwal <sid0@fb.com> |
---|---|
date | Mon, 01 Dec 2014 20:16:24 -0800 (2014-12-02) |
parents | 5a75bcc9da24 |
children | c24d2ea1361b |
files | hggit/git2hg.py hggit/git_handler.py |
diffstat | 2 files changed, 17 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/hggit/git2hg.py +++ b/hggit/git2hg.py @@ -81,10 +81,21 @@ def extract_hg_metadata(message, git_extra): split = message.split("\n--HG--\n", 1) - renames = {} + # Renames are explicitly stored in Mercurial but inferred in Git. For + # commits that originated in Git we'd like to optionally infer rename + # information to store in Mercurial, but for commits that originated in + # Mercurial we'd like to disable this. How do we tell whether the commit + # originated in Mercurial or in Git? We don't have any firm indicators so we + # use a simple heuristic to determine that: if the commit has any extra hg + # fields, it definitely originated in Mercurial and we set renames to a + # dict. If the commit doesn't, we aren't really sure and we make sure + # renames is set to None. Callers can then determine whether to infer rename + # information. + renames = None extra = {} branch = None if len(split) == 2: + renames = {} message, meta = split lines = meta.split("\n") for line in lines: @@ -107,6 +118,8 @@ git_fn = 0 for field, data in git_extra: if field.startswith('HG:'): + if renames is None: + renames = {} command = field[3:] if command == 'rename': before, after = data.split(':', 1)
--- a/hggit/git_handler.py +++ b/hggit/git_handler.py @@ -686,6 +686,9 @@ (strip_message, hg_renames, hg_branch, extra) = git2hg.extract_hg_metadata( commit.message, commit.extra) + if hg_renames is None: + # don't do any rename detection for now + hg_renames = {} gparents = map(self.map_hg_get, commit.parents)