idiff.py 文件源码

python
阅读 23 收藏 0 点赞 0 评论 0

项目:viewvc 作者: viewvc 项目源码 文件源码
def unified(fromlines, tolines, context):
  """Generate unified diff"""

  diff = difflib.Differ().compare(fromlines, tolines)
  lastrow = None
  had_changes = 0

  for row in _trim_context(diff, context):
    if row[0].startswith("? "):
      had_changes = 1
      yield _differ_split(lastrow, row[0])
      lastrow = None
    else:
      if lastrow:
        had_changes = 1
        yield _differ_split(lastrow, None)
      lastrow = row

  if lastrow:
    had_changes = 1
    yield _differ_split(lastrow, None)

  if not had_changes:
    yield _item(type=_RCSDIFF_NO_CHANGES)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号