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

login
register
mail settings
Submitter Matt Harbison
Date Jan. 10, 2015, 5:11 p.m.
Message ID <e9d437cd7fbe266643ea.1420909892@Envy>
Download mbox | patch
Permalink /patch/7427/
State Accepted
Commit 78f11e2f2b2853b4ce54e2f4b571570ebbf1ce44
Headers show

Comments

Matt Harbison - Jan. 10, 2015, 5:11 p.m.
# HG changeset patch
# User Matt Harbison <matt_harbison@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.
Augie Fackler - Jan. 12, 2015, 11:02 p.m.
On Sat, Jan 10, 2015 at 12:11:32PM -0500, Matt Harbison wrote:
> # HG changeset patch
> # User Matt Harbison <matt_harbison@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()

Queued, thanks.

>
> 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()
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel

Patch

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()