Ejemplo n.º 1
0
    # Normalize filename so we can compare it to other filenames git gives us.
    filename = os.path.normpath(filename)
    filename = os.path.normcase(filename)

    ignored_list = list(args.ignored)
    if not args.no_default_ignores and os.path.exists(
            DEFAULT_IGNORE_FILE_NAME):
        with open(DEFAULT_IGNORE_FILE_NAME) as ignore_file:
            ignored_list.extend(parse_ignore_file(ignore_file))

    if args.ignore_file:
        with open(args.ignore_file) as ignore_file:
            ignored_list.extend(parse_ignore_file(ignore_file))

    ignored = set()
    for c in ignored_list:
        try:
            ignored.add(git_common.hash_one(c))
        except subprocess2.CalledProcessError as e:
            # Custom warning string (the message from git-rev-parse is inappropriate).
            sys.stderr.write('warning: unknown revision \'%s\'.\n' % c)

    return hyper_blame(outbuf, ignored, filename, args.revision)


if __name__ == '__main__':  # pragma: no cover
    setup_color.init()
    with git_common.less() as less_input:
        sys.exit(main(sys.argv[1:], less_input))
Ejemplo n.º 2
0
  try:
    repo_root = git_common.repo_root()
  except subprocess2.CalledProcessError as e:
    stderr.write(e.stderr)
    return e.returncode

  # Make filename relative to the repository root, and cd to the root dir (so
  # all filenames throughout this script are relative to the root).
  filename = os.path.relpath(args.filename, repo_root)
  os.chdir(repo_root)

  # Normalize filename so we can compare it to other filenames git gives us.
  filename = os.path.normpath(filename)
  filename = os.path.normcase(filename)

  ignored = set()
  for c in args.ignored:
    try:
      ignored.add(git_common.hash_one(c))
    except subprocess2.CalledProcessError as e:
      # Custom error message (the message from git-rev-parse is inappropriate).
      stderr.write('fatal: unknown revision \'%s\'.\n' % c)
      return e.returncode

  return hyper_blame(ignored, filename, args.revision, out=stdout, err=stderr)


if __name__ == '__main__':  # pragma: no cover
  with git_common.less() as less_input:
    sys.exit(main(sys.argv[1:], stdout=less_input))