|
@@ -68,6 +68,14 @@ from dulwich.archive import (
|
|
|
from dulwich.client import (
|
|
|
get_transport_and_path,
|
|
|
)
|
|
|
+from dulwich.diff_tree import (
|
|
|
+ CHANGE_ADD,
|
|
|
+ CHANGE_DELETE,
|
|
|
+ CHANGE_MODIFY,
|
|
|
+ CHANGE_RENAME,
|
|
|
+ CHANGE_COPY,
|
|
|
+ RENAME_CHANGE_TYPES,
|
|
|
+ )
|
|
|
from dulwich.errors import (
|
|
|
SendPackError,
|
|
|
UpdateRefsError,
|
|
@@ -423,14 +431,45 @@ def show_object(repo, obj, decode, outstream):
|
|
|
}[obj.type_name](repo, obj, decode, outstream)
|
|
|
|
|
|
|
|
|
+def print_name_status(changes):
|
|
|
+ """Print a simple status summary, listing changed files.
|
|
|
+ """
|
|
|
+ for change in changes:
|
|
|
+ if not change:
|
|
|
+ continue
|
|
|
+ if type(change) is list:
|
|
|
+ change = change[0]
|
|
|
+ if change.type == CHANGE_ADD:
|
|
|
+ path1 = change.new.path
|
|
|
+ path2 = ''
|
|
|
+ kind = 'A'
|
|
|
+ elif change.type == CHANGE_DELETE:
|
|
|
+ path1 = change.old.path
|
|
|
+ path2 = ''
|
|
|
+ kind = 'D'
|
|
|
+ elif change.type == CHANGE_MODIFY:
|
|
|
+ path1 = change.new.path
|
|
|
+ path2 = ''
|
|
|
+ kind = 'M'
|
|
|
+ elif change.type in RENAME_CHANGE_TYPES:
|
|
|
+ path1 = change.old.path
|
|
|
+ path2 = change.new.path
|
|
|
+ if change.type == CHANGE_RENAME:
|
|
|
+ kind = 'R'
|
|
|
+ elif change.type == CHANGE_COPY:
|
|
|
+ kind = 'C'
|
|
|
+ yield '%-8s%-20s%-20s' % (kind, path1, path2)
|
|
|
+
|
|
|
+
|
|
|
def log(repo=".", paths=None, outstream=sys.stdout, max_entries=None,
|
|
|
- reverse=False):
|
|
|
+ reverse=False, name_status=False):
|
|
|
"""Write commit logs.
|
|
|
|
|
|
:param repo: Path to repository
|
|
|
:param paths: Optional set of specific paths to print entries for
|
|
|
:param outstream: Stream to write log output to
|
|
|
:param reverse: Reverse order in which entries are printed
|
|
|
+ :param name_status: Print name status
|
|
|
:param max_entries: Optional maximum number of entries to display
|
|
|
"""
|
|
|
with open_repo_closing(repo) as r:
|
|
@@ -439,6 +478,9 @@ def log(repo=".", paths=None, outstream=sys.stdout, max_entries=None,
|
|
|
for entry in walker:
|
|
|
decode = lambda x: commit_decode(entry.commit, x)
|
|
|
print_commit(entry.commit, decode, outstream)
|
|
|
+ if name_status:
|
|
|
+ outstream.writelines(
|
|
|
+ [l+'\n' for l in print_name_status(entry.changes())])
|
|
|
|
|
|
|
|
|
# TODO(jelmer): better default for encoding?
|