Mercurial > hg-git
diff hggit/git_handler.py @ 987:be0d1413a06f
git_handler: detect and reject nested Mercurial repositories
The ReviewBoard repository contains a Mercurial repository within its
Git repository; if you just convert that into Mercurial, you can't
check it out. We handle this similar to invalid Git paths: by default,
refuse the conversion, but with a configuration knob to force it
through with a warning.
See also:
https://github.com/reviewboard/reviewboard/
https://reviewboard.org/bugs/3190
author | Dan Villiom Podlaski Christiansen <danchr@gmail.com> |
---|---|
date | Thu, 04 Feb 2016 13:33:32 +0100 |
parents | 296349f421c8 |
children | 05c8aa7d3edc |
line wrap: on
line diff
--- a/hggit/git_handler.py Mon Feb 01 16:57:18 2016 -0800 +++ b/hggit/git_handler.py Thu Feb 04 13:33:32 2016 +0100 @@ -1456,6 +1456,7 @@ gitlinks[oldfile] = None continue if newfile is not None: + self.audit_hg_path(newfile) # new = file files[newfile] = False, newmode, newsha if renames is not None and newfile != oldfile: @@ -1538,6 +1539,18 @@ if names: return names[0] + def audit_hg_path(self, path): + if '.hg' in path.split(os.path.sep): + if self.ui.configbool('git', 'blockdothg', True): + raise hgutil.Abort( + ('Refusing to import problematic path %r' % path), + hint=("Mercurial cannot check out paths inside nested " + + "repositories; if you need to continue, then set " + + "'[git] blockdothg = false' in your hgrc.")) + self.ui.warn(('warning: path %r is within a nested repository, ' + + 'which Mercurial cannot check out.\n') + % path) + # Stolen from hgsubversion def swap_out_encoding(self, new_encoding='UTF-8'): try: