Patchwork patch: add close() to abstractbackend

login
register
mail settings
Submitter via Mercurial-devel
Date June 30, 2017, 4:14 p.m.
Message ID <7a87ec7bcd672d0aa917.1498839290@martinvonz.svl.corp.google.com>
Download mbox | patch
Permalink /patch/21852/
State Accepted
Headers show

Comments

via Mercurial-devel - June 30, 2017, 4:14 p.m.
# HG changeset patch
# User Martin von Zweigbergk <martinvonz@google.com>
# Date 1498838844 25200
#      Fri Jun 30 09:07:24 2017 -0700
# Node ID 7a87ec7bcd672d0aa9178d9d87a7c8433241e5d3
# Parent  40ee74bfa11122a0a3ab74186f5056243b84af89
patch: add close() to abstractbackend

patchbackend() seems to call it on an arbitrary backend, so it seems
to be part of the API. Since all subclasses do something in their
close() methods, I decided to let this one raise an exception rather
than just pass.
Jun Wu - June 30, 2017, 6:26 p.m.
LGTM.

Excerpts from Martin von Zweigbergk's message of 2017-06-30 09:14:50 -0700:
> # HG changeset patch
> # User Martin von Zweigbergk <martinvonz@google.com>
> # Date 1498838844 25200
> #      Fri Jun 30 09:07:24 2017 -0700
> # Node ID 7a87ec7bcd672d0aa9178d9d87a7c8433241e5d3
> # Parent  40ee74bfa11122a0a3ab74186f5056243b84af89
> patch: add close() to abstractbackend
> 
> patchbackend() seems to call it on an arbitrary backend, so it seems
> to be part of the API. Since all subclasses do something in their
> close() methods, I decided to let this one raise an exception rather
> than just pass.
> 
> diff --git a/mercurial/patch.py b/mercurial/patch.py
> --- a/mercurial/patch.py
> +++ b/mercurial/patch.py
> @@ -448,6 +448,9 @@
>      def exists(self, fname):
>          raise NotImplementedError
>  
> +    def close(self):
> +        raise NotImplementedError
> +
>  class fsbackend(abstractbackend):
>      def __init__(self, ui, basedir):
>          super(fsbackend, self).__init__(ui)
Yuya Nishihara - July 1, 2017, 1:34 a.m.
On Fri, 30 Jun 2017 09:14:50 -0700, Martin von Zweigbergk via Mercurial-devel wrote:
> # HG changeset patch
> # User Martin von Zweigbergk <martinvonz@google.com>
> # Date 1498838844 25200
> #      Fri Jun 30 09:07:24 2017 -0700
> # Node ID 7a87ec7bcd672d0aa9178d9d87a7c8433241e5d3
> # Parent  40ee74bfa11122a0a3ab74186f5056243b84af89
> patch: add close() to abstractbackend

Queued, thanks.

> patchbackend() seems to call it on an arbitrary backend, so it seems
> to be part of the API. Since all subclasses do something in their
> close() methods, I decided to let this one raise an exception rather
> than just pass.

fsbackend doesn't implement close(), but it appears not an abstract class.

Patch

diff --git a/mercurial/patch.py b/mercurial/patch.py
--- a/mercurial/patch.py
+++ b/mercurial/patch.py
@@ -448,6 +448,9 @@ 
     def exists(self, fname):
         raise NotImplementedError
 
+    def close(self):
+        raise NotImplementedError
+
 class fsbackend(abstractbackend):
     def __init__(self, ui, basedir):
         super(fsbackend, self).__init__(ui)