From 11c8cc29c9b1962e90dec4536a0d27ef985eadf1 Mon Sep 17 00:00:00 2001 From: Mads Kiilerich Date: Wed, 29 Sep 2010 01:32:51 +0200 Subject: [PATCH] init: expand destination url as a configured paths Most commands expands configured paths when repositories are specified, just as the urls help says. Clone also expands the destination path. Clone is morally equivalent to init + push/pull, so init should also expand the destination path - and that is what this patch makes it do. There is no really good usecases for this and in most cases it doesn't matter, but consistency is nice, and otherwise we would have to document the exception. --- mercurial/commands.py | 2 +- tests/test-init.t | 34 +++++++++++++++++++++++++++++++--- 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/mercurial/commands.py b/mercurial/commands.py index 8b4f19b702..e1a6e1d32e 100644 --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -2378,7 +2378,7 @@ def init(ui, dest=".", **opts): Returns 0 on success. """ - hg.repository(hg.remoteui(ui, opts), dest, create=1) + hg.repository(hg.remoteui(ui, opts), ui.expandpath(dest), create=1) def locate(ui, repo, *pats, **opts): """locate files matching specific patterns diff --git a/tests/test-init.t b/tests/test-init.t index 689163eeb7..9483b21f0f 100644 --- a/tests/test-init.t +++ b/tests/test-init.t @@ -24,13 +24,13 @@ This test tries to exercise the ssh functionality with a dummy script $ checknewrepo() > { > name=$1 - > if [ -d $name/.hg/store ]; then + > if [ -d "$name"/.hg/store ]; then > echo store created > fi - > if [ -f $name/.hg/00changelog.i ]; then + > if [ -f "$name"/.hg/00changelog.i ]; then > echo 00changelog.i created > fi - > cat $name/.hg/requires + > cat "$name"/.hg/requires > } creating 'local' @@ -157,3 +157,31 @@ creating 'local/sub/repo' revlogv1 store fncache + +prepare test of init of url configured from paths + + $ echo '[paths]' >> $HGRCPATH + $ echo "somewhere = `pwd`/url from paths" >> $HGRCPATH + $ echo "elsewhere = `pwd`/another paths url" >> $HGRCPATH + +init should (for consistency with clone) expand the url + + $ hg init somewhere + $ checknewrepo "url from paths" + store created + 00changelog.i created + revlogv1 + store + fncache + +verify that clone also expand urls + + $ hg clone somewhere elsewhere + updating to branch default + 0 files updated, 0 files merged, 0 files removed, 0 files unresolved + $ checknewrepo "another paths url" + store created + 00changelog.i created + revlogv1 + store + fncache