# HG changeset patch # User Pierre-Yves David # Date 2017-03-02 02:52:36 # Node ID 21fa3d3688f3ecde3a5ffd8b8b4597019c2c75f1 # Parent 15c998528c366fe955f7a484abc40dbbebf1c4e7 vfs: replace 'scmutil.opener' usage with 'scmutil.vfs' The 'vfs' class is the first class citizen for years. We remove all usages of the older API. This will let us remove the old API eventually. diff --git a/contrib/undumprevlog b/contrib/undumprevlog --- a/contrib/undumprevlog +++ b/contrib/undumprevlog @@ -17,7 +17,7 @@ from mercurial import ( for fp in (sys.stdin, sys.stdout, sys.stderr): util.setbinary(fp) -opener = scmutil.opener('.', False) +opener = scmutil.vfs('.', False) tr = transaction.transaction(sys.stderr.write, opener, {'store': opener}, "undump.journal") while True: diff --git a/hgext/convert/subversion.py b/hgext/convert/subversion.py --- a/hgext/convert/subversion.py +++ b/hgext/convert/subversion.py @@ -1146,8 +1146,8 @@ class svn_sink(converter_sink, commandli self.run0('checkout', path, wcpath) self.wc = wcpath - self.opener = scmutil.opener(self.wc) - self.wopener = scmutil.opener(self.wc) + self.opener = scmutil.vfs(self.wc) + self.wopener = scmutil.vfs(self.wc) self.childmap = mapfile(ui, self.join('hg-childmap')) if util.checkexec(self.wc): self.is_exec = util.isexec diff --git a/hgext/largefiles/lfutil.py b/hgext/largefiles/lfutil.py --- a/hgext/largefiles/lfutil.py +++ b/hgext/largefiles/lfutil.py @@ -144,7 +144,7 @@ def openlfdirstate(ui, repo, create=True ''' vfs = repo.vfs lfstoredir = longname - opener = scmutil.opener(vfs.join(lfstoredir)) + opener = scmutil.vfs(vfs.join(lfstoredir)) lfdirstate = largefilesdirstate(opener, ui, repo.root, repo.dirstate._validate) diff --git a/hgext/mq.py b/hgext/mq.py --- a/hgext/mq.py +++ b/hgext/mq.py @@ -434,7 +434,7 @@ class queue(object): except IOError: curpath = os.path.join(path, 'patches') self.path = patchdir or curpath - self.opener = scmutil.opener(self.path) + self.opener = scmutil.vfs(self.path) self.ui = ui self.baseui = baseui self.applieddirty = False diff --git a/hgext/transplant.py b/hgext/transplant.py --- a/hgext/transplant.py +++ b/hgext/transplant.py @@ -60,7 +60,7 @@ class transplants(object): self.opener = opener if not opener: - self.opener = scmutil.opener(self.path) + self.opener = scmutil.vfs(self.path) self.transplants = {} self.dirty = False self.read() @@ -103,7 +103,7 @@ class transplanter(object): def __init__(self, ui, repo, opts): self.ui = ui self.path = repo.join('transplant') - self.opener = scmutil.opener(self.path) + self.opener = scmutil.vfs(self.path) self.transplants = transplants(self.path, 'transplants', opener=self.opener) def getcommiteditor(): diff --git a/mercurial/archival.py b/mercurial/archival.py --- a/mercurial/archival.py +++ b/mercurial/archival.py @@ -249,7 +249,7 @@ class fileit(object): def __init__(self, name, mtime): self.basedir = name - self.opener = scmutil.opener(self.basedir) + self.opener = scmutil.vfs(self.basedir) def addfile(self, name, mode, islink, data): if islink: diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py --- a/mercurial/cmdutil.py +++ b/mercurial/cmdutil.py @@ -583,7 +583,7 @@ def openrevlog(repo, cmd, file_, opts): raise error.CommandError(cmd, _('invalid arguments')) if not os.path.isfile(file_): raise error.Abort(_("revlog '%s' not found") % file_) - r = revlog.revlog(scmutil.opener(pycompat.getcwd(), audit=False), + r = revlog.revlog(scmutil.vfs(pycompat.getcwd(), audit=False), file_[:-2] + ".i") return r diff --git a/mercurial/debugcommands.py b/mercurial/debugcommands.py --- a/mercurial/debugcommands.py +++ b/mercurial/debugcommands.py @@ -76,7 +76,7 @@ def debugancestor(ui, repo, *args): """find the ancestor revision of two revisions in a given index""" if len(args) == 3: index, rev1, rev2 = args - r = revlog.revlog(scmutil.opener(pycompat.getcwd(), audit=False), index) + r = revlog.revlog(scmutil.vfs(pycompat.getcwd(), audit=False), index) lookup = r.lookup elif len(args) == 2: if not repo: @@ -452,7 +452,7 @@ def debugdag(ui, repo, file_=None, *revs spaces = opts.get('spaces') dots = opts.get('dots') if file_: - rlog = revlog.revlog(scmutil.opener(pycompat.getcwd(), audit=False), + rlog = revlog.revlog(scmutil.vfs(pycompat.getcwd(), audit=False), file_) revs = set((int(r) for r in revs)) def events(): diff --git a/mercurial/patch.py b/mercurial/patch.py --- a/mercurial/patch.py +++ b/mercurial/patch.py @@ -449,7 +449,7 @@ class abstractbackend(object): class fsbackend(abstractbackend): def __init__(self, ui, basedir): super(fsbackend, self).__init__(ui) - self.opener = scmutil.opener(basedir) + self.opener = scmutil.vfs(basedir) def _join(self, f): return os.path.join(self.opener.base, f) @@ -560,7 +560,7 @@ class filestore(object): else: if self.opener is None: root = tempfile.mkdtemp(prefix='hg-patch-') - self.opener = scmutil.opener(root) + self.opener = scmutil.vfs(root) # Avoid filename issues with these simple names fn = str(self.created) self.opener.write(fn, data) diff --git a/mercurial/simplemerge.py b/mercurial/simplemerge.py --- a/mercurial/simplemerge.py +++ b/mercurial/simplemerge.py @@ -437,7 +437,7 @@ def simplemerge(ui, local, base, other, local = os.path.realpath(local) if not opts.get('print'): - opener = scmutil.opener(os.path.dirname(local)) + opener = scmutil.vfs(os.path.dirname(local)) out = opener(os.path.basename(local), "w", atomictemp=True) else: out = ui.fout diff --git a/tests/test-filecache.py b/tests/test-filecache.py --- a/tests/test-filecache.py +++ b/tests/test-filecache.py @@ -73,7 +73,7 @@ def basic(repo): # atomic replace file, size doesn't change # hopefully st_mtime doesn't change as well so this doesn't use the cache # because of inode change - f = scmutil.opener('.')('x', 'w', atomictemp=True) + f = scmutil.vfs('.')('x', 'w', atomictemp=True) f.write('b') f.close() @@ -97,7 +97,7 @@ def basic(repo): # should recreate the object repo.cached - f = scmutil.opener('.')('y', 'w', atomictemp=True) + f = scmutil.vfs('.')('y', 'w', atomictemp=True) f.write('B') f.close() @@ -105,10 +105,10 @@ def basic(repo): print("* file y changed inode") repo.cached - f = scmutil.opener('.')('x', 'w', atomictemp=True) + f = scmutil.vfs('.')('x', 'w', atomictemp=True) f.write('c') f.close() - f = scmutil.opener('.')('y', 'w', atomictemp=True) + f = scmutil.vfs('.')('y', 'w', atomictemp=True) f.write('C') f.close() diff --git a/tests/test-parseindex.t b/tests/test-parseindex.t --- a/tests/test-parseindex.t +++ b/tests/test-parseindex.t @@ -42,7 +42,7 @@ We approximate that by reducing the read > return getattr(self.real, key) > > def opener(*args): - > o = scmutil.opener(*args) + > o = scmutil.vfs(*args) > def wrapper(*a): > f = o(*a) > return singlebyteread(f)