[PATCH] cmdutil: use internal separators when building the terse list

Matt Harbison mharbison72 at gmail.com
Sun Jun 3 22:45:15 UTC 2018


# HG changeset patch
# User Matt Harbison <matt_harbison at yahoo.com>
# Date 1527992292 14400
#      Sat Jun 02 22:18:12 2018 -0400
# Node ID dccb37649baadaa2682c4ce15d908b0f372348a8
# Parent  c19516ec13215f08d30dcb30765e64abf8ba4d69
cmdutil: use internal separators when building the terse list

Status uses internal separators, so this is more correct.  See c974320d20b9 and
362096cfdb1f.  A utility method is still needed, so that the paths starting with
'/' aren't created when `self.path` is empty.

diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -416,7 +416,7 @@ class dirnode(object):
     Represent a directory in user working copy with information required for
     the purpose of tersing its status.
 
-    path is the path to the directory
+    path is the path to the directory, without a trailing '/'
 
     statuses is a set of statuses of all files in this directory (this includes
     all the files in all the subdirectories too)
@@ -453,7 +453,7 @@ class dirnode(object):
 
             # does the dirnode object for subdir exists
             if subdir not in self.subdirs:
-                subdirpath = os.path.join(self.path, subdir)
+                subdirpath = pathutil.join(self.path, subdir)
                 self.subdirs[subdir] = dirnode(subdirpath)
 
             # try adding the file in subdir
@@ -468,7 +468,7 @@ class dirnode(object):
     def iterfilepaths(self):
         """Yield (status, path) for files directly under this directory."""
         for f, st in self.files:
-            yield st, os.path.join(self.path, f)
+            yield st, pathutil.join(self.path, f)
 
     def tersewalk(self, terseargs):
         """
@@ -482,7 +482,7 @@ class dirnode(object):
 
         1) All the files in the directory (including all the files in its
         subdirectories) share the same status and the user has asked us to terse
-        that status. -> yield (status, dirpath)
+        that status. -> yield (status, dirpath).  dirpath will end in '/'.
 
         2) Otherwise, we do following:
 
@@ -499,7 +499,7 @@ class dirnode(object):
             # Making sure we terse only when the status abbreviation is
             # passed as terse argument
             if onlyst in terseargs:
-                yield onlyst, self.path + pycompat.ossep
+                yield onlyst, self.path + '/'
                 return
 
         # add the files to status list
@@ -551,7 +551,7 @@ def tersedir(statuslist, terseargs):
     # process each sub-directory and build tersedict
     for subdir in rootobj.subdirs.values():
         for st, f in subdir.tersewalk(terseargs):
-            tersedict[st].append(util.pconvert(f))
+            tersedict[st].append(f)
 
     tersedlist = []
     for st in allst:


More information about the Mercurial-devel mailing list