Show More
@@ -12,6 +12,7 b' import cmdutil' | |||
|
12 | 12 | import scmutil, util, encoding |
|
13 | 13 | import cStringIO, os, tarfile, time, zipfile |
|
14 | 14 | import zlib, gzip |
|
15 | import struct | |
|
15 | 16 | |
|
16 | 17 | def tidyprefix(dest, kind, prefix): |
|
17 | 18 | '''choose prefix to use for names in archive. make sure prefix is |
@@ -165,6 +166,7 b' class zipit(object):' | |||
|
165 | 166 | if mtime < epoch: |
|
166 | 167 | mtime = epoch |
|
167 | 168 | |
|
169 | self.mtime = mtime | |
|
168 | 170 | self.date_time = time.gmtime(mtime)[:6] |
|
169 | 171 | |
|
170 | 172 | def addfile(self, name, mode, islink, data): |
@@ -178,6 +180,14 b' class zipit(object):' | |||
|
178 | 180 | mode = 0777 |
|
179 | 181 | ftype = 0xa000 # UNX_IFLNK in unzip source code |
|
180 | 182 | i.external_attr = (mode | ftype) << 16L |
|
183 | # add "extended-timestamp" extra block, because zip archives | |
|
184 | # without this will be extracted with unexpected timestamp, | |
|
185 | # if TZ is not configured as GMT | |
|
186 | i.extra += struct.pack('<hhBl', | |
|
187 | 0x5455, # block type: "extended-timestamp" | |
|
188 | 1 + 4, # size of this block | |
|
189 | 1, # "modification time is present" | |
|
190 | self.mtime) # time of last modification (UTC) | |
|
181 | 191 | self.z.writestr(i, data) |
|
182 | 192 | |
|
183 | 193 | def done(self): |
@@ -270,3 +270,31 b' old file -- date clamped to 1980' | |||
|
270 | 270 | \s*147\s+2 files (re) |
|
271 | 271 | |
|
272 | 272 | $ cd .. |
|
273 | ||
|
274 | issue3600: check whether "hg archive" can create archive files which | |
|
275 | are extracted with expected timestamp, even though TZ is not | |
|
276 | configured as GMT. | |
|
277 | ||
|
278 | $ mkdir issue3600 | |
|
279 | $ cd issue3600 | |
|
280 | ||
|
281 | $ hg init repo | |
|
282 | $ echo a > repo/a | |
|
283 | $ hg -R repo add repo/a | |
|
284 | $ hg -R repo commit -m '#0' -d '456789012 21600' | |
|
285 | $ cat > show_mtime.py <<EOF | |
|
286 | > import sys, os | |
|
287 | > print int(os.stat(sys.argv[1]).st_mtime) | |
|
288 | > EOF | |
|
289 | ||
|
290 | $ hg -R repo archive --prefix tar-extracted archive.tar | |
|
291 | $ (TZ=UTC-3; export TZ; tar xf archive.tar) | |
|
292 | $ python show_mtime.py tar-extracted/a | |
|
293 | 456789012 | |
|
294 | ||
|
295 | $ hg -R repo archive --prefix zip-extracted archive.zip | |
|
296 | $ (TZ=UTC-3; export TZ; unzip -q archive.zip) | |
|
297 | $ python show_mtime.py zip-extracted/a | |
|
298 | 456789012 | |
|
299 | ||
|
300 | $ cd .. |
General Comments 0
You need to be logged in to leave comments.
Login now