##// END OF EJS Templates
Merge with crew-stable
Bryan O'Sullivan -
r17629:331d6118 merge default
parent child Browse files
Show More
@@ -12,6 +12,7 b' import cmdutil'
12 import scmutil, util, encoding
12 import scmutil, util, encoding
13 import cStringIO, os, tarfile, time, zipfile
13 import cStringIO, os, tarfile, time, zipfile
14 import zlib, gzip
14 import zlib, gzip
15 import struct
15
16
16 # from unzip source code:
17 # from unzip source code:
17 _UNX_IFREG = 0x8000
18 _UNX_IFREG = 0x8000
@@ -169,6 +170,7 b' class zipit(object):'
169 if mtime < epoch:
170 if mtime < epoch:
170 mtime = epoch
171 mtime = epoch
171
172
173 self.mtime = mtime
172 self.date_time = time.gmtime(mtime)[:6]
174 self.date_time = time.gmtime(mtime)[:6]
173
175
174 def addfile(self, name, mode, islink, data):
176 def addfile(self, name, mode, islink, data):
@@ -182,6 +184,14 b' class zipit(object):'
182 mode = 0777
184 mode = 0777
183 ftype = _UNX_IFLNK
185 ftype = _UNX_IFLNK
184 i.external_attr = (mode | ftype) << 16L
186 i.external_attr = (mode | ftype) << 16L
187 # add "extended-timestamp" extra block, because zip archives
188 # without this will be extracted with unexpected timestamp,
189 # if TZ is not configured as GMT
190 i.extra += struct.pack('<hhBl',
191 0x5455, # block type: "extended-timestamp"
192 1 + 4, # size of this block
193 1, # "modification time is present"
194 self.mtime) # time of last modification (UTC)
185 self.z.writestr(i, data)
195 self.z.writestr(i, data)
186
196
187 def done(self):
197 def done(self):
@@ -270,3 +270,31 b' old file -- date clamped to 1980'
270 \s*147\s+2 files (re)
270 \s*147\s+2 files (re)
271
271
272 $ cd ..
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