[PATCH 1 of 2] hg: share supports subrepos (issue3518)

Simon Heimberg simohe at besonet.ch
Mon Nov 5 17:08:36 CST 2012


# HG changeset patch
# User simon at laptop-tosh
# Date 1351334339 -7200
# Branch stable
# Node ID 7425c0c92b2ee79e4e9271c3307d44290bc0977b
# Parent  fac6d36d04cb1838cd10bdcecd487567787fb853
hg: share supports subrepos (issue3518)

set the default path in any case because creating subrepo looks this up.
Subrepos are cloned, not shared.

diff -r fac6d36d04cb -r 7425c0c92b2e mercurial/hg.py
--- a/mercurial/hg.py	Don Nov 01 16:09:21 2012 -0500
+++ b/mercurial/hg.py	Sam Okt 27 12:38:59 2012 +0200
@@ -171,11 +171,14 @@
     r = repository(ui, root)
 
     default = srcrepo.ui.config('paths', 'default')
-    if default:
-        fp = r.opener("hgrc", "w", text=True)
-        fp.write("[paths]\n")
-        fp.write("default = %s\n" % default)
-        fp.close()
+    if not default:
+        # set default to source for being able to clone subrepos
+        default = os.path.abspath(util.urllocalpath(origsource))
+    fp = r.opener("hgrc", "w", text=True)
+    fp.write("[paths]\n")
+    fp.write("default = %s\n" % default)
+    fp.close()
+    r.ui.setconfig('paths', 'default', default)
 
     if update:
         r.ui.status(_("updating working directory\n"))
diff -r fac6d36d04cb -r 7425c0c92b2e tests/test-subrepo.t
--- a/tests/test-subrepo.t	Don Nov 01 16:09:21 2012 -0500
+++ b/tests/test-subrepo.t	Sam Okt 27 12:38:59 2012 +0200
@@ -718,6 +718,14 @@
   committing subrepository subrepo-2
   $ hg st subrepo-2/file
 
+Check that share works with subrepo
+  $ hg --config extensions.share= share . ../shared
+  updating working directory
+  cloning subrepo subrepo-2 from $TESTTMP/subrepo-status/subrepo-2
+  2 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ test -f ../shared/subrepo-1/.hg/sharedpath
+  [1]
+
 Check hg update --clean
   $ cd $TESTTMP/t
   $ rm -r t/t.orig


More information about the Mercurial-devel mailing list