changeset 23877:7cc77030c557

localrepo: remove all external users of localrepo.opener This change touches every module in which repository.opener was being used, and changes it for the equivalent repository.vfs. This is meant to make it easier to split the repository.vfs into several separate vfs. It should now be possible to remove localrepo.opener.
author Angel Ezquerra <angel.ezquerra@gmail.com>
date Thu, 15 Jan 2015 23:17:12 +0100
parents 48fd1dfb99aa
children 37a92908a382
files hgext/blackbox.py hgext/eol.py hgext/gpg.py hgext/keyword.py hgext/mq.py hgext/patchbomb.py hgext/rebase.py hgext/shelve.py mercurial/bookmarks.py mercurial/branchmap.py mercurial/commands.py mercurial/hbisect.py mercurial/hg.py mercurial/merge.py mercurial/statichttprepo.py mercurial/subrepo.py mercurial/tags.py
diffstat 17 files changed, 44 insertions(+), 44 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/blackbox.py	Wed Jan 14 20:29:47 2015 -0800
+++ b/hgext/blackbox.py	Thu Jan 15 23:17:12 2015 +0100
@@ -112,7 +112,7 @@
                 lastblackbox = blackbox
 
         def setrepo(self, repo):
-            self._bbopener = repo.opener
+            self._bbopener = repo.vfs
 
     ui.__class__ = blackboxui
 
@@ -141,7 +141,7 @@
         return
 
     limit = opts.get('limit')
-    blackbox = repo.opener('blackbox.log', 'r')
+    blackbox = repo.vfs('blackbox.log', 'r')
     lines = blackbox.read().split('\n')
 
     count = 0
--- a/hgext/eol.py	Wed Jan 14 20:29:47 2015 -0800
+++ b/hgext/eol.py	Thu Jan 15 23:17:12 2015 +0100
@@ -319,7 +319,7 @@
                             # longer match a file it matched before
                             self.dirstate.normallookup(f)
                     # Create or touch the cache to update mtime
-                    self.opener("eol.cache", "w").close()
+                    self.vfs("eol.cache", "w").close()
                     wlock.release()
                 except error.LockUnavailable:
                     # If we cannot lock the repository and clear the
--- a/hgext/gpg.py	Wed Jan 14 20:29:47 2015 -0800
+++ b/hgext/gpg.py	Thu Jan 15 23:17:12 2015 +0100
@@ -103,7 +103,7 @@
     try:
         # read local signatures
         fn = "localsigs"
-        for item in parsefile(repo.opener(fn), fn):
+        for item in parsefile(repo.vfs(fn), fn):
             yield item
     except IOError:
         pass
@@ -250,7 +250,7 @@
 
     # write it
     if opts['local']:
-        repo.opener.append("localsigs", sigmessage)
+        repo.vfs.append("localsigs", sigmessage)
         return
 
     if not opts["force"]:
--- a/hgext/keyword.py	Wed Jan 14 20:29:47 2015 -0800
+++ b/hgext/keyword.py	Thu Jan 15 23:17:12 2015 +0100
@@ -411,7 +411,7 @@
         if args:
             # simulate hgrc parsing
             rcmaps = ['[keywordmaps]\n'] + [a + '\n' for a in args]
-            fp = repo.opener('hgrc', 'w')
+            fp = repo.vfs('hgrc', 'w')
             fp.writelines(rcmaps)
             fp.close()
             ui.readconfig(repo.join('hgrc'))
--- a/hgext/mq.py	Wed Jan 14 20:29:47 2015 -0800
+++ b/hgext/mq.py	Thu Jan 15 23:17:12 2015 +0100
@@ -3215,7 +3215,7 @@
 
     def _noqueues():
         try:
-            fh = repo.opener(_allqueues, 'r')
+            fh = repo.vfs(_allqueues, 'r')
             fh.close()
         except IOError:
             return True
@@ -3226,7 +3226,7 @@
         current = _getcurrent()
 
         try:
-            fh = repo.opener(_allqueues, 'r')
+            fh = repo.vfs(_allqueues, 'r')
             queues = [queue.strip() for queue in fh if queue.strip()]
             fh.close()
             if current not in queues:
@@ -3243,13 +3243,13 @@
         _setactivenocheck(name)
 
     def _setactivenocheck(name):
-        fh = repo.opener(_activequeue, 'w')
+        fh = repo.vfs(_activequeue, 'w')
         if name != 'patches':
             fh.write(name)
         fh.close()
 
     def _addqueue(name):
