monotone-devel
[Top][All Lists]
Advanced

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

[Monotone-devel] [PATCH 2/2] git_export: cleanup


From: Felipe Contreras
Subject: [Monotone-devel] [PATCH 2/2] git_export: cleanup
Date: Sun, 8 Mar 2009 07:31:42 +0200

These are possible after the previous commit.

Signed-off-by: Felipe Contreras <address@hidden>
---
 git_export.cc |   93 ++++++++++++++++++++++++++++-----------------------------
 1 files changed, 46 insertions(+), 47 deletions(-)

diff --git a/git_export.cc b/git_export.cc
index 803caa4..9583d8a 100644
--- a/git_export.cc
+++ b/git_export.cc
@@ -216,43 +216,46 @@ export_changes(database & db,
       typedef map<string, string>::const_iterator lookup_iterator;
 
       cert_vector certs;
-      cert_vector authors;
-      cert_vector branches;
-      cert_vector changelogs;
-      cert_vector comments;
-      cert_vector dates;
-      cert_vector tags;
+      vector<string> authors;
+      vector<string> branches;
+      vector<string> changelogs;
+      vector<string> comments;
+      vector<string> dates;
+      vector<string> tags;
 
       db.get_revision_certs(*r, certs);
 
+      // default to <unknown> committer and author if no author certs exist
+      // this may be mapped to a different value with the authors-file option
+      string author_name = "<unknown>"; // used as the git author
+      string author_key  = "<unknown>"; // used as the git committer
+      date_t author_date = date_t::now();
+
       for (cert_iterator i = certs.begin(); i != certs.end(); i++)
         {
           if (i->inner().name == author_cert_name)
-            authors.push_back(*i);
+            {
+              if (authors.empty())
+                {
+                  author_name = trim(i->inner().value());
+                  author_key  = trim(i->inner().key());
+                }
+              authors.push_back(i->inner().value());
+            }
           else if (i->inner().name == date_cert_name)
-            dates.push_back(*i);
+            {
+              if (dates.empty())
+                author_date = date_t(i->inner().value());
+              dates.push_back(i->inner().value());
+            }
           else if (i->inner().name == changelog_cert_name)
-            changelogs.push_back(*i);
+            changelogs.push_back(i->inner().value());
           else if (i->inner().name == branch_cert_name)
-            branches.push_back(*i);
+            branches.push_back(i->inner().value());
           else if (i->inner().name == tag_cert_name)
-            tags.push_back(*i);
+            tags.push_back(i->inner().value());
           else if (i->inner().name == comment_cert_name)
-            comments.push_back(*i);
-        }
-
-      // default to <unknown> committer and author if no author certs exist
-      // this may be mapped to a different value with the authors-file option
-      string author_name = "<unknown>"; // used as the git author
-      string author_key  = "<unknown>"; // used as the git committer
-      date_t author_date = date_t::now();
-
-      cert_iterator author = authors.begin();
-
-      if (author != authors.end())
-        {
-          author_name = trim(author->inner().value());
-          author_key  = trim(author->inner().key());
+            comments.push_back(i->inner().value());
         }
 
       // all monotone keys and authors that don't follow the "Name <email>"
@@ -280,17 +283,12 @@ export_changes(database & db,
                author_name.find('>') == string::npos)
         author_name = "<" + author_name + ">";
 
-      cert_iterator date = dates.begin();
-
-      if (date != dates.end())
-        author_date = date_t(date->inner().value());
-
       // default to unknown branch if no branch certs exist
       // this may be mapped to a different value with the branches-file option
       string branch_name = "unknown";
 
       if (!branches.empty())
-        branch_name = branches.begin()->inner().value();
+        branch_name = *(branches.begin());
 
       branch_name = trim(branch_name);
 
@@ -307,10 +305,10 @@ export_changes(database & db,
       changelogs.insert(changelogs.end(),
                         comments.begin(), comments.end());
 
-      for (cert_iterator changelog = changelogs.begin();
+      for (vector<string>::iterator changelog = changelogs.begin();
            changelog != changelogs.end(); ++changelog)
         {
-          string value = changelog->inner().value();
+          string value = *changelog;
           if (messages.find(value) == messages.end())
             {
               messages.insert(value);
@@ -380,19 +378,20 @@ export_changes(database & db,
 
       if (log_certs)
         {
+          vector<string>::iterator i;
+
           message << "\n";
-          for ( ; author != authors.end(); ++author)
-            message << "Monotone-Author: " << author->inner().value() << "\n";
+          for (i = authors.begin(); i != authors.end(); ++i)
+            message << "Monotone-Author: " << *i << "\n";
 
-          for ( ; date != dates.end(); ++date)
-            message << "Monotone-Date: " << date->inner().value() << "\n";
+          for (i = dates.begin(); i != dates.end(); ++i)
+            message << "Monotone-Date: " << *i << "\n";
 
-          for (cert_iterator
-                 branch = branches.begin() ; branch != branches.end(); 
++branch)
-            message << "Monotone-Branch: " << branch->inner().value() << "\n";
+          for (i = branches.begin() ; i != branches.end(); ++i)
+            message << "Monotone-Branch: " << *i << "\n";
 
-          for (cert_iterator tag = tags.begin(); tag != tags.end(); ++tag)
-            message << "Monotone-Tag: " << tag->inner().value() << "\n";
+          for (i = tags.begin(); i != tags.end(); ++i)
+            message << "Monotone-Tag: " << *i << "\n";
         }
 
       string data = message.str();
@@ -432,11 +431,11 @@ export_changes(database & db,
       // create additional branch refs
       if (!branches.empty())
         {
-          cert_iterator branch = branches.begin();
+          vector<string>::iterator branch = branches.begin();
           branch++;
           for ( ; branch != branches.end(); ++branch)
             {
-              branch_name = trim(branch->inner().value());
+              branch_name = trim(*branch);
 
               lookup_iterator branch_lookup = branch_map.find(branch_name);
 
@@ -449,8 +448,8 @@ export_changes(database & db,
         }
 
       // create tag refs
-      for (cert_iterator tag = tags.begin(); tag != tags.end(); ++tag)
-        cout << "reset refs/tags/" << tag->inner().value() << "\n"
+      for (vector<string>::iterator tag = tags.begin(); tag != tags.end(); 
++tag)
+        cout << "reset refs/tags/" << *tag << "\n"
              << "from :" << marked_revs[*r] << "\n";
 
       // report progress to the export file which will be reported during 
import
-- 
1.6.2





reply via email to

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