##// END OF EJS Templates
convert: add config option to use the local time zone...
Julian Cowley -
r17974:337d728e default
parent child Browse files
Show More
@@ -191,6 +191,10 b' def convert(ui, src, dest=None, revmapfi'
191 191 branch indicated in the regex as the second parent of the
192 192 changeset. Default is ``{{mergefrombranch ([-\\w]+)}}``
193 193
194 :convert.localtimezone: use local time (as determined by the TZ
195 environment variable) for changeset date/times. The default
196 is False (use UTC).
197
194 198 :hook.cvslog: Specify a Python function to be called at the end of
195 199 gathering the CVS log. The function is passed a list with the
196 200 log entries, and can modify the entries in-place, or add or
@@ -231,6 +235,10 b' def convert(ui, src, dest=None, revmapfi'
231 235 :convert.svn.trunk: specify the name of the trunk branch. The
232 236 default is ``trunk``.
233 237
238 :convert.localtimezone: use local time (as determined by the TZ
239 environment variable) for changeset date/times. The default
240 is False (use UTC).
241
234 242 Source history can be retrieved starting at a specific revision,
235 243 instead of being integrally converted. Only single branch
236 244 conversions are supported.
@@ -5,7 +5,7 b''
5 5 # This software may be used and distributed according to the terms of the
6 6 # GNU General Public License version 2 or any later version.
7 7
8 import base64, errno, subprocess, os
8 import base64, errno, subprocess, os, datetime
9 9 import cPickle as pickle
10 10 from mercurial import util
11 11 from mercurial.i18n import _
@@ -446,3 +446,10 b' def parsesplicemap(path):'
446 446 if e.errno != errno.ENOENT:
447 447 raise
448 448 return m
449
450 def makedatetimestamp(t):
451 """Like util.makedate() but for time t instead of current time"""
452 delta = (datetime.datetime.utcfromtimestamp(t) -
453 datetime.datetime.fromtimestamp(t))
454 tz = delta.days * 86400 + delta.seconds
455 return t, tz
@@ -11,6 +11,7 b' from mercurial import encoding, util'
11 11 from mercurial.i18n import _
12 12
13 13 from common import NoRepo, commit, converter_source, checktool
14 from common import makedatetimestamp
14 15 import cvsps
15 16
16 17 class convert_cvs(converter_source):
@@ -70,6 +71,8 b' class convert_cvs(converter_source):'
70 71 cs.author = self.recode(cs.author)
71 72 self.lastbranch[cs.branch] = id
72 73 cs.comment = self.recode(cs.comment)
74 if self.ui.configbool('convert', 'localtimezone'):
75 cs.date = makedatetimestamp(cs.date[0])
73 76 date = util.datestr(cs.date, '%Y-%m-%d %H:%M:%S %1%2')
74 77 self.tags.update(dict.fromkeys(cs.tags, id))
75 78
@@ -18,6 +18,7 b' from cStringIO import StringIO'
18 18
19 19 from common import NoRepo, MissingTool, commit, encodeargs, decodeargs
20 20 from common import commandline, converter_source, converter_sink, mapfile
21 from common import makedatetimestamp
21 22
22 23 try:
23 24 from svn.core import SubversionException, Pool
@@ -802,6 +803,8 b' class svn_source(converter_source):'
802 803 # ISO-8601 conformant
803 804 # '2007-01-04T17:35:00.902377Z'
804 805 date = util.parsedate(date[:19] + " UTC", ["%Y-%m-%dT%H:%M:%S"])
806 if self.ui.configbool('convert', 'localtimezone'):
807 date = makedatetimestamp(date[0])
805 808
806 809 log = message and self.recode(message) or ''
807 810 author = author and self.recode(author) or ''
@@ -69,9 +69,16 b' commit a new revision changing b/c'
69 69 $TESTTMP/cvsrepo/src/b/c,v <-- *c (glob)
70 70 $ cd ..
71 71
72 convert fresh repo
72 convert fresh repo and also check localtimezone option
73
74 NOTE: This doesn't check all time zones -- it merely determines that
75 the configuration option is taking effect.
73 76
74 $ hg convert src src-hg
77 An arbitrary (U.S.) time zone is used here. TZ=US/Hawaii is selected
78 since it does not use DST (unlike other U.S. time zones) and is always
79 a fixed difference from UTC.
80
81 $ TZ=US/Hawaii hg convert --config convert.localtimezone=True src src-hg
75 82 initializing destination src-hg repository
76 83 connecting to $TESTTMP/cvsrepo
77 84 scanning source...
@@ -161,7 +168,7 b' commit new file revisions'
161 168
162 169 convert again
163 170
164 $ hg convert src src-hg
171 $ TZ=US/Hawaii hg convert --config convert.localtimezone=True src src-hg
165 172 connecting to $TESTTMP/cvsrepo
166 173 scanning source...
167 174 collecting CVS rlog
@@ -221,7 +228,7 b' commit branch'
221 228
222 229 convert again
223 230
224 $ hg convert src src-hg
231 $ TZ=US/Hawaii hg convert --config convert.localtimezone=True src src-hg
225 232 connecting to $TESTTMP/cvsrepo
226 233 scanning source...
227 234 collecting CVS rlog
@@ -239,7 +246,7 b' convert again'
239 246
240 247 convert again with --filemap
241 248
242 $ hg convert --filemap filemap src src-filemap
249 $ TZ=US/Hawaii hg convert --config convert.localtimezone=True --filemap filemap src src-filemap
243 250 connecting to $TESTTMP/cvsrepo
244 251 scanning source...
245 252 collecting CVS rlog
@@ -286,7 +293,7 b' commit new file revisions with some fuzz'
286 293
287 294 convert again
288 295
289 $ hg convert --config convert.cvsps.fuzz=2 src src-hg
296 $ TZ=US/Hawaii hg convert --config convert.cvsps.fuzz=2 --config convert.localtimezone=True src src-hg
290 297 connecting to $TESTTMP/cvsrepo
291 298 scanning source...
292 299 collecting CVS rlog
@@ -300,25 +307,25 b' convert again'
300 307 2 funny
301 308 1 fuzzy
302 309 0 fuzzy
303 $ hg -R src-hg glog --template '{rev} ({branches}) {desc} files: {files}\n'
304 o 8 (branch) fuzzy files: b/c
310 $ hg -R src-hg glog --template '{rev} ({branches}) {desc} date: {date|date} files: {files}\n'
311 o 8 (branch) fuzzy date: * -1000 files: b/c (glob)
305 312 |
306 o 7 (branch) fuzzy files: a
313 o 7 (branch) fuzzy date: * -1000 files: a (glob)
307 314 |
308 315 o 6 (branch) funny
309 316 | ----------------------------
310 | log message files: a
311 o 5 (branch) ci2 files: b/c
317 | log message date: * -1000 files: a (glob)
318 o 5 (branch) ci2 date: * -1000 files: b/c (glob)
312 319
313 o 4 () ci1 files: a b/c
320 o 4 () ci1 date: * -1000 files: a b/c (glob)
314 321 |
315 o 3 () update tags files: .hgtags
322 o 3 () update tags date: * +0000 files: .hgtags (glob)
316 323 |
317 o 2 () ci0 files: b/c
324 o 2 () ci0 date: * -1000 files: b/c (glob)
318 325 |
319 | o 1 (INITIAL) import files:
326 | o 1 (INITIAL) import date: * -1000 files: (glob)
320 327 |/
321 o 0 () Initial revision files: a b/c
328 o 0 () Initial revision date: * -1000 files: a b/c (glob)
322 329
323 330
324 331 testing debugcvsps
@@ -63,9 +63,16 b' Update svn repository'
63 63 Committed revision 5.
64 64 $ cd ..
65 65
66 Convert to hg once
66 Convert to hg once and also test localtimezone option
67
68 NOTE: This doesn't check all time zones -- it merely determines that
69 the configuration option is taking effect.
67 70
68 $ hg convert "$SVNREPOURL/proj%20B" B-hg
71 An arbitrary (U.S.) time zone is used here. TZ=US/Hawaii is selected
72 since it does not use DST (unlike other U.S. time zones) and is always
73 a fixed difference from UTC.
74
75 $ TZ=US/Hawaii hg convert --config convert.localtimezone=True "$SVNREPOURL/proj%20B" B-hg
69 76 initializing destination B-hg repository
70 77 scanning source...
71 78 sorting...
@@ -109,7 +116,7 b' Update svn repository again'
109 116
110 117 Test incremental conversion
111 118
112 $ hg convert "$SVNREPOURL/proj%20B" B-hg
119 $ TZ=US/Hawaii hg convert --config convert.localtimezone=True "$SVNREPOURL/proj%20B" B-hg
113 120 scanning source...
114 121 sorting...
115 122 converting...
@@ -118,22 +125,22 b' Test incremental conversion'
118 125 updating tags
119 126
120 127 $ cd B-hg
121 $ hg glog --template '{rev} {desc|firstline} files: {files}\n'
122 o 7 update tags files: .hgtags
128 $ hg glog --template '{rev} {desc|firstline} date: {date|date} files: {files}\n'
129 o 7 update tags date: * +0000 files: .hgtags (glob)
123 130 |
124 o 6 work in progress files: letter2.txt
131 o 6 work in progress date: * -1000 files: letter2.txt (glob)
125 132 |
126 o 5 second letter files: letter .txt letter2.txt
133 o 5 second letter date: * -1000 files: letter .txt letter2.txt (glob)
127 134 |
128 o 4 update tags files: .hgtags
135 o 4 update tags date: * +0000 files: .hgtags (glob)
129 136 |
130 o 3 nice day files: letter .txt
137 o 3 nice day date: * -1000 files: letter .txt (glob)
131 138 |
132 o 2 world files: letter .txt
139 o 2 world date: * -1000 files: letter .txt (glob)
133 140 |
134 o 1 hello files: letter .txt
141 o 1 hello date: * -1000 files: letter .txt (glob)
135 142 |
136 o 0 init projB files:
143 o 0 init projB date: * -1000 files: (glob)
137 144
138 145 $ hg tags -q
139 146 tip
@@ -172,6 +172,10 b''
172 172 will add the most recent revision on the branch indicated in
173 173 the regex as the second parent of the changeset. Default is
174 174 "{{mergefrombranch ([-\w]+)}}"
175 convert.localtimezone
176 use local time (as determined by the TZ environment
177 variable) for changeset date/times. The default is False
178 (use UTC).
175 179 hook.cvslog Specify a Python function to be called at the end of
176 180 gathering the CVS log. The function is passed a list with
177 181 the log entries, and can modify the entries in-place, or add
@@ -211,6 +215,10 b''
211 215 convert.svn.trunk
212 216 specify the name of the trunk branch. The default is
213 217 "trunk".
218 convert.localtimezone
219 use local time (as determined by the TZ environment
220 variable) for changeset date/times. The default is False
221 (use UTC).
214 222
215 223 Source history can be retrieved starting at a specific revision, instead
216 224 of being integrally converted. Only single branch conversions are
General Comments 0
You need to be logged in to leave comments. Login now