M hgext3rd/confman/commands.py +13 -0
@@ 1,6 1,7 @@
"This module contains main command actions"
import os
import os.path as osp
+import shutil
import sys
from mercurial import error, registrar
@@ 448,6 449,18 @@ def updateconf(ui, repo, *args, **opts):
ui.write(' ... updated\n')
+@command('cfclear', DEFAULTOPTS)
+def clear(ui, repo, *args, **opts):
+ """Delete all managed directories"""
+ confman, repo = readconf(ui, repo, args, opts)
+ for section in confman.sections:
+ conf = confman.confs[section]
+ layout = conf.get("layout")
+ if layout is not None and os.path.exists(layout):
+ ui.write("Removing %s\n" % layout)
+ shutil.rmtree(layout)
+
+
# requirements.txt handling
A => tests/test-clear.t +110 -0
@@ 0,0 1,110 @@
+Prologue
+ $ cat >> $HGRCPATH << EOF
+ > [ui]
+ > logtemplate ="{node|short} ({phase}): {desc}\n"
+ > [diff]
+ > git = 1
+ > [alias]
+ > amend = amend -d '0 0'
+ > [extensions]
+ > hgext.convert=
+ > graphlog=
+ > EOF
+ $ echo "confman=$(echo $(dirname $TESTDIR))/hgext3rd/confman/" >> $HGRCPATH
+ $ mkcommit() {
+ > echo "$1" > "$1"
+ > hg add "$1"
+ > hg ci -m "add $1"
+ > }
+
+Prepare repos foo & quux
+ $ cd $TESTTMP
+ $ hg init foo
+ $ cd foo
+ $ mkcommit a-default-foo
+ $ hg branch stable
+ marked working directory as branch stable
+ (branches are permanent and global, did you want a bookmark?)
+ $ mkcommit b-stable-foo
+ $ hg log -G
+ @ 11aceb0f8346 (draft): add b-stable-foo
+ |
+ o 797f8866b5b9 (draft): add a-default-foo
+
+
+
+ $ cd ..
+ $ hg init quux
+ $ cd quux
+ $ mkcommit a-quux
+ $ hg tag quux-version-1.0
+ $ mkcommit b-quux
+ $ hg log -G
+ @ ab89ccefe7de (draft): add b-quux
+ |
+ o 54db6de36b30 (draft): Added tag quux-version-1.0 for changeset 260f39052d20
+ |
+ o 260f39052d20 (draft): add a-quux
+
+
+ $ cd ..
+
+Create working conf
+ $ cd $TESTTMP
+ $ hg init conf
+ $ cd conf
+ $ cat >> .hgconf << EOF
+ > [foo]
+ > pulluri = $TESTTMP/foo
+ > paths.default-push = ssh://perdu.com/hg/foo
+ > hgrc.paths.review = $TESTTMP/foo
+ > hgrc.paths.default-push = ssh://perdu.com/hg/foo
+ > hgrc.foo.bar = quux # random stuff to populate target hgrc
+ > layout = foo
+ > track = stable
+ > [bar.quux]
+ > pulluri = $TESTTMP/quux
+ > layout = bar/quux
+ > track = quux-version-1.0
+ > EOF
+
+Run cfclear
+ $ hg cfclear
+ $ [ -e foo ]; echo $?
+ 1
+ $ [ -e bar/quux ]; echo $?
+ 1
+
+
+First cfensureconf
+ $ hg cfensureconf
+ cloning foo from $TESTTMP/foo to $TESTTMP/conf/foo
+ updating to branch default
+ 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+ cloning bar.quux from $TESTTMP/quux to $TESTTMP/conf/bar/quux
+ updating to branch default
+ 3 files updated, 0 files merged, 0 files removed, 0 files unresolved
+ foo
+ foo repo has no `default` path, using configuration pulluri `$TESTTMP/foo` instead
+ searching for changes
+ no changes found
+ updating to stable
+ 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+ updated to 11aceb0f834624f90c1cac5cecc9b09fd28df45f/stable from 797f8866b5b935983bc197b3a18d3b3c71c0643a/default
+ bar.quux
+ updating to quux-version-1.0
+ 0 files updated, 0 files merged, 2 files removed, 0 files unresolved
+ updated to quux-version-1.0/default from ab89ccefe7de105293a3e40e95d77ee15547f8e2/default
+
+Run cfclear
+ $ [ -e foo ]; echo $?
+ 0
+ $ [ -e bar/quux ]; echo $?
+ 0
+ $ hg cfclear
+ Removing foo
+ Removing bar/quux
+ $ [ -e foo ]; echo $?
+ 1
+ $ [ -e bar/quux ]; echo $?
+ 1