Patchwork [STABLE] ignore: fix path concatenation of .hgignore on Windows

login
register
mail settings
Submitter Yuya Nishihara
Date July 27, 2015, 2:02 p.m.
Message ID <fb55ea49d79ecdc19339.1438005748@mimosa>
Download mbox | patch
Permalink /patch/10066/
State Accepted
Headers show

Comments

Yuya Nishihara - July 27, 2015, 2:02 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1438002880 -32400
#      Mon Jul 27 22:14:40 2015 +0900
# Branch stable
# Node ID fb55ea49d79ecdc193392b791dee02b2912cf727
# Parent  3e84f40232c7931dbeca16e563ae8f63ca12cf4d
ignore: fix path concatenation of .hgignore on Windows

Since 3de48ff62733, .hgignore is ignored on Windows because a pat may have
a drive letter, but pathutil.join is posixpath.join.

  "z:\foo\bar/z:\foo\bar\.hgignore"

Instead, this patch uses os.path.join() and util.localpath() to process both
parts as file-system paths.

Maybe we can remove os.path.join() at dirstate._ignore because 'include:' is
resolved relative to repo root? It was introduced by a04c7b74b3d5.
Sean Farley - July 27, 2015, 5:39 p.m.
Yuya Nishihara <yuya@tcha.org> writes:

> # HG changeset patch
> # User Yuya Nishihara <yuya@tcha.org>
> # Date 1438002880 -32400
> #      Mon Jul 27 22:14:40 2015 +0900
> # Branch stable
> # Node ID fb55ea49d79ecdc193392b791dee02b2912cf727
> # Parent  3e84f40232c7931dbeca16e563ae8f63ca12cf4d
> ignore: fix path concatenation of .hgignore on Windows
>
> Since 3de48ff62733, .hgignore is ignored on Windows because a pat may have
> a drive letter, but pathutil.join is posixpath.join.
>
>   "z:\foo\bar/z:\foo\bar\.hgignore"
>
> Instead, this patch uses os.path.join() and util.localpath() to process both
> parts as file-system paths.

This patch looks good to me for stable.

> Maybe we can remove os.path.join() at dirstate._ignore because 'include:' is
> resolved relative to repo root? It was introduced by a04c7b74b3d5.

That is a good question that maybe Martin or Fujiwara could answer?
Matt Mackall - July 27, 2015, 5:46 p.m.
On Mon, 2015-07-27 at 23:02 +0900, Yuya Nishihara wrote:
> # HG changeset patch
> # User Yuya Nishihara <yuya@tcha.org>
> # Date 1438002880 -32400
> #      Mon Jul 27 22:14:40 2015 +0900
> # Branch stable
> # Node ID fb55ea49d79ecdc193392b791dee02b2912cf727
> # Parent  3e84f40232c7931dbeca16e563ae8f63ca12cf4d
> ignore: fix path concatenation of .hgignore on Windows

Queued for stable, thanks.

Patch

diff --git a/mercurial/match.py b/mercurial/match.py
--- a/mercurial/match.py
+++ b/mercurial/match.py
@@ -5,7 +5,7 @@ 
 # This software may be used and distributed according to the terms of the
 # GNU General Public License version 2 or any later version.
 
-import copy, re
+import copy, os, re
 import util, pathutil
 from i18n import _
 
@@ -289,7 +289,7 @@  class match(object):
                 continue
             elif kind == 'include':
                 try:
-                    fullpath = pathutil.join(root, pat)
+                    fullpath = os.path.join(root, util.localpath(pat))
                     includepats = readpatternfile(fullpath, self._warn)
                     for k, p, source in self._normalize(includepats, default,
                                                         root, cwd, auditor):