[PATCH] archive: use hardcoded constants when creating .zip archives

Markus F.X.J. Oberhumer markus at oberhumer.com
Wed Mar 16 17:58:26 CDT 2011


# HG changeset patch
# User Markus F.X.J. Oberhumer <markus at oberhumer.com>
# Date 1300316095 -3600
# Node ID 0ed7191e536db675eec5eff19f75f205c2139977
# Parent  d16c99f16f00d68ca79e3a383335bc866a8c409f
archive: use hardcoded constants when creating .zip archives

Do not rely on local stat constants, which may differ.

diff --git a/mercurial/archival.py b/mercurial/archival.py
--- a/mercurial/archival.py
+++ b/mercurial/archival.py
@@ -9,7 +9,7 @@
 from node import hex
 import cmdutil
 import util, encoding
-import cStringIO, os, stat, tarfile, time, zipfile
+import cStringIO, os, tarfile, time, zipfile
 import zlib, gzip
 
 def tidyprefix(dest, kind, prefix):
@@ -172,10 +172,10 @@
         # unzip will not honor unix file modes unless file creator is
         # set to unix (id 3).
         i.create_system = 3
-        ftype = stat.S_IFREG
+        ftype = 0x8000 # UNX_IFREG in unzip source code
         if islink:
             mode = 0777
-            ftype = stat.S_IFLNK
+            ftype = 0xa000 # UNX_IFLNK in unzip source code
         i.external_attr = (mode | ftype) << 16L
         self.z.writestr(i, data)
 


More information about the Mercurial-devel mailing list