-        fh = repo.opener(_allqueues, 'a')
+        fh = repo.vfs(_allqueues, 'a')
         fh.write('%s\n' % (name,))
         fh.close()
 
@@ -3274,7 +3274,7 @@
         if name == current:
             raise util.Abort(_('cannot delete currently active queue'))
 
-        fh = repo.opener('patches.queues.new', 'w')
+        fh = repo.vfs('patches.queues.new', 'w')
         for queue in existing:
             if queue == name:
                 continue
@@ -3322,7 +3322,7 @@
             raise util.Abort(_('non-queue directory "%s" already exists') %
                     newdir)
 
-        fh = repo.opener('patches.queues.new', 'w')
+        fh = repo.vfs('patches.queues.new', 'w')
         for queue in existing:
             if queue == current:
                 fh.write('%s\n' % (name,))
--- a/hgext/patchbomb.py	Wed Jan 14 20:29:47 2015 -0800
+++ b/hgext/patchbomb.py	Thu Jan 15 23:17:12 2015 +0100
@@ -234,7 +234,7 @@
                    'patch series.\n\n'))
         body = ui.edit(defaultbody, sender)
         # Save series description in case sendmail fails
-        msgfile = repo.opener('last-email.txt', 'wb')
+        msgfile = repo.vfs('last-email.txt', 'wb')
         msgfile.write(body)
         msgfile.close()
     return body
--- a/hgext/rebase.py	Wed Jan 14 20:29:47 2015 -0800
+++ b/hgext/rebase.py	Thu Jan 15 23:17:12 2015 +0100
@@ -754,7 +754,7 @@
 def storestatus(repo, originalwd, target, state, collapse, keep, keepbranches,
                 external, activebookmark):
     'Store the current status to allow recovery'
-    f = repo.opener("rebasestate", "w")
+    f = repo.vfs("rebasestate", "w")
     f.write(repo[originalwd].hex() + '\n')
     f.write(repo[target].hex() + '\n')
     f.write(repo[external].hex() + '\n')
@@ -789,7 +789,7 @@
         external = nullrev
         activebookmark = None
         state = {}
-        f = repo.opener("rebasestate")
+        f = repo.vfs("rebasestate")
         for i, l in enumerate(f.read().splitlines()):
             if i == 0:
                 originalwd = repo[l].rev()
--- a/hgext/shelve.py	Wed Jan 14 20:29:47 2015 -0800
+++ b/hgext/shelve.py	Thu Jan 15 23:17:12 2015 +0100
@@ -95,7 +95,7 @@
 
     @classmethod
     def load(cls, repo):
-        fp = repo.opener(cls._filename)
+        fp = repo.vfs(cls._filename)
         try:
             version = int(fp.readline().strip())
 
@@ -121,7 +121,7 @@
 
     @classmethod
     def save(cls, repo, name, originalwctx, pendingctx, stripnodes):
-        fp = repo.opener(cls._filename, 'wb')
+        fp = repo.vfs(cls._filename, 'wb')
         fp.write('%i\n' % cls._version)
         fp.write('%s\n' % name)
         fp.write('%s\n' % hex(originalwctx.node()))
