From 8d135fe700ffd6e11bdade8b84d3b601fc23bf87 Mon Sep 17 00:00:00 2001 From: chrisjbillington Date: Fri, 7 Feb 2020 17:50:59 -0500 Subject: [PATCH] Ignore files and directories called .git Git cannot track these files. Print a warning if encountering one. Fixes #166 --- README.md | 5 +++++ hg-fast-export.py | 3 +++ 2 files changed, 8 insertions(+) diff --git a/README.md b/README.md index 8b0e6bb..26c5c62 100644 --- a/README.md +++ b/README.md @@ -196,6 +196,11 @@ hg-fast-export supports multiple branches but only named branches with exactly one head each. Otherwise commits to the tip of these heads within the branch will get flattened into merge commits. +hg-fast-export will ignore any files or directories tracked by mercurial +called `.git`, and will print a warning if it encounters one. Git cannot +track such files or directories. This is not to be confused with submodules, +which are described in README-SUBMODULES.md. + As each git-fast-import run creates a new pack file, it may be required to repack the repository quite often for incremental imports (especially when importing a small number of changesets per diff --git a/hg-fast-export.py b/hg-fast-export.py index f176239..b0a14a2 100755 --- a/hg-fast-export.py +++ b/hg-fast-export.py @@ -204,6 +204,9 @@ def export_file_contents(ctx,manifest,files,hgtags,encoding='',plugins={}): filename=file.decode(encoding).encode('utf8') else: filename=file + if '.git' in filename.split(os.path.sep): + sys.stderr.write('Ignoring file %s which cannot be tracked by git\n' % filename) + continue file_ctx=ctx.filectx(file) d=file_ctx.data()