monotone-devel
[Top][All Lists]
Advanced

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

[Monotone-devel] [PATCH] read-only commands and working copy default bra


From: Florian Weimer
Subject: [Monotone-devel] [PATCH] read-only commands and working copy default branch
Date: Tue, 12 Apr 2005 16:58:04 +0200

Hi,

the patch below prevents commands such as "monotone log" from updating
the wokring copy default branch, which is *very* confusing.

Please pull it from monotone.enyo.de, branch net.venge.monotone,
revision 027ce5e626ccdd28cc8b0b4fa115ee96cc277270.

Florian

2005-04-12  Florian Weimer  <address@hidden>

        * app_state.cc (app_state::allow_working_copy): Only update
        branch_name from the options file if it has not yet been set.  Log
        the branch name.
        (app_state::set_branch): No longer update the options map.
        (app_state::make_branch_sticky): New function which copies the
        stored branch name to the options map.  Only commands which call
        this function change the branch default stored in the working
        copy.

        * commands.cc (CMD(checkout)): Mark branch argument as sticky.
        (CMD(commit)): Likewise.
        (CMD(update)): Likewise.

        * monotone.texi (Working Copy): Mention that the "commit" and
        "update" commands update the stored default branch ("checkout"
        does, too, but this one should be obvious).

# patch "app_state.cc"
#  from [d7d6fbd90b19c513269bb0a1b89feab31c681880]
#    to [45146c95ac44cf51ab3474d7989afd2906f63607]
# 
# patch "app_state.hh"
#  from [be65ffeb33feacce57408e9c43da259bb8583b15]
#    to [9cfdb7a5976dc31edda11e99ee74046fdc318469]
# 
# patch "commands.cc"
#  from [f63e583a3a26df78f0877afd653e1d5244f5c611]
#    to [4e990b0c151610b84978e2571cd9ab8a4f577c7c]
# 
# patch "monotone.texi"
#  from [b38091c6e7e77fe127975e3c5a98dd0e14290798]
#    to [13bed7469b4e155326caade82d7328129accdbec]
# 
--- app_state.cc
+++ app_state.cc
@@ -60,7 +60,9 @@
 
       string dbname = absolutify(options[database_option]());
       if (dbname != "") db.set_filename(mkpath(dbname));
-      branch_name = options[branch_option];
+      if (branch_name().empty())
+        branch_name = options[branch_option];
+      L(F("branch name is '%s'\n") % branch_name());
       internalize_rsa_keypair_id(options[key_option], signing_key);
 
       if (!current.empty()) 
@@ -234,8 +236,12 @@
 app_state::set_branch(utf8 const & branch)
 {
   branch_name = branch();
+}
 
-  options[branch_option] = branch;
+void
+app_state::make_branch_sticky()
+{
+  options[branch_option] = branch_name();
 }
 
 void 
--- app_state.hh
+++ app_state.hh
@@ -49,7 +49,15 @@
   void set_restriction(path_set const & valid_paths, std::vector<utf8> const & 
paths);
   bool restriction_includes(file_path const & path);
 
+  // Set the branch name.  If you only invoke set_branch, the branch
+  // name is not sticky (and won't be written to the working copy and
+  // reused by subsequent monotone invocations).  Commands which
+  // switch the working to a different branch should invoke
+  // make_branch_sticky (before require_working_copy because this
+  // function updates the working copy).
   void set_branch(utf8 const & name);
+  void make_branch_sticky();
+
   void set_database(utf8 const & filename);
   void set_signing_key(utf8 const & key);
   void set_root(utf8 const & root);
--- commands.cc
+++ commands.cc
@@ -1777,6 +1777,7 @@
   if (args.size() == 0 || args.size() == 1)
     {
       N(app.branch_name() != "", F("need --branch argument for branch-based 
checkout"));
+      app.make_branch_sticky();
 
       // if no checkout dir specified, use branch name
       if (args.size() == 0)
@@ -1799,6 +1800,7 @@
 
       if (!app.branch_name().empty()) 
         {
+          app.make_branch_sticky();
           cert_value branch_name(app.branch_name());
           base64<cert_value> branch_encoded;
           encode_base64(branch_name, branch_encoded);
@@ -2549,6 +2551,7 @@
   revision_id rid;
   manifest_map m_old, m_new;
   
+  app.make_branch_sticky();
   app.require_working_copy();
 
   // preserve excluded work for future commmits
@@ -3112,6 +3115,8 @@
   if (args.size() != 0 && args.size() != 1)
     throw usage(name);
 
+  if (!app.branch_name().empty())
+    app.make_branch_sticky();
   app.require_working_copy();
 
   calculate_current_revision(app, r_working, m_old, m_working);
--- monotone.texi
+++ monotone.texi
@@ -3288,6 +3288,10 @@
 If the commit is successful, the @file{MT/log} file is cleared of
 all content making it ready for another edit/commit cycle.
 
+If a @option{--branch} option is specified, the @command{commit} command
+commits to this branch (creating it if necessary).  The branch becomes
+the new default branch of the working copy.
+
 The @command{commit} command also synthesizes a number of
 certificates, which it attaches to the new manifest version and copies
 into your database:
@@ -3364,6 +3368,11 @@
 specified, with your local changes (and only your local changes)
 applied.
 
+If a @option{--branch} option is specified, the @command{update} command
+tries to select the revision to update to from this branch.  The branch
+becomes the new default branch of the working copy (even if you also
+specify an explicit @var{revision} argument).
+
 @end ftable
 
 @page




reply via email to

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