[Bug 3543] New: tell() after open(..., 'ab') returns zero for non-zero sized files on Windows
bugzilla-daemon at bz.selenic.com
bugzilla-daemon at bz.selenic.com
Sun Jul 15 17:10:23 CDT 2012
http://bz.selenic.com/show_bug.cgi?id=3543
Priority: normal
Bug ID: 3543
CC: mercurial-devel at selenic.com,
pierre-yves.david at logilab.fr
Assignee: bugzilla at selenic.com
Summary: tell() after open(..., 'ab') returns zero for non-zero
sized files on Windows
Severity: bug
Classification: Unclassified
OS: Windows
Reporter: adrian at cadifra.com
Hardware: PC
Status: UNCONFIRMED
Version: unspecified
Component: Mercurial
Product: Mercurial
http://selenic.com/repo/hg/rev/95d785ccb4e5 (not yet released) is the first
change that makes the following
test failure appear:
--- C:\Users\adi\hgrepos\hg-main\tests\test-obsolete.t
+++ C:\Users\adi\hgrepos\hg-main\tests\test-obsolete.t.err
@@ -43,8 +43,8 @@
created new head
$ hg debugobsolete -d '1337 0' `getid new_c` `getid new_2_c`
$ hg debugobsolete
- 245bde4270cd1072a27757984f9cda8ba26f08ca
cdbce2fbb16313928851e97e0d85413f3f7eb77f 0 {'date': '56 12', 'user': 'test'}
- cdbce2fbb16313928851e97e0d85413f3f7eb77f
ca819180edb99ed25ceafb3e9584ac287e240b00 0 {'date': '1337 0', 'user': 'test'}
+ abort: parsing obsolete marker: metadata is too short, 42 bytes expected,
got 16777216
+ [255]
See also
http://hgbuildbot.kublai.com/builders/Windows%202008%20R2%20hg%20tests/builds/148/steps/run-tests.py%20%28python2.6%29/logs/stdio
Further analysis reveals that f.tell() after f = open(..., 'ab') returns 0L for
non-zero sized
files on Windows (seen on Windows 7 x64 with x64 Python 2.7.3).
A quick and dirty local hack that fixes this here is:
diff --git a/mercurial/obsolete.py b/mercurial/obsolete.py
--- a/mercurial/obsolete.py
+++ b/mercurial/obsolete.py
@@ -51,7 +51,7 @@
additional encoding. Keys cannot contain '\0' or ':' and values
cannot contain '\0'.
"""
-import struct
+import struct, os
from mercurial import util, base85
from i18n import _
@@ -194,6 +194,7 @@
"""Add a new marker to the store"""
if marker not in self._all:
f = self.sopener('obsstore', 'ab')
+ f.seek(0, os.SEEK_END)
try:
offset = f.tell()
transaction.add('obsstore', offset)
But this probably requires a more proper workaround in a lower layer of
Mercurial.
--
You are receiving this mail because:
You are on the CC list for the bug.
More information about the Mercurial-devel
mailing list