--- a/mercurial/bookmarks.py	Wed Jan 14 20:29:47 2015 -0800
+++ b/mercurial/bookmarks.py	Thu Jan 15 23:17:12 2015 +0100
@@ -115,7 +115,7 @@
     '''
     mark = None
     try:
-        file = repo.opener('bookmarks.current')
+        file = repo.vfs('bookmarks.current')
     except IOError, inst:
         if inst.errno != errno.ENOENT:
             raise
@@ -144,7 +144,7 @@
 
     wlock = repo.wlock()
     try:
-        file = repo.opener('bookmarks.current', 'w', atomictemp=True)
+        file = repo.vfs('bookmarks.current', 'w', atomictemp=True)
         file.write(encoding.fromlocal(mark))
         file.close()
     finally:
--- a/mercurial/branchmap.py	Wed Jan 14 20:29:47 2015 -0800
+++ b/mercurial/branchmap.py	Thu Jan 15 23:17:12 2015 +0100
@@ -21,7 +21,7 @@
 
 def read(repo):
     try:
-        f = repo.opener(_filename(repo))
+        f = repo.vfs(_filename(repo))
         lines = f.read().split('\n')
         f.close()
     except (IOError, OSError):
@@ -203,7 +203,7 @@
 
     def write(self, repo):
         try:
-            f = repo.opener(_filename(repo), "w", atomictemp=True)
+            f = repo.vfs(_filename(repo), "w", atomictemp=True)
             cachekey = [hex(self.tipnode), str(self.tiprev)]
             if self.filteredhash is not None:
                 cachekey.append(hex(self.filteredhash))
--- a/mercurial/commands.py	Wed Jan 14 20:29:47 2015 -0800
+++ b/mercurial/commands.py	Thu Jan 15 23:17:12 2015 +0100
@@ -1803,7 +1803,7 @@
         tr.close()
 
         if tags:
-            repo.opener.write("localtags", "".join(tags))
+            repo.vfs.write("localtags", "".join(tags))
     finally:
         ui.progress(_('building'), None)
         release(tr, lock)
@@ -3377,7 +3377,7 @@
             raise util.Abort(_("can't specify --continue and revisions"))
         # read in unfinished revisions
         try:
-            nodes = repo.opener.read('graftstate').splitlines()
+            nodes = repo.vfs.read('graftstate').splitlines()
             revs = [repo[node].rev() for node in nodes]
         except IOError, inst:
             if inst.errno != errno.ENOENT:
@@ -3506,7 +3506,7 @@
                 if stats and stats[3] > 0:
                     # write out state for --continue
                     nodelines = [repo[rev].hex() + "\n" for rev in revs[pos:]]
-                    repo.opener.write('graftstate', ''.join(nodelines))
+                    repo.vfs.write('graftstate', ''.join(nodelines))
                     raise util.Abort(
                         _("unresolved conflicts, can't continue"),
                         hint=_('use hg resolve and hg graft --continue'))
--- a/mercurial/hbisect.py	Wed Jan 14 20:29:47 2015 -0800
+++ b/mercurial/hbisect.py	Thu Jan 15 23:17:12 2015 +0100
@@ -136,7 +136,7 @@
 def load_state(repo):
     state = {'current': [], 'good': [], 'bad': [], 'skip': []}
     if os.path.exists(repo.join("bisect.state")):
-        for l in repo.opener("bisect.state"):
+        for l in repo.vfs("bisect.state"):
             kind, node = l[:-1].split()
             node = repo.lookup(node)
             if kind not in state:
@@ -146,7 +146,7 @@
 
 
 def save_state(repo, state):
-    f = repo.opener("bisect.state", "w", atomictemp=True)
+    f = repo.vfs("bisect.state", "w", atomictemp=True)
     wlock = repo.wlock()
     try:
         for kind in sorted(state):
--- a/mercurial/hg.py	Wed Jan 14 20:29:47 2015 -0800
+++ b/mercurial/hg.py	Thu Jan 15 23:17:12 2015 +0100
@@ -193,7 +193,7 @@
 
     requirements = ''
     try:
-        requirements = srcrepo.opener.read('requires')
+        requirements = srcrepo.vfs.read('requires')
     except IOError, inst:
         if inst.errno != errno.ENOENT:
             raise
@@ -206,7 +206,7 @@
 
     default = srcrepo.ui.config('paths', 'default')
     if default:
-        fp = r.opener("hgrc", "w", text=True)
+        fp = r.vfs("hgrc", "w", text=True)
         fp.write("[paths]\n")
         fp.write("default = %s\n" % default)
         fp.close()
@@ -226,7 +226,7 @@
         _update(r, uprev)
 
     if bookmarks:
-        r.opener('bookmarks.shared', 'w').close()
+        r.vfs('bookmarks.shared', 'w').close()
 
 def copystore(ui, srcrepo, destpath):
     '''copy files from store of srcrepo in destpath
@@ -441,7 +441,7 @@
         destrepo = destpeer.local()
         if destrepo:
             template = uimod.samplehgrcs['cloned']
-            fp = destrepo.opener("hgrc", "w", text=True)
+            fp = destrepo.vfs("hgrc", "w", text=True)
             u = util.url(abspath)
             u.passwd = None
             defaulturl = str(u)
--- a/mercurial/merge.py	Wed Jan 14 20:29:47 2015 -0800
+++ b/mercurial/merge.py	Thu Jan 15 23:17:12 2015 +0100
@@ -138,7 +138,7 @@
         """
         records = []
         try:
-            f = self._repo.opener(self.statepathv1)
+            f = self._repo.vfs(self.statepathv1)
             for i, l in enumerate(f):
                 if i == 0:
                     records.append(('L', l[:-1]))
@@ -157,7 +157,7 @@
         """
         records = []
         try:
-            f = self._repo.opener(self.statepathv2)
+            f = self._repo.vfs(self.statepathv2)
             data = f.read()
             off = 0
             end = len(data)
