##// 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 branch indicated in the regex as the second parent of the
191 branch indicated in the regex as the second parent of the
192 changeset. Default is ``{{mergefrombranch ([-\\w]+)}}``
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 :hook.cvslog: Specify a Python function to be called at the end of
198 :hook.cvslog: Specify a Python function to be called at the end of
195 gathering the CVS log. The function is passed a list with the
199 gathering the CVS log. The function is passed a list with the
196 log entries, and can modify the entries in-place, or add or
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 :convert.svn.trunk: specify the name of the trunk branch. The
235 :convert.svn.trunk: specify the name of the trunk branch. The
232 default is ``trunk``.
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 Source history can be retrieved starting at a specific revision,
242 Source history can be retrieved starting at a specific revision,
235 instead of being integrally converted. Only single branch
243 instead of being integrally converted. Only single branch
236 conversions are supported.
244 conversions are supported.
@@ -5,7 +5,7 b''
5 # This software may be used and distributed according to the terms of the
5 # This software may be used and distributed according to the terms of the
6 # GNU General Public License version 2 or any later version.
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 import cPickle as pickle
9 import cPickle as pickle
10 from mercurial import util
10 from mercurial import util
11 from mercurial.i18n import _
11 from mercurial.i18n import _
@@ -446,3 +446,10 b' def parsesplicemap(path):'
446 if e.errno != errno.ENOENT:
446 if e.errno != errno.ENOENT:
447 raise
447 raise
448 return m
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 from mercurial.i18n import _
11 from mercurial.i18n import _
12
12
13 from common import NoRepo, commit, converter_source, checktool
13 from common import NoRepo, commit, converter_source, checktool
14 from common import makedatetimestamp
14 import cvsps
15 import cvsps
15
16
16 class convert_cvs(converter_source):
17 class convert_cvs(converter_source):
@@ -70,6 +71,8 b' class convert_cvs(converter_source):'
70 cs.author = self.recode(cs.author)
71 cs.author = self.recode(cs.author)
71 self.lastbranch[cs.branch] = id
72 self.lastbranch[cs.branch] = id
72 cs.comment = self.recode(cs.comment)
73 cs.comment = self.recode(cs.comment)
74 if self.ui.configbool('convert', 'localtimezone'):
75 cs.date = makedatetimestamp(cs.date[0])
73 date = util.datestr(cs.date, '%Y-%m-%d %H:%M:%S %1%2')
76 date = util.datestr(cs.date, '%Y-%m-%d %H:%M:%S %1%2')
74 self.tags.update(dict.fromkeys(cs.tags, id))
77 self.tags.update(dict.fromkeys(cs.tags, id))
75
78
@@ -18,6 +18,7 b' from cStringIO import StringIO'
18
18
19 from common import NoRepo, MissingTool, commit, encodeargs, decodeargs
19 from common import NoRepo, MissingTool, commit, encodeargs, decodeargs
20 from common import commandline, converter_source, converter_sink, mapfile
20 from common import commandline, converter_source, converter_sink, mapfile
21 from common import makedatetimestamp
21
22
22 try:
23 try:
23 from svn.core import SubversionException, Pool
24 from svn.core import SubversionException, Pool
@@ -802,6 +803,8 b' class svn_source(converter_source):'
802 # ISO-8601 conformant
803 # ISO-8601 conformant
803 # '2007-01-04T17:35:00.902377Z'
804 # '2007-01-04T17:35:00.902377Z'
804 date = util.parsedate(date[:19] + " UTC", ["%Y-%m-%dT%H:%M:%S"])
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 log = message and self.recode(message) or ''
809 log = message and self.recode(message) or ''
807 author = author and self.recode(author) or ''
810 author = author and self.recode(author) or ''
@@ -69,9 +69,16 b' commit a new revision changing b/c'
69 $TESTTMP/cvsrepo/src/b/c,v <-- *c (glob)
69 $TESTTMP/cvsrepo/src/b/c,v <-- *c (glob)
70 $ cd ..
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 initializing destination src-hg repository
82 initializing destination src-hg repository
76 connecting to $TESTTMP/cvsrepo
83 connecting to $TESTTMP/cvsrepo
77 scanning source...
84 scanning source...
@@ -161,7 +168,7 b' commit new file revisions'
161
168
162 convert again
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 connecting to $TESTTMP/cvsrepo
172 connecting to $TESTTMP/cvsrepo
166 scanning source...
173 scanning source...
167 collecting CVS rlog
174 collecting CVS rlog
@@ -221,7 +228,7 b' commit branch'
221
228
222 convert again
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 connecting to $TESTTMP/cvsrepo
232 connecting to $TESTTMP/cvsrepo
226 scanning source...
233 scanning source...
227 collecting CVS rlog
234 collecting CVS rlog
@@ -239,7 +246,7 b' convert again'
239
246
240 convert again with --filemap
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 connecting to $TESTTMP/cvsrepo
250 connecting to $TESTTMP/cvsrepo
244 scanning source...
251 scanning source...
245 collecting CVS rlog
252 collecting CVS rlog
@@ -286,7 +293,7 b' commit new file revisions with some fuzz'
286
293
287 convert again
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 connecting to $TESTTMP/cvsrepo
297 connecting to $TESTTMP/cvsrepo
291 scanning source...
298 scanning source...
292 collecting CVS rlog
299 collecting CVS rlog
@@ -300,25 +307,25 b' convert again'
300 2 funny
307 2 funny
301 1 fuzzy
308 1 fuzzy
302 0 fuzzy
309 0 fuzzy
303 $ hg -R src-hg glog --template '{rev} ({branches}) {desc} files: {files}\n'
310 $ hg -R src-hg glog --template '{rev} ({branches}) {desc} date: {date|date} files: {files}\n'
304 o 8 (branch) fuzzy files: b/c
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 o 6 (branch) funny
315 o 6 (branch) funny
309 | ----------------------------
316 | ----------------------------
310 | log message files: a
317 | log message date: * -1000 files: a (glob)
311 o 5 (branch) ci2 files: b/c
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 testing debugcvsps
331 testing debugcvsps
@@ -63,9 +63,16 b' Update svn repository'
63 Committed revision 5.
63 Committed revision 5.
64 $ cd ..
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 initializing destination B-hg repository
76 initializing destination B-hg repository
70 scanning source...
77 scanning source...
71 sorting...
78 sorting...
@@ -109,7 +116,7 b' Update svn repository again'
109
116
110 Test incremental conversion
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 scanning source...
120 scanning source...
114 sorting...
121 sorting...
115 converting...
122 converting...
@@ -118,22 +125,22 b' Test incremental conversion'
118 updating tags
125 updating tags
119
126
120 $ cd B-hg
127 $ cd B-hg
121 $ hg glog --template '{rev} {desc|firstline} files: {files}\n'
128 $ hg glog --template '{rev} {desc|firstline} date: {date|date} files: {files}\n'
122 o 7 update tags files: .hgtags
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 $ hg tags -q
145 $ hg tags -q
139 tip
146 tip
@@ -172,6 +172,10 b''
172 will add the most recent revision on the branch indicated in
172 will add the most recent revision on the branch indicated in
173 the regex as the second parent of the changeset. Default is
173 the regex as the second parent of the changeset. Default is
174 "{{mergefrombranch ([-\w]+)}}"
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 hook.cvslog Specify a Python function to be called at the end of
179 hook.cvslog Specify a Python function to be called at the end of
176 gathering the CVS log. The function is passed a list with
180 gathering the CVS log. The function is passed a list with
177 the log entries, and can modify the entries in-place, or add
181 the log entries, and can modify the entries in-place, or add
@@ -211,6 +215,10 b''
211 convert.svn.trunk
215 convert.svn.trunk
212 specify the name of the trunk branch. The default is
216 specify the name of the trunk branch. The default is
213 "trunk".
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 Source history can be retrieved starting at a specific revision, instead
223 Source history can be retrieved starting at a specific revision, instead
216 of being integrally converted. Only single branch conversions are
224 of being integrally converted. Only single branch conversions are
General Comments 0
You need to be logged in to leave comments. Login now