diff --git a/dulwich/objects.py b/dulwich/objects.py index 695a90e72e4f82046a234f5b748d1f899c5a72b9_ZHVsd2ljaC9vYmplY3RzLnB5..8cabda8ae1c6aa891b5850d0091bc62c088e8c2e_ZHVsd2ljaC9vYmplY3RzLnB5 100644 --- a/dulwich/objects.py +++ b/dulwich/objects.py @@ -479,5 +479,7 @@ def parse_timezone(text): offset = int(text) + signum = (offset < 0) and -1 or 1 + offset = abs(offset) hours = int(offset / 100) minutes = (offset % 100) @@ -482,8 +484,8 @@ 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.") @@ -485,9 +487,11 @@ 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): diff --git a/git_handler.py b/git_handler.py index 695a90e72e4f82046a234f5b748d1f899c5a72b9_Z2l0X2hhbmRsZXIucHk=..8cabda8ae1c6aa891b5850d0091bc62c088e8c2e_Z2l0X2hhbmRsZXIucHk= 100644 --- 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,9 +231,9 @@ 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: @@ -234,9 +235,12 @@ 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) diff --git a/tests/test-file-removal b/tests/test-file-removal index 695a90e72e4f82046a234f5b748d1f899c5a72b9_dGVzdHMvdGVzdC1maWxlLXJlbW92YWw=..8cabda8ae1c6aa891b5850d0091bc62c088e8c2e_dGVzdHMvdGVzdC1maWxlLXJlbW92YWw= 100755 --- 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 diff --git a/tests/test-git-clone b/tests/test-git-clone index 695a90e72e4f82046a234f5b748d1f899c5a72b9_dGVzdHMvdGVzdC1naXQtY2xvbmU=..8cabda8ae1c6aa891b5850d0091bc62c088e8c2e_dGVzdHMvdGVzdC1naXQtY2xvbmU= 100755 --- 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 diff --git a/tests/test-sane-without-bookmarks b/tests/test-sane-without-bookmarks index 695a90e72e4f82046a234f5b748d1f899c5a72b9_dGVzdHMvdGVzdC1zYW5lLXdpdGhvdXQtYm9va21hcmtz..8cabda8ae1c6aa891b5850d0091bc62c088e8c2e_dGVzdHMvdGVzdC1zYW5lLXdpdGhvdXQtYm9va21hcmtz 100755 --- 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