Patchwork [2,of,3,V2] statichttprepo: use LockUnavailable() instead of Abort() for lock (API)

login
register
mail settings
Submitter Pulkit Goyal
Date Sept. 10, 2020, 8:08 a.m.
Message ID <2236c304b8ad360333ee.1599725289@workspace>
Download mbox | patch
Permalink /patch/47122/
State Accepted
Headers show

Comments

Pulkit Goyal - Sept. 10, 2020, 8:08 a.m.
# HG changeset patch
# User Pulkit Goyal <7895pulkit@gmail.com>
# Date 1599725255 -19800
#      Thu Sep 10 13:37:35 2020 +0530
# Node ID 2236c304b8ad360333ee125aa777316628d1e3d5
# Parent  5ecbecdc0aa49eb6a3878e01f8aa99417602b957
# EXP-Topic tags-fix
statichttprepo: use LockUnavailable() instead of Abort() for lock (API)

If we try to get a lock on statichttprepo, we get `error.Abort()` instead of
subclass of `error.LockError()`. The callers which catches `error.LockError`
fails to catch this case as the correct error is not raised.

Raising `error.LockUnavaible()` is same as what is done for wlock also.

Patch

diff --git a/mercurial/statichttprepo.py b/mercurial/statichttprepo.py
--- a/mercurial/statichttprepo.py
+++ b/mercurial/statichttprepo.py
@@ -238,7 +238,12 @@  class statichttprepository(
         )
 
     def lock(self, wait=True):
-        raise error.Abort(_(b'cannot lock static-http repository'))
+        raise error.LockUnavailable(
+            0,
+            _(b'lock not available'),
+            b'lock',
+            _(b'cannot lock static-http repository'),
+        )
 
     def _writecaches(self):
         pass  # statichttprepository are read only