# HG changeset patch # User Scott Chacon # Date 1242751254 25200 # Node ID 8cabda8ae1c6aa891b5850d0091bc62c088e8c2e # Parent 695a90e72e4f82046a234f5b748d1f899c5a72b9# Parent dd6c77ec206c64f7719aff3de2c34c7cb7be134f merge from beejahth diff -r 695a90e72e4f -r 8cabda8ae1c6 dulwich/objects.py --- a/dulwich/objects.py Tue May 19 09:33:46 2009 -0700 +++ b/dulwich/objects.py Tue May 19 09:40:54 2009 -0700 @@ -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): diff -r 695a90e72e4f -r 8cabda8ae1c6 git_handler.py --- a/git_handler.py Tue May 19 09:33:46 2009 -0700 +++ b/git_handler.py Tue May 19 09:40:54 2009 -0700 @@ -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 + ' ' - 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) diff -r 695a90e72e4f -r 8cabda8ae1c6 tests/test-file-removal --- a/tests/test-file-removal Tue May 19 09:33:46 2009 -0700 +++ b/tests/test-file-removal Tue May 19 09:40:54 2009 -0700 @@ -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 -r 695a90e72e4f -r 8cabda8ae1c6 tests/test-git-clone --- a/tests/test-git-clone Tue May 19 09:33:46 2009 -0700 +++ b/tests/test-git-clone Tue May 19 09:40:54 2009 -0700 @@ -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 -r 695a90e72e4f -r 8cabda8ae1c6 tests/test-sane-without-bookmarks --- a/tests/test-sane-without-bookmarks Tue May 19 09:33:46 2009 -0700 +++ b/tests/test-sane-without-bookmarks Tue May 19 09:40:54 2009 -0700 @@ -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