[PATCH] branchmap: add seek() to end of file before calling tell() on append open()

Matt Harbison mharbison72 at gmail.com
Sat Jan 10 17:11:32 UTC 2015


# HG changeset patch
# User Matt Harbison <matt_harbison at yahoo.com>
# Date 1420909203 18000
#      Sat Jan 10 12:00:03 2015 -0500
# Node ID e9d437cd7fbe266643ea7b91705a7f1cdd7a419a
# Parent  db833be29c538f95ecf4972aef602cc03a7d4d81
branchmap: add seek() to end of file before calling tell() on append open()

This is similar to 48c232873a54, which was subsequently modified in 19f5dec2d61f
for 2.4.  Unexpected test changes on Windows occurred without this.

diff --git a/mercurial/branchmap.py b/mercurial/branchmap.py
--- a/mercurial/branchmap.py
+++ b/mercurial/branchmap.py
@@ -407,6 +407,9 @@
             try:
                 if self._rbcnamescount != 0:
                     f = repo.vfs.open(_rbcnames, 'ab')
+                    # The position after open(x, 'a') is implementation defined-
+                    # see issue3543.  SEEK_END was added in 2.5
+                    f.seek(0, 2) #os.SEEK_END
                     if f.tell() == self._rbcsnameslen:
                         f.write('\0')
                     else:
@@ -431,6 +434,9 @@
                                    len(self._rbcrevs) // _rbcrecsize)
             try:
                 f = repo.vfs.open(_rbcrevs, 'ab')
+                # The position after open(x, 'a') is implementation defined-
+                # see issue3543.  SEEK_END was added in 2.5
+                f.seek(0, 2) #os.SEEK_END
                 if f.tell() != start:
                     f.seek(start)
                     f.truncate()


More information about the Mercurial-devel mailing list