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-120: e65d1e95297f298f


From: code
Subject: [Monotone-commits-diffs] net.venge.monotone.issue-120: e65d1e95297f298fa88c6d2cea1c9ff0e9689a64
Date: Thu, 24 Feb 2011 17:30:45 +0100 (CET)

revision:            e65d1e95297f298fa88c6d2cea1c9ff0e9689a64
date:                2011-02-23T21:30:23
author:              Richard Hopkins <address@hidden>
branch:              net.venge.monotone.issue-120
changelog:
Added method friendly_node_summary, and enum node_status to mimic existing
"mtn status" output

This will also form the basis of allowing revision_summary to be used for
"mtn status" and "mtn ls changed".

Currently friendly_node_summary does not implement all of the statuses as I
need to discuss about handling attributes via this method, and also of
added directories should be seen as a node_status of added or not.

The idea is once all of the existing paths in the revision_summary
iteration have been handled by the respective friendly_node_summary calls
then we can add a new boost::function parameter and call that instead. This
will leave us (hopefully) with the same functionality as before, but with
the framework done for "mtn ls changed" to just keep the filenames.

manifest:
format_version "1"

new_manifest [94b3cabc7f27b010a0686a44556bda17c6f6a9b1]

old_revision [a3dc8f1526dcdf8c37412441e6ccc8b4a6d136d7]

patch "src/rev_output.cc"
 from [a2c70b893b31296917d1a2b974faa1da46c13f1e]
   to [a77e06898637b1612f0be870f8d10a917acebf27]

patch "src/rev_output.hh"
 from [666dd3ed35e16d8b122b4932c2aad05a21a22e25]
   to [2451927b672030dde2542360648295ad49168d54]
============================================================
--- src/rev_output.cc	a2c70b893b31296917d1a2b974faa1da46c13f1e
+++ src/rev_output.cc	a77e06898637b1612f0be870f8d10a917acebf27
@@ -119,6 +119,64 @@ revision_header(revision_id const rid, r
   header = utf8(out.str(), origin::internal);
 }
 
+string
+friendly_node_summary(node_status const status, file_path const & fp_first,
+                      file_path const & fp_second)
+{
+  ostringstream out;
+
+  switch (status)
+    {
+      case dropped:
+        out << (F("  dropped  %s") % fp_first);
+        break;
+    
+      case renamed:
+        out << (F("  renamed  %s\n"
+                  "       to  %s") % fp_first % fp_second);
+        break;
+
+      /*case added: // TODO: dir
+        out << (F("  added    %s") % fp_first) << '\n';
+        break;
+      */
+
+      case added:
+        out << (F("  added    %s") % fp_first);
+        break;
+
+      case patched:
+        out << (F("  patched  %s") % fp_first);
+        break;
+
+    /*TODO: for (map<pair<file_path, attr_key>, attr_value >::const_iterator
+           i = cs.attrs_set.begin(); i != cs.attrs_set.end(); ++i)
+        out << (F("  attr on  %s\n"
+                  "      set  %s\n"
+                  "       to  %s")
+                % i->first.first % i->first.second % i->second) << '\n';
+
+      // FIXME: naming here could not be more inconsistent
+      // the cset calls it attrs_cleared
+      // the command is attr drop
+      // here it is called unset
+      // the revision text uses attr clear 
+
+      for (set<pair<file_path, attr_key> >::const_iterator
+             i = cs.attrs_cleared.begin(); i != cs.attrs_cleared.end(); ++i)
+        out << (F("  attr on  %s\n"
+                  "    unset  %s") % i->first % i->second) << '\n';
+    */
+
+      default:
+        out << "TODO\n";
+        break;
+    }
+
+  out << '\n';
+  return out.str();
+}
+
 void
 revision_summary(revision_t const & rev, utf8 & summary)
 {
@@ -148,13 +206,12 @@ revision_summary(revision_t const & rev,
 
       for (set<file_path>::const_iterator i = cs.nodes_deleted.begin();
             i != cs.nodes_deleted.end(); ++i)
-        out << (F("  dropped  %s") %*i) << '\n';
+        out << friendly_node_summary(dropped, *i, *i);
 
       for (map<file_path, file_path>::const_iterator
             i = cs.nodes_renamed.begin();
             i != cs.nodes_renamed.end(); ++i)
-        out << (F("  renamed  %s\n"
-                  "       to  %s") % i->first % i->second) << '\n';
+        out << friendly_node_summary(renamed, i->first, i->second);
 
       for (set<file_path>::const_iterator i = cs.dirs_added.begin();
             i != cs.dirs_added.end(); ++i)
@@ -162,11 +219,11 @@ revision_summary(revision_t const & rev,
 
       for (map<file_path, file_id>::const_iterator i = cs.files_added.begin();
             i != cs.files_added.end(); ++i)
-        out << (F("  added    %s") % i->first) << '\n';
+        out << friendly_node_summary(added, i->first, i->first);
 
       for (map<file_path, pair<file_id, file_id> >::const_iterator
               i = cs.deltas_applied.begin(); i != cs.deltas_applied.end(); ++i)
-        out << (F("  patched  %s") % i->first) << '\n';
+        out << friendly_node_summary(patched, i->first, i->first);
 
       for (map<pair<file_path, attr_key>, attr_value >::const_iterator
              i = cs.attrs_set.begin(); i != cs.attrs_set.end(); ++i)
============================================================
--- src/rev_output.hh	666dd3ed35e16d8b122b4932c2aad05a21a22e25
+++ src/rev_output.hh	2451927b672030dde2542360648295ad49168d54
@@ -27,6 +27,20 @@ revision_header(revision_id const rid, r
                 std::vector<cert> const & certs, std::string const & date_fmt,
                 utf8 & header);
 
+enum node_status
+{
+  added,
+  attr_set,
+  attr_unset,
+  dropped,
+  patched,
+  renamed
+};
+
+std::string
+friendly_node_summary(node_status const status, file_path const & fp_first,
+                      file_path const & fp_second);
+
 void
 revision_summary(revision_t const & rev, utf8 & summary);
 

reply via email to

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