[PATCH] convert/bzr: handle Bazaar timestamps correctly (issue1652)
Greg Ward
greg-hg at gerg.ca
Wed May 6 16:49:20 CDT 2009
# HG changeset patch
# User Greg Ward <greg-hg at gerg.ca>
# Date 1241646483 14400
# Node ID 15ff29cd23bfc0ad1113d0be00378abdebb0aa57
# Parent b0ce2595777bddf8d4a62119e3a2dfb8ca0078b4
convert/bzr: handle Bazaar timestamps correctly (issue1652).
diff --git a/hgext/convert/bzr.py b/hgext/convert/bzr.py
--- a/hgext/convert/bzr.py
+++ b/hgext/convert/bzr.py
@@ -110,8 +110,7 @@
self._parentids[version] = parents
return commit(parents=parents,
- # bzr uses 1 second timezone precision
- date='%d %d' % (rev.timestamp, rev.timezone / 3600),
+ date='%d %d' % (rev.timestamp, -rev.timezone),
author=self.recode(rev.committer),
# bzr returns bytestrings or unicode, depending on the content
desc=self.recode(rev.message),
diff --git a/tests/test-convert-bzr b/tests/test-convert-bzr
--- a/tests/test-convert-bzr
+++ b/tests/test-convert-bzr
@@ -33,6 +33,26 @@
EOF
hg convert --filemap filemap source source-filemap-hg
hg -R source-filemap-hg manifest -r tip
+
+# extract timestamps that look just like hg's {date|isodate}:
+# yyyy-mm-dd HH:MM zzzz (no seconds!)
+echo "% compare timestamps"
+cd source
+bzr log | \
+ awk -F'[ :]' '$1 == "timestamp" { printf "%s %s:%s %s\n", $4, $5, $6, $8 }' \
+ > ../bzr-timestamps
+cd ..
+
+hg -R source-hg log --template "{date|isodate}\n" > hg-timestamps
+if diff -q bzr-timestamps hg-timestamps ; then
+ echo "good: hg timestamps match bzr timestamps"
+else
+ echo "fail: bzr timestamps are:"
+ cat bzr-timestamps
+ echo "but hg timestamps are:"
+ cat hg-timestamps
+fi
+
cd ..
echo % merge
diff --git a/tests/test-convert-bzr.out b/tests/test-convert-bzr.out
--- a/tests/test-convert-bzr.out
+++ b/tests/test-convert-bzr.out
@@ -35,6 +35,8 @@
b
d
f
+% compare timestamps
+good: hg timestamps match bzr timestamps
% merge
initializing destination source-hg repository
scanning source...
More information about the Mercurial-devel
mailing list