linepat = re.compile(r'[^|\/\\]')
class Commit:
- _line = None
- _hash = None
- _children = None
- _parents = {}
- _message= None
- _message_pos = None
- _node_pos = None
- _node_color = None
-
def __init__(self,line):
+ self._line = None
+ self._hash = None
+ self._children = {}
+ self._parents = {}
+ self._message= None
+ self._message_pos = None
+ self._node_pos = None
+ self._node_color = None
self._line = line
pos = 0
self._message = word
self._message_pos = pos
- pos = pos + 1
+ pos = pos + 1
+ def update_parent (self, child):
+ self._parents[child._hash] = child
+ child._children[self._hash] = self
+
+ def export_to_tikz(self, ypos):
+ print("export Commit:")
+
class Branch:
- _name = ""
- _hash = ""
- _commit = ""
-
def __init__(self, line):
+ self._hash=""
words = line.split(" ")
self._name = words.pop(0)
- self._hash = words.pop(0)
+ while self._hash == "":
+ self._hash = words.pop(0)
self._commit = " ".join(words)
def to_s_long(self):
print(" ".join({self._name, self._hash, self._commit}))
class Repo:
- _commits = {}
+
+ def __init__(self):
+ self._commits = {}
+ self._branches = []
def add_commit(self, commit):
if commit._hash:
self._commits[commit._hash] = commit
+ def resolve_parents(self):
+ for key_c, commit in self._commits.iteritems():
+ for key_p, parent in commit._parents.iteritems():
+ commit.update_parent(self._commits[key_p])
+
+ def add_branch(self, branch):
+ if self._commits.has_key(branch._hash):
+ branch._commit = self._commits[branch._hash]
+ self._branches.append( branch)
cmd = "git log --graph --oneline --parents"
return_output = check_output(cmd, shell=True)
-print(return_output.split("\n"))
+#print(return_output.split("\n"))
r = Repo()
for line in return_output.split("\n"):
- r.add_commit(Commit(line))
+ if not line == "":
+ r.add_commit(Commit(line))
+
+r.resolve_parents()
+
+cmd = "git branch -av | cut -b 3-"
+
+return_output = check_output(cmd, shell=True)
+for line in return_output.split("\n"):
+ if not line == "":
+ r.add_branch(Branch(line))
-print()
\ No newline at end of file
+print(return_output.split("\n"))
\ No newline at end of file