Patchwork fsmonitor: remove use of repo.opener

login
register
mail settings
Submitter Durham Goode
Date March 7, 2017, 8:53 p.m.
Message ID <4d485e46a3e5c83ff8d2.1488920005@dev111.prn1.facebook.com>
Download mbox | patch
Permalink /patch/18972/
State Accepted
Headers show

Comments

Durham Goode - March 7, 2017, 8:53 p.m.
# HG changeset patch
# User Durham Goode <durham@fb.com>
# Date 1488919920 28800
#      Tue Mar 07 12:52:00 2017 -0800
# Node ID 4d485e46a3e5c83ff8d2ae0a4ba8e484a284f65b
# Parent  7433b3bc55eebfa9149280339b406bd4cec64efb
fsmonitor: remove use of repo.opener

This has been deprecated, so we need to switch to the appropriate vfs apis.
Augie Fackler - March 8, 2017, 1:11 a.m.
On Tue, Mar 07, 2017 at 12:53:25PM -0800, Durham Goode wrote:
> # HG changeset patch
> # User Durham Goode <durham@fb.com>
> # Date 1488919920 28800
> #      Tue Mar 07 12:52:00 2017 -0800
> # Node ID 4d485e46a3e5c83ff8d2ae0a4ba8e484a284f65b
> # Parent  7433b3bc55eebfa9149280339b406bd4cec64efb
> fsmonitor: remove use of repo.opener

Queued, thanks.

>
> This has been deprecated, so we need to switch to the appropriate vfs apis.
>
> diff --git a/hgext/fsmonitor/state.py b/hgext/fsmonitor/state.py
> --- a/hgext/fsmonitor/state.py
> +++ b/hgext/fsmonitor/state.py
> @@ -20,7 +20,7 @@ from mercurial import pathutil
>
>  class state(object):
>      def __init__(self, repo):
> -        self._opener = repo.opener
> +        self._vfs = repo.vfs
>          self._ui = repo.ui
>          self._rootdir = pathutil.normasprefix(repo.root)
>          self._lastclock = None
> @@ -33,7 +33,7 @@ class state(object):
>
>      def get(self):
>          try:
> -            file = self._opener('fsmonitor.state', 'rb')
> +            file = self._vfs('fsmonitor.state', 'rb')
>          except IOError as inst:
>              if inst.errno != errno.ENOENT:
>                  raise
> @@ -91,7 +91,7 @@ class state(object):
>              return
>
>          try:
> -            file = self._opener('fsmonitor.state', 'wb', atomictemp=True)
> +            file = self._vfs('fsmonitor.state', 'wb', atomictemp=True)
>          except (IOError, OSError):
>              self._ui.warn(_("warning: unable to write out fsmonitor state\n"))
>              return
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Patch

diff --git a/hgext/fsmonitor/state.py b/hgext/fsmonitor/state.py
--- a/hgext/fsmonitor/state.py
+++ b/hgext/fsmonitor/state.py
@@ -20,7 +20,7 @@  from mercurial import pathutil
 
 class state(object):
     def __init__(self, repo):
-        self._opener = repo.opener
+        self._vfs = repo.vfs
         self._ui = repo.ui
         self._rootdir = pathutil.normasprefix(repo.root)
         self._lastclock = None
@@ -33,7 +33,7 @@  class state(object):
 
     def get(self):
         try:
-            file = self._opener('fsmonitor.state', 'rb')
+            file = self._vfs('fsmonitor.state', 'rb')
         except IOError as inst:
             if inst.errno != errno.ENOENT:
                 raise
@@ -91,7 +91,7 @@  class state(object):
             return
 
         try:
-            file = self._opener('fsmonitor.state', 'wb', atomictemp=True)
+            file = self._vfs('fsmonitor.state', 'wb', atomictemp=True)
         except (IOError, OSError):
             self._ui.warn(_("warning: unable to write out fsmonitor state\n"))
             return