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.issue-76: 923c2015f49aa88f1


From: code
Subject: [Monotone-commits-diffs] net.venge.monotone.issue-76: 923c2015f49aa88f1533360cce4525e1dff7baf6
Date: Sun, 27 Mar 2011 13:10:18 +0200 (CEST)

revision:            923c2015f49aa88f1533360cce4525e1dff7baf6
date:                2011-03-26T14:27:17
author:              Richard Hopkins <address@hidden>
branch:              net.venge.monotone.issue-76
changelog:
Revert can now be used in a multi-parent workspace

cmd_ws_commit.cc (revert): A revision can now be specified manually and it
will be used to calculate old_roster - if it's a valid parent of the
workspace.

func/two_parent_workspace_commands_that_fail/__driver__.lua: Updated
expected message when reverting in a multi-parent workspace without
specifying the revision.

All tests now pass.

TODO: Need to add some more tests for revert such as passing in a
non-parent revision id, and checking the file reverted file contents 
are the correct ones.

manifest:
format_version "1"

new_manifest [a3f57c91572bdfea4fd455433ca12703399d2542]

old_revision [b2729ea31820bf3bca56abb985e92f7009e4d4d2]

patch "src/cmd_ws_commit.cc"
 from [d9dbacb820c6d070c4952ee2b0f143e61e85631e]
   to [65a28aabb2177fa9ca7d8029196005c07091f57a]

patch "test/func/two_parent_workspace_commands_that_fail/__driver__.lua"
 from [268519096042c3dce7328da87198918d3d5a55b8]
   to [11722f00bcdd5d2c2936972da66f0365afc7c889]
============================================================
--- src/cmd_ws_commit.cc	d9dbacb820c6d070c4952ee2b0f143e61e85631e
+++ src/cmd_ws_commit.cc	65a28aabb2177fa9ca7d8029196005c07091f57a
@@ -363,13 +363,48 @@ revert(app_state & app,
 
   database db(app);
   workspace work(app);
+  project_t project(db);
 
   parent_map parents;
   work.get_parent_rosters(db, parents);
-  E(parents.size() == 1, origin::user,
-    F("this command can only be used in a single-parent workspace"));
-  old_roster = parent_roster(parents.begin());
 
+  if (parents.size() == 1)
+    {
+      // TODO: Should we error out here, or just check if they have passed
+      // a revision id through that it's actually the parent of the
+      // workspace.
+      E(app.opts.revision.empty(), origin::user,
+        F("this workspace only has 1 parent"));
+
+      old_roster = parent_roster(parents.begin());
+    }
+  else
+    {
+      E(app.opts.revision.size() == 1, origin::user,
+        F("this workspace has multiple parents. specify which parent to "
+          "use with -r"));
+
+      revision_id wanted_parent_id;
+      complete(app.opts, app.lua, project, idx(app.opts.revision, 0)(),
+               wanted_parent_id);
+
+      bool found_wanted_parent = false;
+      for (parent_map::const_iterator i = parents.begin();
+           i != parents.end(); i++)
+        {
+          if (i->first == wanted_parent_id)
+            {
+              found_wanted_parent = true;
+              old_roster = parent_roster(i);
+              break;
+            }
+        }
+
+      E(found_wanted_parent, origin::user,
+        F("the specified revision is not a parent of the current "
+          "workspace"));
+    }
+
   {
     temp_node_id_source nis;
     work.get_current_roster_shape(db, nis, new_roster);
@@ -539,7 +574,8 @@ CMD(revert, "revert", "", CMD_REF(worksp
     N_("Reverts files and/or directories"),
     N_("In order to revert the entire workspace, specify '.' as the "
        "file name."),
-    options::opts::depth | options::opts::exclude | options::opts::missing)
+    options::opts::depth | options::opts::exclude | options::opts::missing
+    | options::opts::revision)
 {
   revert(app, args, false);
 }
============================================================
--- test/func/two_parent_workspace_commands_that_fail/__driver__.lua	268519096042c3dce7328da87198918d3d5a55b8
+++ test/func/two_parent_workspace_commands_that_fail/__driver__.lua	11722f00bcdd5d2c2936972da66f0365afc7c889
@@ -26,6 +26,7 @@ diag = "mtn: misuse: this command can on
 check(not qgrep("ancestor", "testfile"))
 
 diag = "mtn: misuse: this command can only be used in a single-parent workspace\n"
+revertdiag = "mtn: misuse: this workspace has multiple parents. specify which parent to use with -r\n"
 diffdiag = ("mtn: misuse: this workspace has more than one parent\n"..
         "mtn: misuse: (specify a revision to diff against with '--revision')\n")
 
@@ -52,7 +53,7 @@ check(mtn("revert", "."), 1, nil, true)
 
 -- revert and update: to where?
 check(mtn("revert", "."), 1, nil, true)
-check(grep("-v", "detected at", "stderr"), 0, diag)
+check(grep("-v", "detected at", "stderr"), 0, revertdiag)
 check(mtn("update"), 1, nil, true)
 check(grep("-v", "detected at", "stderr"), 0, diag)
 

reply via email to

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