[PATCH STABLE] mq: fix init with nonexistent or non-local repository
Cédric Duval
cedricduval at free.fr
Sun Mar 14 13:30:44 CDT 2010
# HG changeset patch
# User Cédric Duval <cedricduval at free.fr>
# Date 1268588798 -3600
# Node ID 70dcaf340ab51b5cdc4ed4db94f143d78e9e4fe0
# Parent d4d3a8a65248fa65556a737d44f2465519afc95a
mq: fix init with nonexistent or non-local repository
diff --git a/hgext/mq.py b/hgext/mq.py
--- a/hgext/mq.py
+++ b/hgext/mq.py
@@ -2604,7 +2604,16 @@
if not mq:
return orig(ui, *args, **kwargs)
- repopath = cmdutil.findrepo(os.getcwd())
+ if args:
+ repopath = args[0]
+ if not hg.islocal(repopath):
+ raise util.Abort(_('only a local queue repository '
+ 'may be initialized'))
+ else:
+ repopath = cmdutil.findrepo(os.getcwd())
+ if not repopath:
+ raise util.Abort(_('There is no Mercurial repository here '
+ '(.hg not found)'))
repo = hg.repository(ui, repopath)
return qinit(ui, repo, True)
diff --git a/tests/test-mq b/tests/test-mq
--- a/tests/test-mq
+++ b/tests/test-mq
@@ -80,6 +80,19 @@
cat .hg/patches/series
cd ..
+echo '% init --mq without repo'
+mkdir f
+cd f
+hg init --mq
+cd ..
+
+echo '% init --mq with nonexistent directory'
+hg init --mq nonexistentdir
+
+echo '% init --mq with bundle (non "local")'
+hg -R a bundle --all a.bundle >/dev/null
+hg init --mq a.bundle
+
cd a
hg qnew -m 'foo bar' test.patch
diff --git a/tests/test-mq.out b/tests/test-mq.out
--- a/tests/test-mq.out
+++ b/tests/test-mq.out
@@ -90,6 +90,12 @@
series:
A
B
+% init --mq without repo
+abort: There is no Mercurial repository here (.hg not found)
+% init --mq with nonexistent directory
+abort: repository nonexistentdir not found!
+% init --mq with bundle (non "local")
+abort: only a local queue repository may be initialized
% qrefresh
foo bar
More information about the Mercurial-devel
mailing list