[PATCH 2 of 7] clone: allow local cloning to create more than one level of directories

Matt Harbison mharbison72 at gmail.com
Sat Aug 18 15:17:01 EDT 2018


# HG changeset patch
# User Matt Harbison <matt_harbison at yahoo.com>
# Date 1534567886 14400
#      Sat Aug 18 00:51:26 2018 -0400
# Node ID 01dd6d301bf9e43bad389d777413ed06b2a36f49
# Parent  8da858a0bfb4d37ef5f3d9a1717c92729555faff
clone: allow local cloning to create more than one level of directories

I figure cloning a remote repository is more common, thus it's more likely that
some people might be relying on the less restrictive behavior.  Additionally,
`hg init` will also create more than one level of missing directories.

I also have a use case for reading the subrepos from .hgsub, and sharing them
into the normal nested location on the server.  SCM Manager doesn't host
subrepos in the normal nested location, which is nice for deduplicating the
repository data, but confuses `hg verify`.  Some of the subrepos are in the root
of the repositories, while others are one or two directories deep.  So not
having to build up the parent path first is desirable.

diff --git a/mercurial/hg.py b/mercurial/hg.py
--- a/mercurial/hg.py
+++ b/mercurial/hg.py
@@ -634,7 +634,7 @@ def clone(ui, peeropts, source, dest=Non
             srcrepo.hook('preoutgoing', throw=True, source='clone')
             hgdir = os.path.realpath(os.path.join(dest, ".hg"))
             if not os.path.exists(dest):
-                os.mkdir(dest)
+                util.makedirs(dest)
             else:
                 # only clean up directories we create ourselves
                 cleandir = hgdir
diff --git a/tests/test-http.t b/tests/test-http.t
--- a/tests/test-http.t
+++ b/tests/test-http.t
@@ -494,9 +494,12 @@ disable pull-based clones
   new changesets 5fed3813f7f5:56f9bc90cce6
   (run 'hg update' to get a working copy)
 
-  $ hg clone test/partial/clone test/another/clone
-  abort: $ENOTDIR$: 'test/another/clone'
-  [255]
+  $ hg clone -U -r 0 test/partial/clone test/another/clone
+  adding changesets
+  adding manifests
+  adding file changes
+  added 1 changesets with 4 changes to 4 files
+  new changesets 8b6053c928fe
 
 corrupt cookies file should yield a warning
 


More information about the Mercurial-devel mailing list