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.colored-diff: 1e72ca225f530


From: code
Subject: [Monotone-commits-diffs] net.venge.monotone.colored-diff: 1e72ca225f53020031d2534130f74866f2c78b9a
Date: Sun, 16 Jan 2011 12:58:16 GMT

revision:            1e72ca225f53020031d2534130f74866f2c78b9a
date:                2011-01-16T11:59:30
author:              Richard Hopkins
branch:              net.venge.monotone.colored-diff
changelog:
Colorized output of mtn status

For simplicity I have made status_added be used when adding files 
and directories. We may want to differentiate between them later 
like we do for diff_* and status_* even though they both have very 
similar "child" purposes, but for now my plan is to simplify them 
and be consistent with their usage. 

This has the benefit of the get_output_color hook being easier to
edit by all users.

For instance, nobody should have to care about the "reset" purpose
in the hook as this is an implementation detail, so this will be
taken out eventually.

manifest:
format_version "1"

new_manifest [396df3552ff4de25360e38e3cb623da118038d67]

old_revision [96c709bbdd68e6b620813e6221489509b93bd93c]

patch "colorizer.cc"
 from [91a78780eb3129aee04033b1a1c7a84642c2cd51]
   to [f6834808b449eeed8b68236160931f1f69dd27e1]

patch "colorizer.hh"
 from [f57044cca7f6b76d0890db20d28b4c82b385965b]
   to [048936d14b4373d0148bf8991791364c2a5395ae]

patch "rev_output.cc"
 from [90f5ca2ff78f91bdf512231482d00a2eee37875b]
   to [c36ffcf8412298362035f4c5d9c1ef8bc8b149d7]

patch "std_hooks.lua"
 from [3497e715f6d10ab3f3224a4dfa1448dd918f812d]
   to [6228376d2dfa906746aa1a6f13b5fcdf0f260b5a]
============================================================
--- std_hooks.lua	3497e715f6d10ab3f3224a4dfa1448dd918f812d
+++ std_hooks.lua	6228376d2dfa906746aa1a6f13b5fcdf0f260b5a
@@ -1552,7 +1552,14 @@ function get_output_color(purpose)
 		diff_separator = "bold",
 		
 		log_revision = "bold",
-		rev_header = "bold"
+		rev_header = "bold",
+
+		status_added = "green",
+		status_dropped = "red",
+		status_patched = "blue",
+		status_renamed = "yellow",
+		status_set = "cyan",
+		status_unset = "magenta"
 	}
 
 	local chosen_color = color_table[purpose]
============================================================
--- rev_output.cc	90f5ca2ff78f91bdf512231482d00a2eee37875b
+++ rev_output.cc	c36ffcf8412298362035f4c5d9c1ef8bc8b149d7
@@ -155,32 +155,40 @@ 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 << color.colorize((F("  dropped  %s") %*i).str(),
+                              colorizer::status_dropped) << '\n';
 
       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 << color.colorize((F("  renamed  %s\n"
+                                 "       to  %s") % i->first
+                                 % i->second).str(),
+                              colorizer::status_renamed) << '\n';
 
       for (set<file_path>::const_iterator i = cs.dirs_added.begin();
             i != cs.dirs_added.end(); ++i)
-        out << (F("  added    %s") % *i) << '\n';
+        out << color.colorize((F("  added    %s") % *i).str(),
+                              colorizer::status_added) << '\n';
 
       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 << color.colorize((F("  added    %s") % i->first).str(),
+                              colorizer::status_added) << '\n';
 
       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 << color.colorize((F("  patched  %s") % i->first).str(),
+                              colorizer::status_patched) << '\n';
 
       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';
+        out << color.colorize((F("  attr on  %s\n"
+                                 "      set  %s\n"
+                                 "       to  %s")
+                               % i->first.first % i->first.second
+                               % i->second).str(),
+                              colorizer::status_set) << '\n';
 
       // FIXME: naming here could not be more inconsistent
       // the cset calls it attrs_cleared
@@ -190,8 +198,10 @@ revision_summary(revision_t const & rev,
 
       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';
+        out << color.colorize((F("  attr on  %s\n"
+                                 "    unset  %s") % i->first
+                                 % i->second).str(),
+                              colorizer::status_unset) << '\n';
 
       out << '\n';
     }
============================================================
--- colorizer.cc	91a78780eb3129aee04033b1a1c7a84642c2cd51
+++ colorizer.cc	f6834808b449eeed8b68236160931f1f69dd27e1
@@ -50,6 +50,24 @@ string colorizer::purpose_to_name(colori
     case rev_header:
       return "rev_header";
 
+    case status_added:
+      return "status_added";
+
+    case status_dropped:
+      return "status_dropped";
+
+    case status_patched:
+      return "status_patched";
+
+    case status_renamed:
+      return "status_renamed";
+
+    case status_set:
+      return "status_set";
+
+    case status_unset:
+      return "status_unset";
+
     default:
       I(false); // should never get here
   }
@@ -110,6 +128,12 @@ colorizer::colorizer(bool enable, lua_ho
       colormap.insert(map_output_color(diff_separator));
       colormap.insert(map_output_color(log_revision));
       colormap.insert(map_output_color(rev_header));
+      colormap.insert(map_output_color(status_added));
+      colormap.insert(map_output_color(status_dropped));
+      colormap.insert(map_output_color(status_patched));
+      colormap.insert(map_output_color(status_renamed));
+      colormap.insert(map_output_color(status_set));
+      colormap.insert(map_output_color(status_unset));
     }
 }
 
============================================================
--- colorizer.hh	f57044cca7f6b76d0890db20d28b4c82b385965b
+++ colorizer.hh	048936d14b4373d0148bf8991791364c2a5395ae
@@ -25,7 +25,13 @@ struct colorizer {
                  diff_comment,
                  diff_separator,
                  log_revision,
-                 rev_header
+                 rev_header,
+                 status_added,
+                 status_dropped,
+                 status_patched,
+                 status_renamed,
+                 status_set,
+                 status_unset
                  } purpose;
 
   colorizer(bool enable, lua_hooks & lh);

reply via email to

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