declare local constants instead of using magic values and comments
authorMads Kiilerich <mads@kiilerich.com>
Mon, 27 Aug 2012 23:16:22 +0200
changeset 17429 72fa4ef2245f
parent 17428 72803c8edaa4
child 17430 e841ecc03765
declare local constants instead of using magic values and comments
mercurial/archival.py
mercurial/obsolete.py
mercurial/pure/osutil.py
--- a/mercurial/archival.py	Mon Aug 27 23:14:27 2012 +0200
+++ b/mercurial/archival.py	Mon Aug 27 23:16:22 2012 +0200
@@ -13,6 +13,10 @@
 import cStringIO, os, tarfile, time, zipfile
 import zlib, gzip
 
+# from unzip source code:
+_UNX_IFREG = 0x8000
+_UNX_IFLNK = 0xa000
+
 def tidyprefix(dest, kind, prefix):
     '''choose prefix to use for names in archive.  make sure prefix is
     safe for consumers.'''
@@ -173,10 +177,10 @@
         # unzip will not honor unix file modes unless file creator is
         # set to unix (id 3).
         i.create_system = 3
-        ftype = 0x8000 # UNX_IFREG in unzip source code
+        ftype = _UNX_IFREG
         if islink:
             mode = 0777
-            ftype = 0xa000 # UNX_IFLNK in unzip source code
+            ftype = _UNX_IFLNK
         i.external_attr = (mode | ftype) << 16L
         self.z.writestr(i, data)
 
--- a/mercurial/obsolete.py	Mon Aug 27 23:14:27 2012 +0200
+++ b/mercurial/obsolete.py	Mon Aug 27 23:16:22 2012 +0200
@@ -58,6 +58,8 @@
 _pack = struct.pack
 _unpack = struct.unpack
 
+_SEEK_END = 2 # os.SEEK_END was introduced in Python 2.5
+
 # the obsolete feature is not mature enough to be enabled by default.
 # you have to rely on third party extension extension to enable this.
 _enabled = False
@@ -207,7 +209,7 @@
                 # defined. So we must seek to the end before calling tell(),
                 # or we may get a zero offset for non-zero sized files on
                 # some platforms (issue3543).
-                f.seek(0, 2) # os.SEEK_END
+                f.seek(0, _SEEK_END)
                 offset = f.tell()
                 transaction.add('obsstore', offset)
                 # offset == 0: new file - add the version header
--- a/mercurial/pure/osutil.py	Mon Aug 27 23:14:27 2012 +0200
+++ b/mercurial/pure/osutil.py	Mon Aug 27 23:16:22 2012 +0200
@@ -82,7 +82,7 @@
 
     _FILE_ATTRIBUTE_NORMAL = 0x80
 
-    # _open_osfhandle
+    # open_osfhandle flags
     _O_RDONLY = 0x0000
     _O_RDWR = 0x0002
     _O_APPEND = 0x0008