changeset 242:aba2e1d3ac96

Move current the merge block related input into the .read() method instead of the low-level dbreader()
author Franz Glasner <hg@dom66.de>
date Mon, 05 Nov 2018 09:38:58 +0100
parents 75ae41055a0e
children 6b8a6329875a
files extensions/timestamps.py
diffstat 1 files changed, 15 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/extensions/timestamps.py	Sun Nov 04 09:45:21 2018 +0100
+++ b/extensions/timestamps.py	Mon Nov 05 09:38:58 2018 +0100
@@ -380,7 +380,12 @@
 
     :param fp: the binary file object to be read
 
-    :return: a record which is a list of fields
+    :return: a triple (lineno, mergeblock_type, record) with
+             `lineno` the physical line number in the input file,
+             `mergeblock_type` a sigil (one of '', '<', '|', '=') that denotes
+             whether the record was read with in a normal block, the `local`
+             block, then `base` block or the `other` block,
+             and the `record` which itself is a list of fields
 
     """
     fp = io.BufferedReader(fp)
@@ -395,11 +400,8 @@
             f = ''.join(field)
             if f or record:
                 record.append(f)
-            # an empty line is an empty record
-
-            # XXX FIXME: which of the merge blocks to return?
-            if not mergeblock_type:
-                yield (lineno, record)
+            # Note: an empty line is an empty record
+            yield (lineno, mergeblock_type, record)
 
             lineno += 1
             record = []
@@ -505,14 +507,13 @@
     # EOF
     # Check whether the last line contained data but no CR or LF
     #
+    # But note: an empty line is an empty record: do not yield
+    # trailing empty lines
+    #
     f = ''.join(field)
     if f or record:
         record.append(f)
-        # an empty line is an empty record: do not yield trailing empty lines
-
-        # XXX FIXME: which of the merge blocks to return?
-        if not mergeblock_type:
-            yield (lineno, record)
+        yield (lineno, mergeblock_type, record)
 
 
 def db_writer(fp):
@@ -672,7 +673,9 @@
         """
         self._init()
         datano = 0
-        for lineno, record in db_reader(fp):
+        for lineno, mergeblock_type, record in db_reader(fp):
+            if mergeblock_type:
+                continue
             if len(record) == 2:
                 k, v = record
                 if self._version is None: