Patchwork [1,of,2,STABLE] terse: split on repo separator instead of os.sep (issue5715)

login
register
mail settings
Submitter Matt Harbison
Date Oct. 28, 2017, 4:24 a.m.
Message ID <f5cdf17fe89faac24397.1509164696@Envy>
Download mbox | patch
Permalink /patch/25295/
State Accepted
Headers show

Comments

Matt Harbison - Oct. 28, 2017, 4:24 a.m.
# HG changeset patch
# User Matt Harbison <matt_harbison@yahoo.com>
# Date 1509162518 14400
#      Fri Oct 27 23:48:38 2017 -0400
# Branch stable
# Node ID f5cdf17fe89faac2439732269e3988cb05134b0a
# Parent  ea8d40bbb945a15df07a93164ec244a5f6e8d26e
terse: split on repo separator instead of os.sep (issue5715)

The paths being processed are from scmutil.status, and therefore normalized to
'/' separators.
Yuya Nishihara - Oct. 28, 2017, 5:11 a.m.
On Sat, 28 Oct 2017 00:24:56 -0400, Matt Harbison wrote:
> # HG changeset patch
> # User Matt Harbison <matt_harbison@yahoo.com>
> # Date 1509162518 14400
> #      Fri Oct 27 23:48:38 2017 -0400
> # Branch stable
> # Node ID f5cdf17fe89faac2439732269e3988cb05134b0a
> # Parent  ea8d40bbb945a15df07a93164ec244a5f6e8d26e
> terse: split on repo separator instead of os.sep (issue5715)

Queued, thanks.

>          # the filename contains a path separator, it means it's not the direct
>          # child of this directory
> -        if pathsep in filename:
> -            subdir, filep = filename.split(pathsep, 1)
> +        if r'/' in filename:
> +            subdir, filep = filename.split(r'/', 1)

Dropped r'' since a filename should be a bytes string on Python 3.

Patch

diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -404,11 +404,6 @@ 
 
     return commit(ui, repo, recordinwlock, pats, opts)
 
-
-# extracted at module level as it's required each time a file will be added
-# to dirnode class object below
-pathsep = pycompat.ossep
-
 class dirnode(object):
     """
     Represent a directory in user working copy with information required for
@@ -446,8 +441,8 @@ 
 
         # the filename contains a path separator, it means it's not the direct
         # child of this directory
-        if pathsep in filename:
-            subdir, filep = filename.split(pathsep, 1)
+        if r'/' in filename:
+            subdir, filep = filename.split(r'/', 1)
 
             # does the dirnode object for subdir exists
             if subdir not in self.subdirs: