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: 8c57a6ba773f4


From: code
Subject: [Monotone-commits-diffs] net.venge.monotone.colored-diff: 8c57a6ba773f45b33a0c2308c93de34d80e820e4
Date: Sun, 10 Apr 2011 13:05:04 +0200 (CEST)

revision:            8c57a6ba773f45b33a0c2308c93de34d80e820e4
date:                2011-04-10T09:45:18
author:              Richard Hopkins <address@hidden>
branch:              net.venge.monotone.colored-diff
changelog:
Whitespace cleanup for colorizer files, and calls to .colorize

manifest:
format_version "1"

new_manifest [df3087038dcd5a811730ca7c8288dbc87b486bdd]

old_revision [08d015c908015234c4a7423a9bc5921521217675]

patch "src/colorizer.cc"
 from [96964884a83e4d7d638c146821a554d033f396eb]
   to [770dbe7f2c330c9f08c413985497a052b38a2f31]

patch "src/colorizer.hh"
 from [eb3d0e3dad8d447e270e0c6264bf1a4ea139013f]
   to [edcd644f94e2d14dd47e72aadaee6ce9562b7053]

patch "src/diff_output.cc"
 from [d90cc052a93d88428251b8ecb73b398eac1c546f]
   to [2549a312cc68aa71fd4c1401b941078f0ebfc946]

patch "src/lua_hooks.cc"
 from [54cca6b8fc31bfb114a5272ec9896c03e7f284b1]
   to [395a0f4bf8a29c80b81e6aea2c63efa42e376081]

patch "src/rev_output.cc"
 from [fec6728d80bca2d8d13ab49bb4ecd03310879fe5]
   to [7139e01b9af930758ab468b0f4f7f7c3e2d84b92]
============================================================
--- src/diff_output.cc	d90cc052a93d88428251b8ecb73b398eac1c546f
+++ src/diff_output.cc	2549a312cc68aa71fd4c1401b941078f0ebfc946
@@ -178,7 +178,7 @@ struct unidiff_hunk_writer : public hunk
                       ostream & ost,
                       string const & encloser_pattern,
                       colorizer const & color)
-  : hunk_consumer(a, b, ctx, ost, encloser_pattern, color)
+    : hunk_consumer(a, b, ctx, ost, encloser_pattern, color)
   {}
 };
 
@@ -186,14 +186,14 @@ void unidiff_hunk_writer::insert_at(size
 {
   b_len++;
   hunk.push_back(color.colorize(string("+") + b[b_pos],
-                                    colorizer::add));
+                                colorizer::add));
 }
 
 void unidiff_hunk_writer::delete_at(size_t a_pos)
 {
   a_len++;
   hunk.push_back(color.colorize(string("-") + a[a_pos],
-                                    colorizer::remove));
+                                colorizer::remove));
 }
 
 void unidiff_hunk_writer::flush_hunk(size_t pos)
@@ -215,16 +215,16 @@ void unidiff_hunk_writer::flush_hunk(siz
         ss << "@@ -0,0";
       else
         {
-          ss << "@@ -" << a_begin+1;
+          ss << "@@ -" << a_begin + 1;
           if (a_len > 1)
             ss << ',' << a_len;
         }
- 
+
       if (b_len == 0)
         ss << " +0,0";
       else
         {
-          ss << " +" << b_begin+1;
+          ss << " +" << b_begin + 1;
           if (b_len > 1)
             ss << ',' << b_len;
         }
@@ -313,8 +313,8 @@ struct cxtdiff_hunk_writer : public hunk
                       ostream & ost,
                       string const & encloser_pattern,
                       colorizer const & colorizer)
-  : hunk_consumer(a, b, ctx, ost, encloser_pattern, colorizer),
-    have_insertions(false), have_deletions(false)
+    : hunk_consumer(a, b, ctx, ost, encloser_pattern, colorizer),
+      have_insertions(false), have_deletions(false)
   {}
 };
 
@@ -412,20 +412,20 @@ void cxtdiff_hunk_writer::flush_pending_
   // just deletions, prefix with "-"; if both, prefix with "!"
   colorizer::purpose p = colorizer::normal;
   if (inserts.empty() && !deletes.empty())
-  {
-    prefix = "-";
-    p = colorizer::remove;
-  }
+    {
+      prefix = "-";
+      p = colorizer::remove;
+    }
   else if (deletes.empty() && !inserts.empty())
-  {
-    prefix = "+";
-    p = colorizer::add;
-  }
+    {
+      prefix = "+";
+      p = colorizer::add;
+    }
   else
-  {
-    prefix = "!";
-    p = colorizer::change;
-  }
+    {
+      prefix = "!";
+      p = colorizer::change;
+    }
 
   for (vector<size_t>::const_iterator i = deletes.begin();
        i != deletes.end(); ++i)
@@ -596,39 +596,39 @@ make_diff(string const & filename1,
   //      if the new file name is "/dev/null", nothing else.
   switch (type)
     {
-      case unified_diff:
-      {
-        ost << color.colorize(string("--- ") + filename1,
-                              colorizer::remove)
-            << '\t' << id1 << '\n';
-        ost << color.colorize(string("+++ ") + filename2,
-                              colorizer::add)
-            << '\t' << id2 << '\n';
+    case unified_diff:
+    {
+      ost << color.colorize(string("--- ") + filename1,
+                            colorizer::remove)
+          << '\t' << id1 << '\n';
+      ost << color.colorize(string("+++ ") + filename2,
+                            colorizer::add)
+          << '\t' << id2 << '\n';
 
-        unidiff_hunk_writer hunks(lines1, lines2, 3, ost, pattern, color);
-        walk_hunk_consumer(lcs, left_interned, right_interned, hunks);
-        break;
-      }
-      case context_diff:
-      {
-        ost << color.colorize(string("*** ") + filename1,
-                              colorizer::remove)
-            << '\t' << id1 << '\n';
-        ost << color.colorize(string("--- ") + filename2,
-                              colorizer::add)
-            << '\t' << id2 << '\n';
+      unidiff_hunk_writer hunks(lines1, lines2, 3, ost, pattern, color);
+      walk_hunk_consumer(lcs, left_interned, right_interned, hunks);
+      break;
+    }
+    case context_diff:
+    {
+      ost << color.colorize(string("*** ") + filename1,
+                            colorizer::remove)
+          << '\t' << id1 << '\n';
+      ost << color.colorize(string("--- ") + filename2,
+                            colorizer::add)
+          << '\t' << id2 << '\n';
 
-        cxtdiff_hunk_writer hunks(lines1, lines2, 3, ost, pattern, color);
-        walk_hunk_consumer(lcs, left_interned, right_interned, hunks);
-        break;
-      }
-      default:
-      {
-        // should never reach this; the external_diff type is not
-        // handled by this function.
-        I(false);
-      }
+      cxtdiff_hunk_writer hunks(lines1, lines2, 3, ost, pattern, color);
+      walk_hunk_consumer(lcs, left_interned, right_interned, hunks);
+      break;
     }
+    default:
+    {
+      // should never reach this; the external_diff type is not
+      // handled by this function.
+      I(false);
+    }
+    }
 }
 
 
============================================================
--- src/lua_hooks.cc	54cca6b8fc31bfb114a5272ec9896c03e7f284b1
+++ src/lua_hooks.cc	395a0f4bf8a29c80b81e6aea2c63efa42e376081
@@ -778,12 +778,12 @@ lua_hooks::hook_get_output_color(string 
   Lua ll = Lua(st);
 
   return ll.func("get_output_color")
-    .push_str(purpose)
-    .call(1, 3)
-    .extract_str(style).pop()
-    .extract_str(bg).pop()
-    .extract_str(fg)
-    .ok();
+         .push_str(purpose)
+         .call(1, 3)
+         .extract_str(style).pop()
+         .extract_str(bg).pop()
+         .extract_str(fg)
+         .ok();
 }
 
 bool
