Convert log graphviz to be more modular
So that we can use it in conjunction with graph-objects
This commit is contained in:
parent
e7838a5294
commit
7a63ccd990
25
libwyag.py
25
libwyag.py
@ -460,12 +460,9 @@ argsp.add_argument("commit",
|
||||
def cmd_log(args):
|
||||
repo = repo_find()
|
||||
|
||||
print("digraph wyaglog{")
|
||||
print(" node[shape=rect]")
|
||||
log_graphviz(repo, object_find(repo, args.commit), set())
|
||||
print("}")
|
||||
print(log_graphviz(repo, args.commit))
|
||||
|
||||
def log_graphviz(repo, sha, seen):
|
||||
def log_graphviz_recurse(repo, sha, seen):
|
||||
if sha in seen:
|
||||
return
|
||||
seen.add(sha)
|
||||
@ -478,7 +475,7 @@ def log_graphviz(repo, sha, seen):
|
||||
|
||||
if "\n" in message: # keep only the first line
|
||||
message = message[:message.index("\n")]
|
||||
print(f" c_{sha} [label=\"{sha[0:7]}: {message}\"]")
|
||||
yield f" c_{sha} [label=\"{sha[0:7]}: {message}\"]"
|
||||
assert commit.fmt==b'commit'
|
||||
|
||||
if not b'parent' in commit.kvlm.keys():
|
||||
@ -492,8 +489,20 @@ def log_graphviz(repo, sha, seen):
|
||||
|
||||
for p in parents:
|
||||
p = p.decode("ascii")
|
||||
print (f" c_{sha} -> c_{p}")
|
||||
log_graphviz(repo, p, seen)
|
||||
yield f" c_{sha} -> c_{p}"
|
||||
yield from log_graphviz_recurse(repo, p, seen)
|
||||
|
||||
def log_graphviz(repo, sha):
|
||||
seen = set()
|
||||
|
||||
graph = "digraph wyaglog{\n"
|
||||
graph += " node[shape=rect]\n"
|
||||
for line in log_graphviz_recurse(repo, object_find(repo, sha), seen):
|
||||
graph += " " + line + "\n"
|
||||
|
||||
graph += "}"
|
||||
|
||||
return graph
|
||||
|
||||
class GitTreeLeaf (object):
|
||||
def __init__(self, mode, path, sha):
|
||||
|
Loading…
Reference in New Issue
Block a user