Patchwork [5,of,5] pathutil: use temporary variables instead of complicated wrapping

login
register
mail settings
Submitter Pierre-Yves David
Date Dec. 3, 2015, 10:01 p.m.
Message ID <3bab3ad5eff0cf16c241.1449180089@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/11796/
State Accepted
Headers show

Comments

Pierre-Yves David - Dec. 3, 2015, 10:01 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@fb.com>
# Date 1449177260 28800
#      Thu Dec 03 13:14:20 2015 -0800
# Node ID 3bab3ad5eff0cf16c241aaea5958c53920aa3158
# Parent  65797f84a2cc0317f1326215701befd382d04299
# EXP-Topic symlink.issue4749
# Available At http://hg.netv6.net/marmoute-wip/mercurial/
#              hg pull http://hg.netv6.net/marmoute-wip/mercurial/ -r 3bab3ad5eff0
pathutil: use temporary variables instead of complicated wrapping

The one-lining did not help readability, we get rid of it.
Augie Fackler - Dec. 4, 2015, 7:56 p.m.
On Thu, Dec 03, 2015 at 02:01:29PM -0800, Pierre-Yves David wrote:
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david@fb.com>
> # Date 1449177260 28800
> #      Thu Dec 03 13:14:20 2015 -0800
> # Node ID 3bab3ad5eff0cf16c241aaea5958c53920aa3158
> # Parent  65797f84a2cc0317f1326215701befd382d04299
> # EXP-Topic symlink.issue4749
> # Available At http://hg.netv6.net/marmoute-wip/mercurial/
> #              hg pull http://hg.netv6.net/marmoute-wip/mercurial/ -r 3bab3ad5eff0
> pathutil: use temporary variables instead of complicated wrapping

Queued these, thanks!

>
> The one-lining did not help readability, we get rid of it.
>
> diff --git a/mercurial/pathutil.py b/mercurial/pathutil.py
> --- a/mercurial/pathutil.py
> +++ b/mercurial/pathutil.py
> @@ -109,18 +109,17 @@ class pathauditor(object):
>              # They must be ignored for patterns can be checked too.
>              if err.errno not in (errno.ENOENT, errno.ENOTDIR, errno.EINVAL):
>                  raise
>          else:
>              if stat.S_ISLNK(st.st_mode):
> -                raise error.Abort(
> -                    _('path %r traverses symbolic link %r')
> -                    % (path, prefix))
> +                msg = _('path %r traverses symbolic link %r') % (path, prefix)
> +                raise error.Abort(msg)
>              elif (stat.S_ISDIR(st.st_mode) and
>                    os.path.isdir(os.path.join(curpath, '.hg'))):
>                  if not self.callback or not self.callback(curpath):
> -                    raise error.Abort(_("path '%s' is inside nested "
> -                                        "repo %r") % (path, prefix))
> +                    msg = _("path '%s' is inside nested repo %r")
> +                    raise error.Abort(msg % (path, prefix))
>
>      def check(self, path):
>          try:
>              self(path)
>              return True
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> https://selenic.com/mailman/listinfo/mercurial-devel

Patch

diff --git a/mercurial/pathutil.py b/mercurial/pathutil.py
--- a/mercurial/pathutil.py
+++ b/mercurial/pathutil.py
@@ -109,18 +109,17 @@  class pathauditor(object):
             # They must be ignored for patterns can be checked too.
             if err.errno not in (errno.ENOENT, errno.ENOTDIR, errno.EINVAL):
                 raise
         else:
             if stat.S_ISLNK(st.st_mode):
-                raise error.Abort(
-                    _('path %r traverses symbolic link %r')
-                    % (path, prefix))
+                msg = _('path %r traverses symbolic link %r') % (path, prefix)
+                raise error.Abort(msg)
             elif (stat.S_ISDIR(st.st_mode) and
                   os.path.isdir(os.path.join(curpath, '.hg'))):
                 if not self.callback or not self.callback(curpath):
-                    raise error.Abort(_("path '%s' is inside nested "
-                                        "repo %r") % (path, prefix))
+                    msg = _("path '%s' is inside nested repo %r")
+                    raise error.Abort(msg % (path, prefix))
 
     def check(self, path):
         try:
             self(path)
             return True