============================================================
--- src/rev_output.cc	fec6728d80bca2d8d13ab49bb4ecd03310879fe5
+++ src/rev_output.cc	7139e01b9af930758ab468b0f4f7f7c3e2d84b92
@@ -154,35 +154,35 @@ revision_summary(revision_t const & rev,
         out << _("no changes") << '\n';
 
       for (set<file_path>::const_iterator i = cs.nodes_deleted.begin();
-            i != cs.nodes_deleted.end(); ++i)
-        out << color.colorize((F("  dropped  %s") %*i).str(),
+           i != cs.nodes_deleted.end(); ++i)
+        out << color.colorize((F("  dropped  %s") % *i).str(),
                               colorizer::remove) << '\n';
 
       for (map<file_path, file_path>::const_iterator
-            i = cs.nodes_renamed.begin();
-            i != cs.nodes_renamed.end(); ++i)
+           i = cs.nodes_renamed.begin();
+           i != cs.nodes_renamed.end(); ++i)
         out << color.colorize((F("  renamed  %s\n"
                                  "       to  %s") % i->first
-                                 % i->second).str(),
+                               % i->second).str(),
                               colorizer::rename) << '\n';
 
       for (set<file_path>::const_iterator i = cs.dirs_added.begin();
-            i != cs.dirs_added.end(); ++i)
+           i != cs.dirs_added.end(); ++i)
         out << color.colorize((F("  added    %s") % *i).str(),
                               colorizer::add) << '\n';
 
       for (map<file_path, file_id>::const_iterator i = cs.files_added.begin();
-            i != cs.files_added.end(); ++i)
+           i != cs.files_added.end(); ++i)
         out << color.colorize((F("  added    %s") % i->first).str(),
                               colorizer::add) << '\n';
 
       for (map<file_path, pair<file_id, file_id> >::const_iterator
-              i = cs.deltas_applied.begin(); i != cs.deltas_applied.end(); ++i)
+           i = cs.deltas_applied.begin(); i != cs.deltas_applied.end(); ++i)
         out << color.colorize((F("  patched  %s") % i->first).str(),
                               colorizer::change) << '\n';
 
       for (map<pair<file_path, attr_key>, attr_value >::const_iterator
-             i = cs.attrs_set.begin(); i != cs.attrs_set.end(); ++i)
+           i = cs.attrs_set.begin(); i != cs.attrs_set.end(); ++i)
         out << color.colorize((F("  attr on  %s\n"
                                  "      set  %s\n"
                                  "       to  %s")
@@ -197,10 +197,10 @@ revision_summary(revision_t const & rev,
       // 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)
+           i = cs.attrs_cleared.begin(); i != cs.attrs_cleared.end(); ++i)
         out << color.colorize((F("  attr on  %s\n"
                                  "    unset  %s") % i->first
-                                 % i->second).str(),
+                               % i->second).str(),
                               colorizer::unset) << '\n';
 
       out << '\n';
============================================================
--- src/colorizer.cc	96964884a83e4d7d638c146821a554d033f396eb
+++ src/colorizer.cc	770dbe7f2c330c9f08c413985497a052b38a2f31
@@ -19,7 +19,7 @@ string colorizer::purpose_to_name(colori
 string colorizer::purpose_to_name(colorizer::purpose const p) const
 {
   switch (p)
-  {
+    {
     case normal:
       return "normal";
     case reset:
@@ -50,7 +50,7 @@ string colorizer::purpose_to_name(colori
 
     default:
       I(false); // should never get here
-  }
+    }
 }
 
 std::pair<colorizer::purpose, boost::tuple<string, string, string> > colorizer::map_output_color(
@@ -133,7 +133,7 @@ string colorizer::style_to_code(string c
     return "\033[22m\033[23m\033[24m"; // all off
 }
 
-colorizer::colorizer(bool enable, lua_hooks & lh) 
+colorizer::colorizer(bool enable, lua_hooks & lh)
   : lua(lh)
 {
   if (!have_smart_terminal())
@@ -164,7 +164,7 @@ colorizer::colorize(string const & in, p
   if (colormap.find(p) == colormap.end())
     return in;
 
-   return get_format(p) + in + get_format(reset);
+  return get_format(p) + in + get_format(reset);
 }
 
 string
============================================================
--- src/colorizer.hh	eb3d0e3dad8d447e270e0c6264bf1a4ea139013f
+++ src/colorizer.hh	edcd644f94e2d14dd47e72aadaee6ce9562b7053
@@ -15,7 +15,8 @@
 #include <map>
 #include <boost/tuple/tuple.hpp>
 
-struct colorizer {
+struct colorizer
+{
 
   typedef enum { normal = 0,
                  reset,
@@ -31,7 +32,7 @@ struct colorizer {
                  separator,
                  set,
                  unset
-                } purpose;
+               } purpose;
 
   colorizer(bool enable, lua_hooks & lh);
 
@@ -40,7 +41,7 @@ private:
 
 private:
   std::map<purpose, boost::tuple<std::string, std::string, std::string> >
-    colormap;
+  colormap;
   lua_hooks & lua;
 
   std::pair<purpose, boost::tuple<std::string, std::string, std::string> >

reply via email to

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