monotone-commits-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Monotone-commits-diffs] net.venge.monotone: 01dce6f01b4958850742305ceb


From: code
Subject: [Monotone-commits-diffs] net.venge.monotone: 01dce6f01b4958850742305cebf0937bf57d0d97
Date: Sun, 9 Jan 2011 00:46:09 GMT

revision:            01dce6f01b4958850742305cebf0937bf57d0d97
date:                2011-01-09T00:43:19
author:              address@hidden
branch:              net.venge.monotone
changelog:
* cmd_netsync.cc (remote, remote_stdio): set dbname_given when
  defaulting to a :memory: database
* work.cc (set_options): only read the current options and
  look out for an old database path if there is actually an
  options file
* database.cc (get_database_path): fail clearly if app.opts
  do not contain enough information for a valid internal
  database path (fixes issue 113)
* NEWS: note the bugfix

manifest:
format_version "1"

new_manifest [73a23f950fe13501aaf3e8fb4d28379a94d86e27]

old_revision [8f3745bb58c478bd24f2204bfb1f8bb08e6b9214]

add_dir "tests/db_opt_fallback_mechanisms"

add_file "tests/db_opt_fallback_mechanisms/__driver__.lua"
 content [09354a970b921effa2850aa4ad722ce95a433ea8]

patch "NEWS"
 from [1e1359c5cd7ef37431ad77f27d952639754d2b8c]
   to [a7b73d969faeb5f94a7c8ac287a6dfcee10f08db]

patch "cmd_netsync.cc"
 from [c5dcaa406cddacc083e28d68e5746ed4ad39ce25]
   to [732e7c4f6adb6bc8bd96964ab147e53e700053c1]

patch "database.cc"
 from [7bade10adebd690f76d1fb9014b0a5672b5133a5]
   to [c4d5eb755d893255d1be35276e2b12ccbea8372c]

patch "work.cc"
 from [6daa957e96a3248b2415519cab25aa4123bd809a]
   to [304b3f0ad0624464b9b16b23d0dcb78b4a8effb2]
============================================================
--- NEWS	1e1359c5cd7ef37431ad77f27d952639754d2b8c
+++ NEWS	a7b73d969faeb5f94a7c8ac287a6dfcee10f08db
@@ -52,6 +52,13 @@ XXX XXX XX XX:XX:XX UTC 2010
           name of the removed file instead.
           (fixes monotone issue 111)
 
+        - monotone no longer wrongly falls back on a :memory: database
+          when no database option is given. It also prints out an
+          informational message for commands like 'setup' and 'clone'
+          that fall back on the configured default database, again,
+          if no database is specified for these commands.
+          (fixes monotone issue 113)
+
         - mtn pull and mtn sync would always say that your workspace
           has not been updated.  Now, it only does that when you used
           the --update option and there were no updates.
============================================================
--- database.cc	7bade10adebd690f76d1fb9014b0a5672b5133a5
+++ database.cc	c4d5eb755d893255d1be35276e2b12ccbea8372c
@@ -4927,10 +4927,10 @@ database_path_helper::get_database_path(
 {
   if (!opts.dbname_given ||
       (opts.dbname.as_internal().empty() &&
-       opts.dbname_alias.empty()))
+       opts.dbname_alias.empty() &&
+       opts.dbname_type != memory_db))
     {
-      L(FL("no database option given or options empty"));
-      return;
+      E(false, origin::user, F("no database specified"));
     }
 
   if (opts.dbname_type == unmanaged_db)
============================================================
--- work.cc	6daa957e96a3248b2415519cab25aa4123bd809a
+++ work.cc	304b3f0ad0624464b9b16b23d0dcb78b4a8effb2
@@ -587,10 +587,10 @@ workspace::get_options(options & opts)
       // one would expect that we should set the key_dir_given flag here, but
       // we do not because of the interaction between --confdir and --keydir.
       // If --keydir is not given and --confdir is, then --keydir will default
-      // to the "keys" subdirectory of the given confdir. This works by the 
-      // --confdir option body looking at key_dir_given; if reading the keydir 
-      // from _MTN/options set that, then --confdir would stop setting the 
-      // default keydir when in a workspace. 
+      // to the "keys" subdirectory of the given confdir. This works by the
+      // --confdir option body looking at key_dir_given; if reading the keydir
+      // from _MTN/options set that, then --confdir would stop setting the
+      // default keydir when in a workspace.
       //opts.key_dir_given = true;
     }
 
@@ -635,20 +635,21 @@ workspace::set_options(options const & o
   bookkeeping_path o_path;
   get_options_path(o_path);
 
+  database_path_helper helper(lua);
+  system_path old_db_path, new_db_path;
+
+  helper.get_database_path(opts, new_db_path);
+
   // If any of the incoming options was empty, we want to leave that option
   // as is in _MTN/options, not write out an empty option.
   options cur_opts;
   if (file_exists(o_path))
+  {
     read_options_file(o_path, cur_opts);
+    helper.get_database_path(cur_opts, old_db_path);
+  }
 
   bool options_changed = false;
-
-  database_path_helper helper(lua);
-  system_path old_db_path, new_db_path;
-
-  helper.get_database_path(cur_opts, old_db_path);
-  helper.get_database_path(opts, new_db_path);
-
   if (old_db_path != new_db_path && file_exists(new_db_path))
     {
       // remove the currently registered workspace from the old
============================================================
--- cmd_netsync.cc	c5dcaa406cddacc083e28d68e5746ed4ad39ce25
+++ cmd_netsync.cc	732e7c4f6adb6bc8bd96964ab147e53e700053c1
@@ -123,6 +123,7 @@ CMD_AUTOMATE_NO_STDIO(remote_stdio,
           "verify the server key, because we have no record of what it should be.")
           % memory_db_identifier);
       app.opts.dbname_type = memory_db;
+      app.opts.dbname_given = true;
     }
 
   database db(app);
@@ -224,6 +225,7 @@ CMD_AUTOMATE_NO_STDIO(remote,
           "verify the server key, because we have no record of what it should be.")
           % memory_db_identifier);
       app.opts.dbname_type = memory_db;
+      app.opts.dbname_given = true;
     }
 
   database db(app);
============================================================
--- /dev/null	
+++ tests/db_opt_fallback_mechanisms/__driver__.lua	09354a970b921effa2850aa4ad722ce95a433ea8
@@ -0,0 +1,17 @@
+-- commands that use a specific database must fail early and clearly
+check(raw_mtn("ls", "branches"), 1, false, true)
+check(qgrep("no database specified", "stderr"))
+
+-- some commands (setup and clone specifically) might use a default
+-- database and even create it beforehand
+check(raw_mtn("setup", "-b", "foo", "."), 0, false, true)
+check(qgrep("using default database ':default.mtn'", "stderr"))
+check(remove("_MTN"))
+check(remove("databases"))
+
+skip_if(no_network_tests)
+
+-- and some commands should use :memory: as default because they
+-- just need a temporary throw-away database to work properly
+check(raw_mtn("au", "remote", "interface_version", "--remote-stdio-host", "http://code.monotone.ca/monotone", "--key="), 0, false, true)
+check(qgrep("No database given; assuming ':memory:' database", "stderr"))

reply via email to

[Prev in Thread] Current Thread [Next in Thread]