[PATCH 2 of 2 V2] patch: replace functions in fsbackend to use vfs
FUJIWARA Katsunori
foozy at lares.dti.ne.jp
Thu Jun 5 08:55:38 CDT 2014
At Thu, 05 Jun 2014 16:16:08 +0530,
Chinmay Joshi wrote:
>
> # HG changeset patch
> # User Chinmay Joshi <c at chinmayjoshi.com>
> # Date 1401962069 -19800
> # Thu Jun 05 15:24:29 2014 +0530
> # Node ID 8409375408a3d8626de54cce515babd03c7a78fb
> # Parent 03dfb48d6b03dd6129f19be65b3e95534dfbb96f
> patch: replace functions in fsbackend to use vfs
>
> Several functions in fsbackend are replaced to use vfs functions.
> vfs operations are applied on filename and path is joined by _join().
>
> diff --git a/mercurial/patch.py b/mercurial/patch.py
> --- a/mercurial/patch.py
> +++ b/mercurial/patch.py
> @@ -417,12 +417,12 @@
> return os.path.join(self.opener.base, f)
>
> def getfile(self, fname):
> - path = self._join(fname)
> - if os.path.islink(path):
> - return (os.readlink(path), (True, False))
> + if self.opener.islink(fname):
> + return (self.opener.readlink(fname), (True, False))
> +
> isexec = False
> try:
> - isexec = os.lstat(path).st_mode & 0100 != 0
> + isexec = self.opener.lstat(fname).st_mode & 0100 != 0
> except OSError, e:
> if e.errno != errno.ENOENT:
> raise
This patch looks good to me.
BTW, for performance efficiency, it may be desirable to avoid
'islink' by reusing result of 'lstat', in another patch: 'islink'
also causes 'lstat' system call invocation in underlying layer,
and it costs much in large scale repositories.
'stat.S_ISLNK' usage in 'add'/'copy' of 'workingctx' can be referred
for such improvement.
> @@ -431,17 +431,17 @@
> def setfile(self, fname, data, mode, copysource):
> islink, isexec = mode
> if data is None:
> - util.setflags(self._join(fname), islink, isexec)
> + self.opener.setflags(fname, islink, isexec)
> return
> if islink:
> self.opener.symlink(data, fname)
> else:
> self.opener.write(fname, data)
> if isexec:
> - util.setflags(self._join(fname), False, True)
> + self.opener.setflags(fname, False, True)
>
> def unlink(self, fname):
> - util.unlinkpath(self._join(fname), ignoremissing=True)
> + self.opener.unlinkpath(fname, ignoremissing=True)
>
> def writerej(self, fname, failed, total, lines):
> fname = fname + ".rej"
> @@ -453,7 +453,7 @@
> fp.close()
>
> def exists(self, fname):
> - return os.path.lexists(self._join(fname))
> + return self.opener.lexists(fname)
>
> class workingbackend(fsbackend):
> def __init__(self, ui, repo, similarity):
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel
>
----------------------------------------------------------------------
[FUJIWARA Katsunori] foozy at lares.dti.ne.jp
More information about the Mercurial-devel
mailing list