Bug that caused inifinite recursion while searching for non-existant document.
authorŁukasz Rekucki <lrekucki@gmail.com>
Mon, 26 Apr 2010 16:54:18 +0000 (18:54 +0200)
committerŁukasz Rekucki <lrekucki@gmail.com>
Mon, 26 Apr 2010 16:54:18 +0000 (18:54 +0200)
apps/wiki/urls.py
lib/vstorage.py
redakcja/urls.py

index c5c08a1..bfc799f 100644 (file)
@@ -1,11 +1,12 @@
 from django.conf.urls.defaults import *
 from django.conf.urls.defaults import *
-from django.conf import settings
 
 urlpatterns = patterns('wiki.views',
     url(r'^$',
         'document_list', name='wiki_doclist'),
 
 urlpatterns = patterns('wiki.views',
     url(r'^$',
         'document_list', name='wiki_doclist'),
+
     url(r'^create/(?P<name>[^/]+)',
         'document_create_missing', name='wiki_create_missing'),
     url(r'^create/(?P<name>[^/]+)',
         'document_create_missing', name='wiki_create_missing'),
+
     url(r'^gallery/(?P<directory>[^/]+)$',
         'document_gallery', name="wiki_gallery"),
     url(r'^(?P<name>[^/]+)/history$',
     url(r'^gallery/(?P<directory>[^/]+)$',
         'document_gallery', name="wiki_gallery"),
     url(r'^(?P<name>[^/]+)/history$',
index 82151da..b4acaf3 100644 (file)
@@ -328,16 +328,20 @@ class VersionedStorage(object):
         """Find the last revision in which the file existed."""
         repo_file = self._title_to_file(title)
         changectx = self._changectx()  # start with tip
         """Find the last revision in which the file existed."""
         repo_file = self._title_to_file(title)
         changectx = self._changectx()  # start with tip
+        visited = set()
+
         stack = [changectx]
         stack = [changectx]
+        visited.add(changectx)
 
         while repo_file not in changectx:
             if not stack:
 
         while repo_file not in changectx:
             if not stack:
-                return None
+                raise DocumentNotFound(title)
 
             changectx = stack.pop()
             for parent in changectx.parents():
 
             changectx = stack.pop()
             for parent in changectx.parents():
-                if parent != changectx:
+                if parent not in visited:
                     stack.append(parent)
                     stack.append(parent)
+                    visited.add(parent)
 
         try:
             fctx = changectx[repo_file]
 
         try:
             fctx = changectx[repo_file]
index 904ad44..f8538fa 100644 (file)
@@ -16,6 +16,9 @@ urlpatterns = patterns('',
     url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
     (r'^admin/', include(admin.site.urls)),
 
     url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
     (r'^admin/', include(admin.site.urls)),
 
+    url(r'^$', 'django.views.generic.simple.redirect_to', {'url': '/documents/'}),
+    url(r'^documents/', include('wiki.urls')),
+
     # Static files (should be served by Apache)
     url(r'^%s(?P<path>.+)$' % settings.MEDIA_URL[1:], 'django.views.static.serve',
         {'document_root': settings.MEDIA_ROOT, 'show_indexes': True}),
     # Static files (should be served by Apache)
     url(r'^%s(?P<path>.+)$' % settings.MEDIA_URL[1:], 'django.views.static.serve',
         {'document_root': settings.MEDIA_ROOT, 'show_indexes': True}),
@@ -23,7 +26,4 @@ urlpatterns = patterns('',
         {'document_root': settings.MEDIA_ROOT, 'show_indexes': True}),
     url(r'^%s(?P<path>.+)$' % settings.STATIC_URL[1:], 'django.views.static.serve',
         {'document_root': settings.STATIC_ROOT, 'show_indexes': True}),
         {'document_root': settings.MEDIA_ROOT, 'show_indexes': True}),
     url(r'^%s(?P<path>.+)$' % settings.STATIC_URL[1:], 'django.views.static.serve',
         {'document_root': settings.STATIC_ROOT, 'show_indexes': True}),
-
-    url(r'^$', 'django.views.generic.simple.redirect_to', {'url': '/documents/'}),
-    url(r'^documents/', include('wiki.urls')),
 )
 )