Anonymous avatar Anonymous committed b0a1948

[svn r5055] revert r4425

Comments (0)

Files changed (5)

0.11/repository_hook_system/README

-To make the sample TicketChanger plugin work, you need to add this to
-your trac.ini:
-
-[repository-hooks]
-post-commit = TicketChanger
-
-You also need to add a post-commit hook to SVN:
-#!/bin/sh
-
-
-REPOS="$1"
-REV="$2"
-
-
-full_path_to_python full_path_to_repository_hook_system/listener.py --hook=post-commit -p full_path_to_repository $REV

0.11/repository_hook_system/interface.py

     def is_available(repository, hookname):
         """can this subscriber be invoked on this hook?"""        
 
-    def after_commit(changeset):
-        """what to do after a commit"""
-
-    def before_commit(changeset):
-        """what to do before a commit"""
-
-    def other_repository_action(*args):
-        """what to do in the case of some other repositiory action"""
+    def invoke(changeset):
+        """what to do on a commit"""
 
 ### interfaces for the hook system
 
 class IRepositoryChangeListener(Interface):
-    """This is a particular type of repository (SVN, Git, etc)'s change
-    listener."""
+    """listeners to changes from repository hooks"""
 
     def type():
         """list of types of repository to listen for changes"""

0.11/repository_hook_system/listener.py

 
         # find the active listeners
         listeners = ExtensionPoint(IRepositoryChangeListener).extensions(env)
-
+        
         # find the listener for the given repository type and invoke the hook
         for listener in listeners:
             if env.config.get('trac', 'repository_type') in listener.type():
-                changeset = listener.changeset(repo, hook, *args)
+                changeset = listener.changeset(repo, *args)
                 subscribers = listener.subscribers(hook)
                 for subscriber in subscribers:
-                    funcname = hook.replace("-","_")
-                    func = getattr(subscriber, funcname, None)
-                    if func:
-                        func(changeset)
+                    subscriber.invoke(changeset)
         
 def filename():
     return os.path.abspath(__file__.rstrip('c'))

0.11/repository_hook_system/svnhooksystem.py

 from trac.config import ListOption
 from trac.core import *
 from trac.util.text import CRLF
-from trac.versioncontrol.api import NoSuchChangeset
 from utils import iswritable
 
 class SVNHookSystem(FileSystemHooks):
                  in getattr(self, hookname, []) 
                  and subscriber.is_available(self.type(), hookname) ]
 
-    def changeset(self, repo, hook, revision):
+    def changeset(self, repo, revision):
         """ 
         return the changeset given the repository object and revision number
         """
         try:
-            if hook == 'pre-commit':
-                chgset = {'transaction' : revision} #Trac has no way to get a transaction out of svn
-            else:
-                chgset = repo.get_changeset(revision)
+            chgset = repo.get_changeset(revision)
         except NoSuchChangeset:
             # XXX should probably throw an exception (same one?)
             return # out of scope changesets are not cached

0.11/repository_hook_system/ticketchanger.py

     def is_available(self, repository, hookname):
         return True
 
-    def post_commit(self, chgset):
+    def invoke(self, chgset):
 
         # regular expressions        
         ticket_prefix = '(?:#|(?:ticket|issue|bug)[: ]?)'
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.