comparison mercurial/obsolete.py @ 17429:72fa4ef2245f

declare local constants instead of using magic values and comments
author Mads Kiilerich <mads@kiilerich.com>
date Mon, 27 Aug 2012 23:16:22 +0200
parents 9724f8f8850b
children fb72eec7efd8
comparison
equal deleted inserted replaced
17428:72803c8edaa4 17429:72fa4ef2245f
55 import util, base85 55 import util, base85
56 from i18n import _ 56 from i18n import _
57 57
58 _pack = struct.pack 58 _pack = struct.pack
59 _unpack = struct.unpack 59 _unpack = struct.unpack
60
61 _SEEK_END = 2 # os.SEEK_END was introduced in Python 2.5
60 62
61 # the obsolete feature is not mature enough to be enabled by default. 63 # the obsolete feature is not mature enough to be enabled by default.
62 # you have to rely on third party extension extension to enable this. 64 # you have to rely on third party extension extension to enable this.
63 _enabled = False 65 _enabled = False
64 66
205 # Whether the file's current position is at the begin or at 207 # Whether the file's current position is at the begin or at
206 # the end after opening a file for appending is implementation 208 # the end after opening a file for appending is implementation
207 # defined. So we must seek to the end before calling tell(), 209 # defined. So we must seek to the end before calling tell(),
208 # or we may get a zero offset for non-zero sized files on 210 # or we may get a zero offset for non-zero sized files on
209 # some platforms (issue3543). 211 # some platforms (issue3543).
210 f.seek(0, 2) # os.SEEK_END 212 f.seek(0, _SEEK_END)
211 offset = f.tell() 213 offset = f.tell()
212 transaction.add('obsstore', offset) 214 transaction.add('obsstore', offset)
213 # offset == 0: new file - add the version header 215 # offset == 0: new file - add the version header
214 for bytes in _encodemarkers(new, offset == 0): 216 for bytes in _encodemarkers(new, offset == 0):
215 f.write(bytes) 217 f.write(bytes)