klaus icon indicating copy to clipboard operation
klaus copied to clipboard

History of deleted/moved files

Open raboof opened this issue 12 years ago • 9 comments

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

raboof avatar Jun 17 '12 11:06 raboof

Right. Probably some flag to git log

jonashaag avatar Jun 17 '12 16:06 jonashaag

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

Commit ca16af724d80c522e2fa1d30cab23dd9aec6bc6f 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.

raboof avatar Jun 28 '12 19:06 raboof

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:

127.0.0.1 - - [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
    execute(app)
  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/'

posativ avatar Jun 29 '12 20:06 posativ

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.

raboof avatar Jun 30 '12 09:06 raboof

Also return Nil is kinda cool ;)

jonashaag avatar Jun 30 '12 12:06 jonashaag

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.

jonashaag avatar Aug 01 '12 19:08 jonashaag

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.

raboof avatar Aug 01 '12 21:08 raboof

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.

jonashaag avatar Aug 01 '12 22:08 jonashaag

Exactly!

raboof avatar Aug 02 '12 06:08 raboof