diff --git a/repo.py b/repo.py index 9699e0c4dbabc0db072e3b19f507997adf0d7090..da30ca6e186690ff6166f2c80966f9e0ada70148 100644 --- a/repo.py +++ b/repo.py @@ -46,15 +46,22 @@ class RepoWrapper(dulwich.repo.Repo): def _path_changed_between(self, path, commit1, commit2): path, filename = os.path.split(path) - blob1 = self.get_tree(commit1, path)[filename] - blob2 = self.get_tree(commit2, path)[filename] - return blob1[1] != blob2[1] + tree1 = self.get_tree(commit1, path) + tree2 = self.get_tree(commit2, path) + try: + blob1 = tree1[filename] + blob2 = tree2[filename] + return blob1 == blob2 + except KeyError: + # file new or deleted in tree2 + return True def get_tree(self, commit, path): tree = self[commit.tree] if path: for directory in path.split('/'): - tree = self[tree[directory][1]] + if directory: + tree = self[tree[directory][1]] return tree def listdir(self, commit, root=None): diff --git a/templates/view_commit.html b/templates/view_commit.html index a9a7b03f5399f99e3deb5060b325f455cd147179..6849c9f94ce2f1e81eb8e23879129d8332159fd6 100644 --- a/templates/view_commit.html +++ b/templates/view_commit.html @@ -15,7 +15,7 @@ <span class=datetime>{{ commit.commit_time|timesince }} ago</span> </div> <div class=changes> - {{ repo.commit_diff(commit)|pygmentize }} + {{ repo.commit_diff(commit)|pygmentize('udiff') }} </div> </div>