Anonymous avatar Anonymous committed a74e304

0.12.1dev: Formalize the notion of repository scope by defining a default, "empty" scope in `Repository.scope`.

Part of #9566.

Comments (0)

Files changed (4)

trac/versioncontrol/api.py

 class Repository(object):
     """Base class for a repository provided by a version control system."""
 
+    scope = '/'
+    
     def __init__(self, name, params, log):
         """Initialize a repository.
         

trac/versioncontrol/cache.py

                     next_youngest = self.repos.oldest_rev
                     # Ugly hack needed because doing that everytime in 
                     # oldest_rev suffers from horrendeous performance (#5213)
-                    if hasattr(self.repos, 'scope'):
-                        if self.repos.scope != '/' and not \
-                                self.repos.has_node('/', next_youngest):
-                            next_youngest = self.repos.next_rev(next_youngest,
-                                    find_initial_rev=True)
+                    if self.repos.scope != '/' and not \
+                            self.repos.has_node('/', next_youngest):
+                        next_youngest = self.repos.next_rev(next_youngest,
+                                find_initial_rev=True)
                     next_youngest = self.repos.normalize_rev(next_youngest)
                 except TracError:
                     # can't normalize oldest_rev: repository was empty
                                date)
         else:
             raise NoSuchChangeset(rev)
-        self.scope = getattr(repos.repos, 'scope', '')
 
     def get_changes(self):
         db = self.env.get_db_cnx()

trac/versioncontrol/svn_authz.py

 
             rm = RepositoryManager(self.env)
             repos = rm.get_repository(resource.parent.id)
-            scope = getattr(repos, 'scope', '')
             modules = [resource.parent.id or self.authz_module_name]
             if modules[0]:
                 modules.append('')
 
             def check_path(path):
-                path = '/' + join(scope, path)
+                path = '/' + join(repos.scope, path)
                 if path != '/':
                     path += '/'
                 

trac/versioncontrol/tests/svn_authz.py

                         return Mock(get_changes=get_changes)
                     return Mock(scope='/scope',
                                 get_changeset=get_changeset)
-                return Mock()
+                return Mock(scope='/')
         
         rm.__class__ = TestRepositoryManager
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.