[Monotone-devel] [PATCH] mtn mkdir quickie (revised)

2006-12-12 Thread Ben Walton

Hi All,

I've redone the diff for the mtn mkdir patch.  No more po/*po changes
included.  I also trimmed all of the unit tests into a single
tests/mkdir/__driver__.lua.  This is reflected in the testsuite.lua
changes now too.

I hope this is nicer to work with.

Thanks
-Ben
--
---
Ben Walton [EMAIL PROTECTED]

Unanswered questions are far less dangerous than unquestioned answers.
- The Roadside Pulpit
---


mtn_mkdir.patch
Description: Binary data
___
Monotone-devel mailing list
Monotone-devel@nongnu.org
http://lists.nongnu.org/mailman/listinfo/monotone-devel


[Monotone-devel] [PATCH] mtn mkdir quickie (revised 2)

2006-12-12 Thread Ben Walton

Ok, it's one of those days.

The previously revised patch did not include the tests.  This should be better.

Thanks and sorry.
-Ben
--
---
Ben Walton [EMAIL PROTECTED]

Unanswered questions are far less dangerous than unquestioned answers.
- The Roadside Pulpit
---
# 
# old_revision [42c37d8a46e9fa3cc7e5feff21637ca9279c1fdb]
# 
# add_dir tests/mkdir
# 
# add_file tests/mkdir/__driver__.lua
#  content [33e48a4f90a4fc32c8031389366479e634619fe1]
# 
# add_file tests/mkdir/ignore_hook.lua
#  content [b5e9120785416fb3a3b1f7e464a23cc8ef45e2e9]
# 
# patch ChangeLog
#  from [c1ee9064be33f06d3e4552f554c2f88785d72235]
#to [d1823d3069436beb0ce982f3a07761576a0f906d]
# 
# patch cmd_ws_commit.cc
#  from [c261cde4b2eb928ff75f57fab634f1d987443287]
#to [86f5fe60fefe154c4d6ec7e1b615c1e360aec0b5]
# 
# patch monotone.texi
#  from [414a511aca4ab92d13eb98af0662f95ef8d4adec]
#to [69c65c0f117e8df6c1544b8f2bd8e2ff8d0d6008]
# 
# patch testsuite.lua
#  from [2188f4ffa8cfc4a560da9af28c071820f1a889ca]
#to [1c3a7065f83c690beaeaec859b201fb3033cd1a6]
# 

--- tests/mkdir/__driver__.lua	33e48a4f90a4fc32c8031389366479e634619fe1
+++ tests/mkdir/__driver__.lua	33e48a4f90a4fc32c8031389366479e634619fe1
@@ -0,0 +1,55 @@
+
+skip_if(not existsonpath(test))
+mtn_setup()
+
+check(get(ignore_hook.lua))
+
+--no args
+check(mtn(mkdir), 2, false, false)
+
+--base functionality
+check(mtn(mkdir, testing), 0, false, false)
+check({test, -d, testing})
+
+--error if already exists
+check(mtn(mkdir, testing), 1, false, false)
+
+--nested
+check(mtn(mkdir, testing2/nested), 0, false, false)
+check ({test, -d, testing2/nested})
+
+--nested, parent exists
+check(mtn(mkdir, testing/nested), 0, false, false)
+check ({test, -d, testing/nested})
+
+--multiple
+check(mtn(mkdir, test1, test2), 0, false, false)
+check({test, -d, test1})
+check({test, -d, test2})
+
+--multiple, nested
+check(mtn(mkdir, testing1/test1, testing2/test2), 0, false, false)
+check({test, -d, testing1/test1})
+check({test, -d, testing2/test2})
+
+--multiple, nested, same parent
+check(mtn(mkdir, testing3/test1, testing3/test2), 0, false, false)
+check({test, -d, testing3/test1})
+check({test, -d, testing3/test2})
+
+--multiple w/some pre-existing
+check(mtn(mkdir, test1, test3), 1, false, false)
+check({test, -d, test3}, 1, false, false)
+
+--ignore feature
+check(mtn(--rcfile=ignore_hook.lua, mkdir, testing4), 1, false, false)
+check({test, -d, testing4}, 1, false, false)
+
+--multiple with some ignored (all should fail, workspace should be unchanged)
+check(mtn(--rcfile=ignore_hook.lua, mkdir, testing4, testing5), 1, false, false)
+check({test, -d, testing4}, 1, false, false)
+check({test, -d, testing5}, 1, false, false)
+
+--not respecting ignore
+check(mtn(--no-respect-ignore, --rcfile=ignore_hook.lua, mkdir, testing4), 0, false, false)
+check({test, -d, testing4})

--- tests/mkdir/ignore_hook.lua	b5e9120785416fb3a3b1f7e464a23cc8ef45e2e9
+++ tests/mkdir/ignore_hook.lua	b5e9120785416fb3a3b1f7e464a23cc8ef45e2e9
@@ -0,0 +1,4 @@
+function ignore_file(name)
+if (string.find(name, testing4)) then return true end
+return false
+end

--- ChangeLog	c1ee9064be33f06d3e4552f554c2f88785d72235
+++ ChangeLog	d1823d3069436beb0ce982f3a07761576a0f906d
@@ -1,3 +1,10 @@
+2006-12-08  Ben Walton  [EMAIL PROTECTED]
+
+	* cmd_ws_cc: Added mtn mkdir
+	* testsuite.lua: added mtn mkdir test
+	* included tests/mkdir as unit testing for mtn mkdir
+	* added documentation to monotone.texi
+
 2006-12-09  Richard Levitte  [EMAIL PROTECTED]
 
 	* tests/netsync_permissions_wildcards/__driver__.lua:

--- cmd_ws_commit.cc	c261cde4b2eb928ff75f57fab634f1d987443287
+++ cmd_ws_commit.cc	86f5fe60fefe154c4d6ec7e1b615c1e360aec0b5
@@ -248,7 +248,50 @@ CMD(disapprove, N_(review), N_(REVISI
   }
 }
 
+CMD(mkdir, N_(workspace), N_([DIRECTORY...]),
+N_(create one or more directories and add them to the workspace),
+options::opts::no_ignore)
+{
+  if (args.size()  1)
+throw usage(name);
 
+  app.require_workspace();
+
+  path_set paths;
+  //spin through args and try to ensure that we won't have any collisions
+  //before doing any real filesystem modification.  we'll also verify paths
+  //against .mtn-ignore here.
+  for (vectorutf8::const_iterator i = args.begin();
+   i != args.end(); ++i)
+{
+  split_path sp;
+  file_path_external(*i).split(sp);
+  file_path fp(sp);
+
+  require_path_is_nonexistent
+(fp, F(directory '%s' already exists) % fp);
+
+  //we'll treat this as a user (fatal) error.  it