changeset 89:e35ed99fa691

committer info now being kept properly
author Scott Chacon <schacon@gmail.com>
date Fri, 08 May 2009 20:57:02 -0700
parents 52b4be85151d
children 353c9e9192ec
files TODO.txt dulwich/objects.py git_handler.py
diffstat 3 files changed, 21 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/TODO.txt
+++ b/TODO.txt
@@ -27,8 +27,7 @@
   - dont convert back properly for some reason
 
 Created in Git:
-* different committer in Git objects
-* encoding field
+* encoding field / utf-8
 * octopus merge explode/implode
 
 WEBSITE
--- a/dulwich/objects.py
+++ b/dulwich/objects.py
@@ -544,14 +544,17 @@
                 self._author += text[count]
                 count += 1
             self._author += text[count]
+            self._author_raw = self._author
             count += 1
             assert text[count] == ' ', "Invalid commit object, " \
                  "author information must be followed by space not %s" % text[count]
             count += 1
+            self._author_raw += ' ' + text[count:].split(" ", 1)[0]
             self._author_time = int(text[count:].split(" ", 1)[0])
             while text[count] != ' ':
                 assert text[count] != '\n', "Malformed author information"
                 count += 1
+            self._author_raw += text[count:count+6]
             self._author_timezone = parse_timezone(text[count:count+6])
             count += 1
             while text[count] != '\n':
@@ -569,14 +572,17 @@
                 self._committer += text[count]
                 count += 1
             self._committer += text[count]
+            self._committer_raw = self._committer
             count += 1
             assert text[count] == ' ', "Invalid commit object, " \
                  "commiter information must be followed by space not %s" % text[count]
             count += 1
-            self._commit_time = int(text[count:count+10])
+            self._committer_raw += ' ' + text[count:].split(" ", 1)[0]
+            self._commit_time = int(text[count:].split(" ", 1)[0])
             while text[count] != ' ':
                 assert text[count] != '\n', "Malformed committer information"
                 count += 1
+            self._committer_raw += text[count:count+6]
             self._commit_timezone = parse_timezone(text[count:count+6])
             count += 1
             while text[count] != '\n':
--- a/git_handler.py
+++ b/git_handler.py
@@ -197,12 +197,16 @@
 
         # hg authors might not have emails
         author = ctx.user()
-        if not '>' in author:
+        if not '>' in author: # TODO : this kills losslessness - die (submodules)?
             author = author + ' <none@none>'
         commit['author'] = author + ' ' + str(int(time)) + ' ' + seconds_to_offset(timezone)
         message = ctx.description()
         commit['message'] = ctx.description() + "\n"
 
+        extra = ctx.extra()
+        if 'committer' in extra:
+            commit['committer'] = extra['committer']
+
         # HG EXTRA INFORMATION
         add_extras = False
         extra_message = ''
@@ -541,12 +545,17 @@
                 files.remove(removefile)
 
         extra = {}
-        
-        # *TODO : if committer is different than author, add it to extra
-        
+
         # if named branch, add to extra
         if hg_branch:
             extra['branch'] = hg_branch
+
+        # if committer is different than author, add it to extra
+        if not commit._author_raw == commit._committer_raw:
+            extra['committer'] = commit._committer_raw
+
+        if hg_branch:
+            extra['branch'] = hg_branch
         
         text = strip_message
         date = datetime.datetime.fromtimestamp(commit.author_time).strftime("%Y-%m-%d %H:%M:%S")