Skip to content

Commit a042822

Browse files
committed
merge from beejahth
2 parents a365d0f + 50e9404 commit a042822

File tree

5 files changed

+18
-10
lines changed

5 files changed

+18
-10
lines changed

dulwich/objects.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -479,15 +479,19 @@ def as_pretty_string(self):
479479

480480
def parse_timezone(text):
481481
offset = int(text)
482+
signum = (offset < 0) and -1 or 1
483+
offset = abs(offset)
482484
hours = int(offset / 100)
483485
minutes = (offset % 100)
484-
return (hours * 3600) + (minutes * 60)
486+
return signum * (hours * 3600 + minutes * 60)
485487

486488

487489
def format_timezone(offset):
488490
if offset % 60 != 0:
489491
raise ValueError("Unable to handle non-minute offset.")
490-
return '%+03d%02d' % (offset / 3600, (offset / 60) % 60)
492+
sign = (offset < 0) and '-' or '+'
493+
offset = abs(offset)
494+
return '%c%02d%02d' % (sign, offset / 3600, (offset / 60) % 60)
491495

492496

493497
class Commit(ShaFile):

git_handler.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
ShaFile,
1414
Tag,
1515
Tree,
16-
hex_to_sha
16+
hex_to_sha,
17+
format_timezone,
1718
)
1819

1920
import math
@@ -230,13 +231,16 @@ def export_hg_commit(self, rev):
230231
author = ctx.user()
231232
if not '>' in author: # TODO : this kills losslessness - die (submodules)?
232233
author = author + ' <none@none>'
233-
commit['author'] = author + ' ' + str(int(time)) + ' ' + seconds_to_offset(timezone)
234+
commit['author'] = author + ' ' + str(int(time)) + ' ' + format_timezone(-timezone)
234235
message = ctx.description()
235236
commit['message'] = ctx.description() + "\n"
236237

237238
extra = ctx.extra()
238239
if 'committer' in extra:
239-
commit['committer'] = extra['committer']
240+
# fixup timezone
241+
(name_timestamp, timezone) = extra['committer'].rsplit(' ', 1)
242+
timezone = format_timezone(-int(timezone))
243+
commit['committer'] = '%s %s' % (name_timestamp, timezone)
240244
if 'encoding' in extra:
241245
commit['encoding'] = extra['encoding']
242246

@@ -623,7 +627,7 @@ def getfilectx(repo, memctx, f):
623627

624628
# if committer is different than author, add it to extra
625629
if not commit._author_raw == commit._committer_raw:
626-
extra['committer'] = commit._committer_raw
630+
extra['committer'] = "%s %d %d" % (commit.committer, commit.commit_time, -commit.commit_timezone)
627631

628632
if commit._encoding:
629633
extra['encoding'] = commit._encoding
@@ -632,7 +636,7 @@ def getfilectx(repo, memctx, f):
632636
extra['branch'] = hg_branch
633637

634638
text = strip_message
635-
date = datetime.datetime.fromtimestamp(commit.author_time).strftime("%Y-%m-%d %H:%M:%S")
639+
date = (commit.author_time, -commit.author_timezone)
636640
ctx = context.memctx(self.repo, (p1, p2), text, files, getfilectx,
637641
commit.author, date, extra)
638642
a = self.repo.commitctx(ctx)

tests/test-file-removal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# "$TESTDIR/hghave" git || exit 80
55

66
# bail early if the user is already running git-daemon
7-
echo hi | nc localhost 9418 && exit 80
7+
echo hi | nc localhost 9418 2>/dev/null && exit 80
88

99
echo "[extensions]" >> $HGRCPATH
1010
echo "hggit=$(echo $(dirname $(dirname $0)))" >> $HGRCPATH

tests/test-git-clone

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# "$TESTDIR/hghave" git || exit 80
55

66
# bail early if the user is already running git-daemon
7-
echo hi | nc localhost 9418 && exit 80
7+
echo hi | nc localhost 9418 2>/dev/null && exit 80
88

99
echo "[extensions]" >> $HGRCPATH
1010
echo "hggit=$(echo $(dirname $(dirname $0)))" >> $HGRCPATH

tests/test-sane-without-bookmarks

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# "$TESTDIR/hghave" git || exit 80
55

66
# bail early if the user is already running git-daemon
7-
echo hi | nc localhost 9418 && exit 80
7+
echo hi | nc localhost 9418 2>/dev/null && exit 80
88

99
echo "[extensions]" >> $HGRCPATH
1010
echo "hggit=$(echo $(dirname $(dirname $0)))" >> $HGRCPATH

0 commit comments

Comments
 (0)