[PATCH 2 of 2 V2] patch: replace functions in fsbackend to use vfs

Pierre-Yves David pierre-yves.david at ens-lyon.org
Thu Jun 5 18:59:29 CDT 2014



On 06/05/2014 03:46 AM, 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

Those two are pushed, Thanks!

Additional thanks goes to Foozy for his review.

-- 
Pierre-Yves David

>
> 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
> @@ -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
>

-- 
Pierre-Yves David


More information about the Mercurial-devel mailing list