changeset 132:8cabda8ae1c6

merge from beejahth
author Scott Chacon <schacon@gmail.com>
date Tue, 19 May 2009 09:40:54 -0700
parents 695a90e72e4f (current diff) dd6c77ec206c (diff)
children 2fa3ac775983
files git_handler.py
diffstat 5 files changed, 18 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/dulwich/objects.py
+++ b/dulwich/objects.py
@@ -479,15 +479,19 @@
 
 def parse_timezone(text):
     offset = int(text)
+    signum = (offset < 0) and -1 or 1
+    offset = abs(offset)
     hours = int(offset / 100)
     minutes = (offset % 100)
-    return (hours * 3600) + (minutes * 60)
+    return signum * (hours * 3600 + minutes * 60)
 
 
 def format_timezone(offset):
     if offset % 60 != 0:
         raise ValueError("Unable to handle non-minute offset.")
-    return '%+03d%02d' % (offset / 3600, (offset / 60) % 60)
+    sign = (offset < 0) and '-' or '+'
+    offset = abs(offset)
+    return '%c%02d%02d' % (sign, offset / 3600, (offset / 60) % 60)
 
 
 class Commit(ShaFile):
--- a/git_handler.py
+++ b/git_handler.py
@@ -13,7 +13,8 @@
     ShaFile,
     Tag,
     Tree,
-    hex_to_sha
+    hex_to_sha,
+    format_timezone,
     )
 
 import math
@@ -230,13 +231,16 @@
         author = ctx.user()
         if not '>' in author: # TODO : this kills losslessness - die (submodules)?
             author = author + ' <none@none>'
-        commit['author'] = author + ' ' + str(int(time)) + ' ' + seconds_to_offset(timezone)
+        commit['author'] = author + ' ' + str(int(time)) + ' ' + format_timezone(-timezone)
         message = ctx.description()
         commit['message'] = ctx.description() + "\n"
 
         extra = ctx.extra()
         if 'committer' in extra:
-            commit['committer'] = extra['committer']
+            # fixup timezone
+            (name_timestamp, timezone) = extra['committer'].rsplit(' ', 1)
+            timezone = format_timezone(-int(timezone))
+            commit['committer'] = '%s %s' % (name_timestamp, timezone)
         if 'encoding' in extra:
             commit['encoding'] = extra['encoding']
 
@@ -623,7 +627,7 @@
 
         # if committer is different than author, add it to extra
         if not commit._author_raw == commit._committer_raw:
-            extra['committer'] = commit._committer_raw
+            extra['committer'] = "%s %d %d" % (commit.committer, commit.commit_time, -commit.commit_timezone)
 
         if commit._encoding:
             extra['encoding'] = commit._encoding
@@ -632,7 +636,7 @@
             extra['branch'] = hg_branch
 
         text = strip_message
-        date = datetime.datetime.fromtimestamp(commit.author_time).strftime("%Y-%m-%d %H:%M:%S")
+        date = (commit.author_time, -commit.author_timezone)
         ctx = context.memctx(self.repo, (p1, p2), text, files, getfilectx,
                              commit.author, date, extra)
         a = self.repo.commitctx(ctx)
--- a/tests/test-file-removal
+++ b/tests/test-file-removal
@@ -4,7 +4,7 @@
 # "$TESTDIR/hghave" git || exit 80
 
 # bail early if the user is already running git-daemon
-echo hi | nc localhost 9418 && exit 80
+echo hi | nc localhost 9418 2>/dev/null && exit 80
 
 echo "[extensions]" >> $HGRCPATH
 echo "hggit=$(echo $(dirname $(dirname $0)))" >> $HGRCPATH
--- a/tests/test-git-clone
+++ b/tests/test-git-clone
@@ -4,7 +4,7 @@
 # "$TESTDIR/hghave" git || exit 80
 
 # bail early if the user is already running git-daemon
-echo hi | nc localhost 9418 && exit 80
+echo hi | nc localhost 9418 2>/dev/null && exit 80
 
 echo "[extensions]" >> $HGRCPATH
 echo "hggit=$(echo $(dirname $(dirname $0)))" >> $HGRCPATH
--- a/tests/test-sane-without-bookmarks
+++ b/tests/test-sane-without-bookmarks
@@ -4,7 +4,7 @@
 # "$TESTDIR/hghave" git || exit 80
 
 # bail early if the user is already running git-daemon
-echo hi | nc localhost 9418 && exit 80
+echo hi | nc localhost 9418 2>/dev/null && exit 80
 
 echo "[extensions]" >> $HGRCPATH
 echo "hggit=$(echo $(dirname $(dirname $0)))" >> $HGRCPATH