Patchwork [08,of,14] undumprevlog: manually lift path auditing

login
register
mail settings
Submitter Pierre-Yves David
Date July 2, 2017, 2:56 a.m.
Message ID <5dd9c2cb6d1dbebc0a51.1498964193@nodosa.octopoid.net>
Download mbox | patch
Permalink /patch/21889/
State Accepted
Headers show

Comments

Pierre-Yves David - July 2, 2017, 2:56 a.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@octobus.net>
# Date 1498960272 -7200
#      Sun Jul 02 03:51:12 2017 +0200
# Node ID 5dd9c2cb6d1dbebc0a51662dd8dda9d4c3f933db
# Parent  aa8fda090eeee63cfc24d4a125d69f275abac1dd
# EXP-Topic vfs.ward
# Available At https://www.mercurial-scm.org/repo/users/marmoute/mercurial/
#              hg pull https://www.mercurial-scm.org/repo/users/marmoute/mercurial/ -r 5dd9c2cb6d1d
undumprevlog: manually lift path auditing

The 'audit' parameter of 'vfs' has very few users (three) and None of them are
from official commands. We start using alternative approach to be eventually
able of dropping the parameters.
Yuya Nishihara - July 5, 2017, 2:39 p.m.
On Sun, 02 Jul 2017 04:56:33 +0200, Pierre-Yves David wrote:
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david@octobus.net>
> # Date 1498960272 -7200
> #      Sun Jul 02 03:51:12 2017 +0200
> # Node ID 5dd9c2cb6d1dbebc0a51662dd8dda9d4c3f933db
> # Parent  aa8fda090eeee63cfc24d4a125d69f275abac1dd
> # EXP-Topic vfs.ward
> # Available At https://www.mercurial-scm.org/repo/users/marmoute/mercurial/
> #              hg pull https://www.mercurial-scm.org/repo/users/marmoute/mercurial/ -r 5dd9c2cb6d1d
> undumprevlog: manually lift path auditing
> 
> The 'audit' parameter of 'vfs' has very few users (three) and None of them are
> from official commands. We start using alternative approach to be eventually
> able of dropping the parameters.
> 
> diff --git a/contrib/undumprevlog b/contrib/undumprevlog
> --- a/contrib/undumprevlog
> +++ b/contrib/undumprevlog
> @@ -17,7 +17,8 @@ from mercurial import (
>  for fp in (sys.stdin, sys.stdout, sys.stderr):
>      util.setbinary(fp)
>  
> -opener = vfsmod.vfs('.', False)
> +opener = vfsmod.vfs('.')
> +opener.audit = lambda fn: True # disable path auditing

I don't think replacing the audit function is better than the audit flag.
Also, util.checkosfilename() was guarded by self._audit, which is no longer
be disabled.

Patch

diff --git a/contrib/undumprevlog b/contrib/undumprevlog
--- a/contrib/undumprevlog
+++ b/contrib/undumprevlog
@@ -17,7 +17,8 @@  from mercurial import (
 for fp in (sys.stdin, sys.stdout, sys.stderr):
     util.setbinary(fp)
 
-opener = vfsmod.vfs('.', False)
+opener = vfsmod.vfs('.')
+opener.audit = lambda fn: True # disable path auditing
 tr = transaction.transaction(sys.stderr.write, opener, {'store': opener},
                              "undump.journal")
 while True: