Patchwork [03,of,18,V2] branchmap: ignore Abort error while writing cache

login
register
mail settings
Submitter Pierre-Yves David
Date Jan. 4, 2013, 1:04 a.m.
Message ID <3152faab1da3699af063.1357261446@yamac.lan>
Download mbox | patch
Permalink /patch/372/
State Accepted
Commit cd4c7520020691c992e23d2eb2781ce9a1d7037a
Headers show

Comments

Pierre-Yves David - Jan. 4, 2013, 1:04 a.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at ens-lyon.org>
# Date 1357260638 -3600
# Node ID 3152faab1da3699af0637d78e6b9b3b74a9e3fab
# Parent  f8a602bc30ba2903fcdf0d0a84c20c3f5c394ad3
branchmap: ignore Abort error while writing cache

Read only vfs can now raise Abort exception. Note that encoding.local are also a
possible raiser.
Kevin Bullock - Jan. 4, 2013, 3:31 a.m.
On 3 Jan 2013, at 7:04 PM, Pierre-Yves David wrote:

> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david at ens-lyon.org>
> # Date 1357260638 -3600
> # Node ID 3152faab1da3699af0637d78e6b9b3b74a9e3fab
> # Parent  f8a602bc30ba2903fcdf0d0a84c20c3f5c394ad3
> branchmap: ignore Abort error while writing cache
> 
> Read only vfs can now raise Abort exception. Note that encoding.local are also a
> possible raiser.
> 
> diff --git a/mercurial/branchmap.py b/mercurial/branchmap.py
> --- a/mercurial/branchmap.py
> +++ b/mercurial/branchmap.py
> @@ -129,19 +129,23 @@ class branchcache(dict):
> 
> 
>     def write(self, repo):
>         try:
>             f = repo.opener(_filename(repo), "w", atomictemp=True)
> +        except (IOError, OSError, util.Abort):
> +            return
> +        try:
>             cachekey = [hex(self.tipnode), str(self.tiprev)]
>             if self.filteredhash is not None:
>                 cachekey.append(hex(self.filteredhash))
>             f.write(" ".join(cachekey) + '\n')
>             for label, nodes in self.iteritems():
>                 for node in nodes:
>                     f.write("%s %s\n" % (hex(node), encoding.fromlocal(label)))
>             f.close()
> -        except (IOError, OSError):
> +        except (IOError, OSError, util.Abort):
> +            # Abort may be raise by read only opener
Misplaced comment -- looks like it should be on the other 'except:'.

pacem in terris / ??? / ?????? / ????????? / ??
Kevin R. Bullock
Kevin Bullock - Jan. 4, 2013, 4:47 a.m.
On 3 Jan 2013, at 9:31 PM, Kevin Bullock wrote:

> On 3 Jan 2013, at 7:04 PM, Pierre-Yves David wrote:
> 
>> # HG changeset patch
>> # User Pierre-Yves David <pierre-yves.david at ens-lyon.org>
>> # Date 1357260638 -3600
>> # Node ID 3152faab1da3699af0637d78e6b9b3b74a9e3fab
>> # Parent  f8a602bc30ba2903fcdf0d0a84c20c3f5c394ad3
>> branchmap: ignore Abort error while writing cache
>> 
>> Read only vfs can now raise Abort exception. Note that encoding.local are also a
>> possible raiser.
>> 
>> diff --git a/mercurial/branchmap.py b/mercurial/branchmap.py
>> --- a/mercurial/branchmap.py
>> +++ b/mercurial/branchmap.py
>> @@ -129,19 +129,23 @@ class branchcache(dict):
>> 
>> 
>>    def write(self, repo):
>>        try:
>>            f = repo.opener(_filename(repo), "w", atomictemp=True)
>> +        except (IOError, OSError, util.Abort):
>> +            return
>> +        try:
>>            cachekey = [hex(self.tipnode), str(self.tiprev)]
>>            if self.filteredhash is not None:
>>                cachekey.append(hex(self.filteredhash))
>>            f.write(" ".join(cachekey) + '\n')
>>            for label, nodes in self.iteritems():
>>                for node in nodes:
>>                    f.write("%s %s\n" % (hex(node), encoding.fromlocal(label)))
>>            f.close()
>> -        except (IOError, OSError):
>> +        except (IOError, OSError, util.Abort):
>> +            # Abort may be raise by read only opener
> Misplaced comment -- looks like it should be on the other 'except:'.

Per discussion on IRC, the first hunk shouldn't be there. Only the second 'except:' clause should be.

pacem in terris / ??? / ?????? / ????????? / ??
Kevin R. Bullock

Patch

diff --git a/mercurial/branchmap.py b/mercurial/branchmap.py
--- a/mercurial/branchmap.py
+++ b/mercurial/branchmap.py
@@ -129,19 +129,23 @@  class branchcache(dict):
 
 
     def write(self, repo):
         try:
             f = repo.opener(_filename(repo), "w", atomictemp=True)
+        except (IOError, OSError, util.Abort):
+            return
+        try:
             cachekey = [hex(self.tipnode), str(self.tiprev)]
             if self.filteredhash is not None:
                 cachekey.append(hex(self.filteredhash))
             f.write(" ".join(cachekey) + '\n')
             for label, nodes in self.iteritems():
                 for node in nodes:
                     f.write("%s %s\n" % (hex(node), encoding.fromlocal(label)))
             f.close()
-        except (IOError, OSError):
+        except (IOError, OSError, util.Abort):
+            # Abort may be raise by read only opener
             pass
 
     def update(self, repo, ctxgen):
         """Given a branchhead cache, self, that may have extra nodes or be
         missing heads, and a generator of nodes that are at least a superset of