@@ -184,8 +184,8 @@
         # Check local variables before looking at filesystem for performance
         # reasons.
         return bool(self._local) or bool(self._state) or \
-               self._repo.opener.exists(self.statepathv1) or \
-               self._repo.opener.exists(self.statepathv2)
+               self._repo.vfs.exists(self.statepathv1) or \
+               self._repo.vfs.exists(self.statepathv2)
 
     def commit(self):
         """Write current state on disk (if necessary)"""
@@ -205,7 +205,7 @@
 
     def _writerecordsv1(self, records):
         """Write current state on disk in a version 1 file"""
-        f = self._repo.opener(self.statepathv1, 'w')
+        f = self._repo.vfs(self.statepathv1, 'w')
         irecords = iter(records)
         lrecords = irecords.next()
         assert lrecords[0] == 'L'
@@ -217,7 +217,7 @@
 
     def _writerecordsv2(self, records):
         """Write current state on disk in a version 2 file"""
-        f = self._repo.opener(self.statepathv2, 'w')
+        f = self._repo.vfs(self.statepathv2, 'w')
         for key, data in records:
             assert len(key) == 1
             format = '>sI%is' % len(data)
@@ -234,7 +234,7 @@
         note: also write the local version to the `.hg/merge` directory.
         """
         hash = util.sha1(fcl.path()).hexdigest()
-        self._repo.opener.write('merge/' + hash, fcl.data())
+        self._repo.vfs.write('merge/' + hash, fcl.data())
         self._state[fd] = ['u', hash, fcl.path(),
                            fca.path(), hex(fca.filenode()),
                            fco.path(), hex(fco.filenode()),
@@ -284,7 +284,7 @@
             elif flags == fla:
                 flags = flo
         # restore local
-        f = self._repo.opener('merge/' + hash)
+        f = self._repo.vfs('merge/' + hash)
         self._repo.wwrite(dfile, f.read(), flags)
         f.close()
         r = filemerge.filemerge(self._repo, self._local, lfile, fcd, fco, fca,
--- a/mercurial/statichttprepo.py	Wed Jan 14 20:29:47 2015 -0800
+++ b/mercurial/statichttprepo.py	Thu Jan 15 23:17:12 2015 +0100
@@ -109,7 +109,7 @@
         self.names = namespaces.namespaces()
 
         try:
-            requirements = scmutil.readrequires(self.opener, self.supported)
+            requirements = scmutil.readrequires(self.vfs, self.supported)
         except IOError, inst:
             if inst.errno != errno.ENOENT:
                 raise
@@ -117,7 +117,7 @@
 
             # check if it is a non-empty old-style repository
             try:
-                fp = self.opener("00changelog.i")
+                fp = self.vfs("00changelog.i")
                 fp.read(1)
                 fp.close()
             except IOError, inst:
--- a/mercurial/subrepo.py	Wed Jan 14 20:29:47 2015 -0800
+++ b/mercurial/subrepo.py	Thu Jan 15 23:17:12 2015 +0100
@@ -614,7 +614,7 @@
             if defpath != defpushpath:
                 addpathconfig('default-push', defpushpath)
 
-            fp = self._repo.opener("hgrc", "w", text=True)
+            fp = self._repo.vfs("hgrc", "w", text=True)
             try:
                 fp.write(''.join(lines))
             finally:
--- a/mercurial/tags.py	Wed Jan 14 20:29:47 2015 -0800
+++ b/mercurial/tags.py	Thu Jan 15 23:17:12 2015 +0100
@@ -62,7 +62,7 @@
 def readlocaltags(ui, repo, alltags, tagtypes):
     '''Read local tags in repo.  Update alltags and tagtypes.'''
     try:
-        data = repo.opener.read("localtags")
+        data = repo.vfs.read("localtags")
     except IOError, inst:
         if inst.errno != errno.ENOENT:
             raise
@@ -193,7 +193,7 @@
     set, caller is responsible for reading tag info from each head.'''
 
     try:
-        cachefile = repo.opener('cache/tags', 'r')
+        cachefile = repo.vfs('cache/tags', 'r')
         # force reading the file for static-http
         cachelines = iter(cachefile)
     except IOError:
@@ -303,7 +303,7 @@
 def _writetagcache(ui, repo, heads, tagfnode, cachetags):
 
     try:
-        cachefile = repo.opener('cache/tags', 'w', atomictemp=True)
+        cachefile = repo.vfs('cache/tags', 'w', atomictemp=True)
     except (OSError, IOError):
         return