Luke Ross

Colorado

4 releases git clone https://lukeross.name/projects/colorado.git/

Web-based git repository viewer.

Commit 15dfd258bee1d85eb7830834ed0ed4b9425873ad

Fix borked change calc

Committed 7 Jul 2017 by Luke Ross

src/colorado/views.py

@@ -387,9 +387,9 @@ def tree_base_view(slug, type, id, repo, commit, tree, show_download=False):
 	seen = {}
 	by_file = {}
 	commit_count = 0
-	pending = [(commit, commit)]
+	pending = [commit]
 	while pending:
-		current, child = pending.pop(0)
+		current = pending.pop(0)
 		if not current:
 			continue
 		elif current.hexsha in seen:
@@ -397,12 +397,15 @@ def tree_base_view(slug, type, id, repo, commit, tree, show_download=False):
 		else:
 			seen[current.hexsha] = True
 		commit_count += 1
-		for diff in current.diff():
-			if diff.change_type not in "AM":
+		for diff in current.diff(current.parents[0]) if current.parents else current.diff():
+			if not diff.b_path:
 				continue
-			if diff.b_blob and diff.b_blob.hexsha not in by_file:
-				by_file[diff.b_blob.hexsha] = child
-		pending.extend((p, current) for p in current.parents)
+			if diff.b_path in by_file:
+				if by_file[diff.b_path].committed_date < current.committed_date:
+					by_file[diff.b_path] = current
+			else:
+				by_file[diff.b_path] = current
+		pending.extend(current.parents)
 	seen = None  # save mem
 
 	tpl = parse_xml_for_template("repo-home")
@@ -433,8 +436,8 @@ def tree_base_view(slug, type, id, repo, commit, tree, show_download=False):
 		if direntry.type == "blob":
 			ele.findmeld("file-name").content(direntry.name)
 			ele.findmeld("file-size").content(nice_size(direntry.size))
-			if direntry.hexsha in by_file:
-				file_commit = by_file[direntry.hexsha]
+			if direntry.path in by_file:
+				file_commit = by_file[direntry.path]
 				ele.findmeld("file-revdesc").content(file_commit.message)
 				ele.findmeld("file-revdesc").set("href", url_for(
 					".diff_view", slug=slug, id=file_commit.hexsha