mercurial/util.py
changeset 7559 016a7319e76b
parent 7547 4949729ee9ee
parent 7553 71be8688f2db
child 7632 9626819b2e3d
--- a/mercurial/util.py	Wed Dec 31 17:59:58 2008 -0600
+++ b/mercurial/util.py	Wed Dec 31 18:00:35 2008 -0600
@@ -814,9 +814,15 @@
             return
         normpath = os.path.normcase(path)
         parts = splitpath(normpath)
-        if (os.path.splitdrive(path)[0] or parts[0] in ('.hg', '')
+        if (os.path.splitdrive(path)[0] or parts[0] in ('.hg', '.hg.', '')
             or os.pardir in parts):
             raise Abort(_("path contains illegal component: %s") % path)
+        if '.hg' in path:
+            for p in '.hg', '.hg.':
+                if p in parts[1:-1]:
+                    pos = parts.index(p)
+                    base = os.path.join(*parts[:pos])
+                    raise Abort(_('path %r is inside repo %r') % (path, base))
         def check(prefix):
             curpath = os.path.join(self.root, prefix)
             try: