#!/usr/bin/env python3 ## ## Copyright (c) 2016, Alliance for Open Media. All rights reserved. ## ## This source code is subject to the terms of the BSD 2 Clause License and ## the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License ## was not distributed with this source code in the LICENSE file, you can ## obtain it at www.aomedia.org/license/software. If the Alliance for Open ## Media Patent License 1.0 was not distributed with this source code in the ## PATENTS file, you can obtain it at www.aomedia.org/license/patent. ## """Classes for representing diff pieces."""
__author__ = "jkoleszar@google.com"
import re
class DiffLines(object): """A container for one half of a diff."""
def Append(self, line): """Adds a line to the DiffHunk and its DiffLines children.""" if line[0] == "-":
self.left.Append(line) elif line[0] == "+":
self.right.Append(line) elif line[0] == " ":
self.left.Append(line)
self.right.Append(line) elif line[0] == "\\": # Ignore newline messages from git diff. pass else: assertFalse, ("Unrecognized character at start of diff line " "%r" % line[0])
self.lines.append(line)
def Complete(self): return self.left.Complete() and self.right.Complete()
if hunk isNone: # Parse file names
diff_file = file_regex.match(line) if diff_file: if line.startswith("---"):
a_line = line
a = diff_file.group(2) continue if line.startswith("+++"):
b_line = line
b = diff_file.group(2) continue
header = [a_line, b_line, line]
hunk = DiffHunk(header, a, b, start_a, len_a, start_b, len_b) else: # Add the current line to the hunk
hunk.Append(line)
# See if the whole hunk has been parsed. If so, yield it and prepare # for the next hunk. if hunk.Complete(): yield hunk
hunk = None
# Partial hunks are a parse error assert hunk isNone
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.