Patchwork D1072: tersestatus: rework dirnode and tersedir docstrings

login
register
mail settings
Submitter phabricator
Date Oct. 14, 2017, 11:35 a.m.
Message ID <differential-rev-PHID-DREV-kamicptlohrw6io7r6kr-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/24893/
State Superseded
Headers show

Comments

phabricator - Oct. 14, 2017, 11:35 a.m.
dlax created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  Follow-up on refactorings https://phab.mercurial-scm.org/rHG3d6d4b12128e8056f988bf36be1fc46e4c7b29dc and https://phab.mercurial-scm.org/rHG5d98674df18ab8aeaa4a27890061b1e1b99b6f3b of the original
  changeset https://phab.mercurial-scm.org/rHG7e3001b74ab398ef4fc6cad25cc32148f2104dc5 by updating the docstrings of dirnode class and tersedir
  function:
  
  - rewrite dirnode.iterfilepaths()'s docstring (the method got renamed and reimplemented in https://phab.mercurial-scm.org/rHG5d98674df18ab8aeaa4a27890061b1e1b99b6f3b);
  - simplify and update dirnode.tersewalk() to remove reference to 'self' and 'tersedict';
  - use the imperative form of verbs in the first sentence of all docstrings.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D1072

AFFECTED FILES
  mercurial/cmdutil.py

CHANGE DETAILS




To: dlax, #hg-reviewers
Cc: mercurial-devel

Patch

diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -409,9 +409,8 @@ 
 
 class dirnode(object):
     """
-    represents a directory in user working copy
-
-    stores information which is required for purpose of tersing the status
+    Represent a directory in user working copy with information required for
+    the purpose of tersing its status.
 
     path is the path to the directory
 
@@ -431,16 +430,16 @@ 
         self.subdirs = {}
 
     def _addfileindir(self, filename, status):
-        """ adds a file in this directory as the direct child """
+        """Add a file in this directory as a direct child."""
         self.files.append((filename, status))
 
     def addfile(self, filename, status):
         """
-        adds a file which is present in this directory to its direct parent
-        dirnode object
-
-        if the file is not direct child of this directory, we traverse to the
-        directory of which this file is a direct child of and add the file there
+        Add a file to this directory or to its direct parent directory.
+
+        If the file is not direct child of this directory, we traverse to the
+        directory of which this file is a direct child of and add the file
+        there.
         """
 
         # the filename contains a path separator, it means it's not the direct
@@ -463,27 +462,14 @@ 
             self.statuses.add(status)
 
     def iterfilepaths(self):
-        """
-        adds files to the their respective status list in the final tersed list
-
-        path is the path of parent directory of the file
-        files is a list of tuple where each tuple is (filename, status)
-        """
+        """Yield (status, path) for files directly under this directory."""
         for f, st in self.files:
             yield st, os.path.join(self.path, f)
 
     def tersewalk(self, terseargs):
         """
-        a recursive function which process status for a certain directory.
-
-        self is an oject of dirnode class defined below. each object of dirnode
-        class has a set of statuses which files in that directory has. This ease
-        our check whether we can terse that directory or not.
-
-        tersedict is a dictonary which contains each status abbreviation as key
-        and list of files and tersed dirs in that status as value. In each
-        function call we are passing the same dict and adding files and dirs
-        to it.
+        Yield (status, path) obtained by processing the status of this
+        dirnode.
 
         terseargs is the string of arguments passed by the user with `--terse`
         flag.
@@ -494,7 +480,7 @@ 
         subdirectories) share the same status and the user has asked us to terse
         that status. -> yield (status, dirpath)
 
-        2) If '1)' does not happen, we do following:
+        2) Otherwise, we do following:
 
                 a) Yield (status, filepath)  for all the files which are in this
                     directory (only the ones in this directory, not the subdirs)
@@ -523,7 +509,7 @@ 
 
 def tersedir(statuslist, terseargs):
     """
-    terses the status if all the files in a directory shares the same status
+    Terse the status if all the files in a directory shares the same status.
 
     statuslist is scmutil.status() object which contains a list of files for
     each status.
@@ -533,10 +519,6 @@ 
     The function makes a tree of objects of dirnode class, and at each node it
     stores the information required to know whether we can terse a certain
     directory or not.
-
-    tersedict (defined in the function) is a dictionary which has one word key
-    for each status and a list of files and dir in that status as the respective
-    value.
     """
     # the order matters here as that is used to produce final list
     allst = ('m', 'a', 'r', 'd', 'u', 'i', 'c')