# HG changeset patch # User Bryan O'Sullivan # Date 1348072731 25200 # Node ID 331d611813eca2098fdb75c741cb7f5cc72b6567 # Parent 84f12b832ee82e225d0f3d3e463f402f245637bd# Parent 133d13e445446e07ad2d62de6ebfda7a4df8348b Merge with crew-stable diff -r 84f12b832ee8 -r 331d611813ec mercurial/archival.py --- a/mercurial/archival.py Tue Sep 18 21:39:12 2012 +0900 +++ b/mercurial/archival.py Wed Sep 19 09:38:51 2012 -0700 @@ -12,6 +12,7 @@ import scmutil, util, encoding import cStringIO, os, tarfile, time, zipfile import zlib, gzip +import struct # from unzip source code: _UNX_IFREG = 0x8000 @@ -169,6 +170,7 @@ if mtime < epoch: mtime = epoch + self.mtime = mtime self.date_time = time.gmtime(mtime)[:6] def addfile(self, name, mode, islink, data): @@ -182,6 +184,14 @@ mode = 0777 ftype = _UNX_IFLNK i.external_attr = (mode | ftype) << 16L + # add "extended-timestamp" extra block, because zip archives + # without this will be extracted with unexpected timestamp, + # if TZ is not configured as GMT + i.extra += struct.pack(' repo/a + $ hg -R repo add repo/a + $ hg -R repo commit -m '#0' -d '456789012 21600' + $ cat > show_mtime.py < import sys, os + > print int(os.stat(sys.argv[1]).st_mtime) + > EOF + + $ hg -R repo archive --prefix tar-extracted archive.tar + $ (TZ=UTC-3; export TZ; tar xf archive.tar) + $ python show_mtime.py tar-extracted/a + 456789012 + + $ hg -R repo archive --prefix zip-extracted archive.zip + $ (TZ=UTC-3; export TZ; unzip -q archive.zip) + $ python show_mtime.py zip-extracted/a + 456789012 + + $ cd ..