# HG changeset patch # User Franz Glasner # Date 1541407138 -3600 # Node ID aba2e1d3ac96148e552d71763ed46ddd581ec248 # Parent 75ae41055a0ea984e55294d7754624009b6dd6ce Move current the merge block related input into the .read() method instead of the low-level dbreader() diff -r 75ae41055a0e -r aba2e1d3ac96 extensions/timestamps.py --- 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: