changeset 174:4d8f4b5a73c5

Rename functions
author Franz Glasner <hg@dom66.de>
date Sat, 01 Sep 2018 12:20:01 +0200
parents 242a81f3707e
children a884f134906e
files extensions/timestamps.py
diffstat 1 files changed, 11 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/extensions/timestamps.py	Sat Sep 01 12:19:46 2018 +0200
+++ b/extensions/timestamps.py	Sat Sep 01 12:20:01 2018 +0200
@@ -145,7 +145,7 @@
                 if matcher(fn):
                     st = os.lstat(os.path.join(repo.root, fn))
                     print (fn, st, st.st_mtime, to_isoformat(st.st_mtime))
-                    db.write("%s %s\n" % (db_escape(fn),
+                    db.write("%s %s\n" % (escape_str_field(fn),
                                           to_isoformat(st.st_mtime)))
 
 def restore_timestamps(ui, repo, ctx,
@@ -201,7 +201,12 @@
     return matcher
 
 
-def db_escape(fn):
+def escape_str_field(fn):
+    """Escape the string `fn` for database output if needed
+
+    :return: an escaped version or the original one
+
+    """
     if " " in fn or '@' in fn or '#' in fn:
         return "@%s@" % fn.replace("@", "@@")
     else:
@@ -214,11 +219,11 @@
     # about missing attribute ".readable".
     #
     with io.open(filename, "rb") as db:
-        for f in read_db(db):
+        for f in db_reader(db):
             yield f
 
 
-def read_db(db):
+def db_reader(db):
     """A generator that parses the file `db` yielding records consisting of fields
 
     :param db: the binary file to be read
@@ -310,9 +315,9 @@
 
 
 def to_isoformat(t):
-    """Return the timestamp `t` formatted in full ISO format.
+    """Return the POSIX timestamp `t` formatted in full ISO format.
 
-    `t` is interpreted as UTC timestamp.
+    `t` is expected to be in the UTC timezone.
 
     """
     dt = datetime.datetime.utcfromtimestamp(t)