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: fc13d22f21a87c3a


From: code
Subject: [Monotone-commits-diffs] net.venge.monotone.issue-120: fc13d22f21a87c3a0f37d87a7fb8bbf667b65639
Date: Tue, 25 Jan 2011 21:41:14 GMT

revision:            fc13d22f21a87c3a0f37d87a7fb8bbf667b65639
date:                2011-01-25T21:38:20
author:              Richard Hopkins <address@hidden>
branch:              net.venge.monotone.issue-120
changelog:
Potential working replacement for "mtn ls changed"

The strategy is to add each file_path into a std::set and then
iterate over it to output them all to screen - where it will
be sorted and duplicates removed. We should then have achieved
the goal of making "mtn ls changed" perform about the same as
"mtn status" - as it's now directly based from it.

This passes the "listing_changed_files" test and also some
quick testing from a new db+workspace.

I think the std::set iteration could be cleaned up as I end
up using a temporary ostringstream for converting the file_path
into a string - but I don't know how to do that just yet without
it.

manifest:
format_version "1"

new_manifest [90310b6dbe3b9fa0acb0b13bc873ba99d7f16380]

old_revision [5738f6ad3484cf1ea2621890c217a8cfcdea3a9f]

patch "cmd_list.cc"
 from [407919e0d297548d5f0e59ef1cb7dcdb4ce4335a]
   to [9d870ecf6461b873a0a90c0cfcc3e7f4eda17dd4]
============================================================
--- cmd_list.cc	407919e0d297548d5f0e59ef1cb7dcdb4ce4335a
+++ cmd_list.cc	9d870ecf6461b873a0a90c0cfcc3e7f4eda17dd4
@@ -879,8 +879,7 @@ CMD(changed, "changed", "", CMD_REF(list
   revision_id rid;
   calculate_ident(rev, rid);
 
-  ostringstream out; // TODO: We probably don't want to use this as we
-  // need to sort and filter duplicates before outputting.
+  set<file_path> output_files;
 
   // TODO: Refactor this method and promote these locals to parameters
   // We can then use the method to provide us with "mtn ls added" for
@@ -900,7 +899,7 @@ CMD(changed, "changed", "", CMD_REF(list
         {
           for (set<file_path>::const_iterator i = cs.nodes_deleted.begin();
             i != cs.nodes_deleted.end(); ++i)
-            out << *i << "\n";
+            output_files.insert(*i);
         }
 
       if (output_renamed)
@@ -908,32 +907,32 @@ CMD(changed, "changed", "", CMD_REF(list
           for (map<file_path, file_path>::const_iterator
             i = cs.nodes_renamed.begin();
             i != cs.nodes_renamed.end(); ++i)
-            out << i->second << "\n";
+            output_files.insert(i->second);
         }
 
       if (output_added)
         {
           for (set<file_path>::const_iterator i = cs.dirs_added.begin();
             i != cs.dirs_added.end(); ++i)
-            out << *i << "\n";
+            output_files.insert(*i);
 
           for (map<file_path, file_id>::const_iterator i = cs.files_added.begin();
             i != cs.files_added.end(); ++i)
-            out << i->first << "\n";
+            output_files.insert(i->first);
         }
 
       if (output_patched)
         {
           for (map<file_path, pair<file_id, file_id> >::const_iterator
             i = cs.deltas_applied.begin(); i != cs.deltas_applied.end(); ++i)
-            out << i->first << "\n";
+            output_files.insert(i->first);
         }
 
       if (output_attrs)
         {
           for (map<pair<file_path, attr_key>, attr_value >::const_iterator
             i = cs.attrs_set.begin(); i != cs.attrs_set.end(); ++i)
-            out << i->first.first << "\n";
+            output_files.insert(i->first.first);
 
             // FIXME: naming here could not be more inconsistent
             // the cset calls it attrs_cleared
@@ -941,17 +940,25 @@ CMD(changed, "changed", "", CMD_REF(list
             // 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 << i->first << "\n";
+          for (set<pair<file_path, attr_key> >::const_iterator
+            i = cs.attrs_cleared.begin(); i != cs.attrs_cleared.end(); ++i)
+            output_files.insert(i->first);
         }
     }
 
-  utf8 summary = utf8(out.str(), origin::internal);
+  for (set<file_path>::const_iterator i = output_files.begin();
+       i != output_files.end(); ++i)
+    {
+      ostringstream tmp;
+      external summary_external;
 
-  external summary_external;
-  utf8_to_system_best_effort(summary, summary_external);
-  cout << summary_external;
+      tmp << *i;
+      utf8 summary = utf8(tmp.str(), origin::internal);
+
+      utf8_to_system_best_effort(summary, summary_external);
+
+      cout << summary_external << "\n";
+    }
 }
 
 namespace

reply via email to

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