History of deleted/moved files #24

raboof opened this Issue Jun 17, 2012 · 9 comments


None yet
3 participants

raboof commented Jun 17, 2012

When visiting a URL pointing to a file that no longer exists on that branch, it would be cute to show the history of the file with that name up to the point where it got (re)moved


jonashaag commented Jun 17, 2012

Right. Probably some flag to git log

raboof commented Jun 28, 2012

One problem was the 'tree' view on the left failed when the path was no longer present on the current revision. Commits 5d60559, 0d55f98 and 9e6bec1 should fix this.

Commit ca16af7 adds a link to the new path to the file.

Those commits are on my claus fork. My python is very rusty so they're most likely no candidates to pull directly, but perhaps they can serve as some inspiration.


posativ commented Jun 29, 2012

It fails with nested subdirectories (throws IOError: [Errno 21] Is a directory: '/Users/user/dir/.git/') when accessing e.g. tree/master/foo/bar/file.py. I try to fix it.

edit: my traceback from my fork: - - [29/Jun/2012 22:09:31] "GET /acrylamid/tree/master/samples HTTP/1.1" 500 -
Error on request:
Traceback (most recent call last):
  File "/Users/ich/dev/klaus/lib/python2.7/site-packages/Werkzeug-0.8.3-py2.7.egg/werkzeug/serving.py", line 159, in run_wsgi
  File "/Users/ich/dev/klaus/lib/python2.7/site-packages/Werkzeug-0.8.3-py2.7.egg/werkzeug/serving.py", line 146, in execute
    application_iter = app(environ, start_response)
  File "/Users/ich/dev/klaus/klaus/__init__.py", line 64, in __call__
    return self.app(environ, start_response)
  File "/Users/ich/dev/klaus/lib/python2.7/site-packages/Werkzeug-0.8.3-py2.7.egg/werkzeug/wsgi.py", line 411, in __call__
    return self.app(environ, start_response)
  File "/Users/ich/dev/klaus/klaus/__init__.py", line 107, in __call__
    return self.wsgi_app(environ, start_response)
  File "/Users/ich/dev/klaus/klaus/__init__.py", line 103, in wsgi_app
    response = self.dispatch(request, start_response)
  File "/Users/ich/dev/klaus/klaus/__init__.py", line 91, in dispatch
    return handler(self, request, **values)
  File "/Users/ich/dev/klaus/klaus/views.py", line 53, in dec
    return func(app, request, response, repo, commit_id, path)
  File "/Users/ich/dev/klaus/klaus/views.py", line 111, in history
    return Response(app.render_template('history.html', **response), 200,
  File "/Users/ich/dev/klaus/klaus/__init__.py", line 79, in render_template
    return self.jinja_env.get_template(template_name).render(**kwargs)
  File "/Users/ich/dev/klaus/lib/python2.7/site-packages/Jinja2-2.6-py2.7.egg/jinja2/environment.py", line 894, in render
    return self.environment.handle_exception(exc_info, True)
  File "/Users/ich/dev/klaus/klaus/templates/history.html", line 1, in top-level template code
    {% extends 'base.html' %}
  File "/Users/ich/dev/klaus/klaus/templates/base.html", line 1, in top-level template code
    {% extends 'skeleton.html' %}
  File "/Users/ich/dev/klaus/klaus/templates/skeleton.html", line 16, in top-level template code
    {% block content %}{% endblock %}
  File "/Users/ich/dev/klaus/klaus/templates/history.html", line 6, in block "content"
    {% set history = repo.history(branch, path.strip('/'), history_length+1, skip) %}
  File "/Users/ich/dev/klaus/klaus/repo.py", line 93, in history
    return [self[sha1] for sha1 in sha1_sums.strip().split('\n')]
  File "/Users/ich/dev/klaus/lib/python2.7/site-packages/dulwich-0.8.5-py2.7-macosx-10.4-x86_64.egg/dulwich/repo.py", line 1112, in __getitem__
    return self.object_store[self.refs[name]]
  File "/Users/ich/dev/klaus/lib/python2.7/site-packages/dulwich-0.8.5-py2.7-macosx-10.4-x86_64.egg/dulwich/repo.py", line 273, in __getitem__
    _, sha = self._follow(name)
  File "/Users/ich/dev/klaus/lib/python2.7/site-packages/dulwich-0.8.5-py2.7-macosx-10.4-x86_64.egg/dulwich/repo.py", line 255, in _follow
    contents = self.read_ref(refname)
  File "/Users/ich/dev/klaus/lib/python2.7/site-packages/dulwich-0.8.5-py2.7-macosx-10.4-x86_64.egg/dulwich/repo.py", line 231, in read_ref
    contents = self.read_loose_ref(refname)
  File "/Users/ich/dev/klaus/lib/python2.7/site-packages/dulwich-0.8.5-py2.7-macosx-10.4-x86_64.egg/dulwich/repo.py", line 548, in read_loose_ref
    f = GitFile(filename, 'rb')
  File "/Users/ich/dev/klaus/lib/python2.7/site-packages/dulwich-0.8.5-py2.7-macosx-10.4-x86_64.egg/dulwich/file.py", line 85, in GitFile
    return file(filename, mode, bufsize)
IOError: [Errno 21] Is a directory: '/Users/ich/dev/acrylamid/.git/'

raboof commented Jun 30, 2012

Hmm yeah this doesn't work the way I expected it to - sometimes generates the wrong url's in the tree, too. I'll have to try and understand that code a bit better.


jonashaag commented Jun 30, 2012

Also return Nil is kinda cool ;)


jonashaag commented Aug 1, 2012

Hey Arnout, I'm working off the milestone "0.2" tickets right now and this issue is one of these.

I'm not sure what the use case for this feature is. You can't reach those kind of URLs using the UI anyway (because there's no link to them in the current version of the tree). You can still look at the history of that file if you first go back in history of the complete tree and then click on the per-file history.

raboof commented Aug 1, 2012

Indeed it might be a bit obscure for klaus itself :). Indeed there are no internal links to moved files, but there might be in external sites (including search engines) and/or inside files.


jonashaag commented Aug 1, 2012

True. The primary use case I see here is hyperlinking -- you don't want your links to become invalid just because the file/folder has been deleted. You'd want to see the history of that file instead to understand what has happened to it in the meantime.

raboof commented Aug 2, 2012


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment