diff --git a/trac/admin/tests/console-tests.txt b/trac/admin/tests/console-tests.txt
|
a
|
b
|
|
| 11 | 11 | attachment export Export an attachment from a resource to a file or stdout |
| 12 | 12 | attachment list List attachments of a resource |
| 13 | 13 | attachment remove Remove an attachment from a resource |
| | 14 | changeset added Notify trac about changesets added to a repository |
| | 15 | changeset modified Notify trac about changesets modified in a repository |
| 14 | 16 | component add Add a new component |
| 15 | 17 | component chown Change component ownership |
| 16 | 18 | component list Show available components |
| … |
… |
|
| 38 | 40 | repository add Add a source repository |
| 39 | 41 | repository alias Create an alias for a repository |
| 40 | 42 | repository list List source repositories |
| 41 | | repository notify Notify trac about repository events |
| 42 | 43 | repository remove Remove a source repository |
| 43 | 44 | repository rename Rename a source repository |
| 44 | 45 | repository resync Re-synchronize trac with repositories |
diff --git a/trac/versioncontrol/admin.py b/trac/versioncontrol/admin.py
|
a
|
b
|
|
| 17 | 17 | from trac.core import * |
| 18 | 18 | from trac.util.text import print_table, printerr, printout |
| 19 | 19 | from trac.util.translation import _, ngettext |
| 20 | | from trac.versioncontrol import IRepositoryChangeListener, RepositoryManager |
| | 20 | from trac.versioncontrol import RepositoryManager |
| 21 | 21 | |
| 22 | 22 | |
| 23 | 23 | class VersionControlAdmin(Component): |
| … |
… |
|
| 28 | 28 | # IAdminCommandProvider methods |
| 29 | 29 | |
| 30 | 30 | def get_admin_commands(self): |
| | 31 | yield ('changeset added', '<repos> <rev> [rev] [...]', |
| | 32 | """Notify trac about changesets added to a repository |
| | 33 | |
| | 34 | This command should be called from a post-commit hook. It will |
| | 35 | trigger a cache update and notify components about the addition. |
| | 36 | """, |
| | 37 | self._complete_repos, self._do_changeset_added) |
| | 38 | yield ('changeset modified', '<repos> <rev> [rev] [...]', |
| | 39 | """Notify trac about changesets modified in a repository |
| | 40 | |
| | 41 | This command should be called from a post-revprop hook after |
| | 42 | revision properties like the commit message, author or date |
| | 43 | have been changed. It will trigger a cache update for the given |
| | 44 | revisions and notify components about the change. |
| | 45 | """, |
| | 46 | self._complete_repos, self._do_changeset_modified) |
| 31 | 47 | yield ('repository add', '<repos> <dir> [type]', |
| 32 | 48 | 'Add a source repository', |
| 33 | 49 | self._complete_add, self._do_add) |
| … |
… |
|
| 37 | 53 | yield ('repository list', '', |
| 38 | 54 | 'List source repositories', |
| 39 | 55 | None, self._do_list) |
| 40 | | yield ('repository notify', '<event> <repos> <rev> [rev] [...]', |
| 41 | | """Notify trac about repository events |
| 42 | | |
| 43 | | The event "changeset_added" notifies that new changesets have |
| 44 | | been added to a repository. |
| 45 | | |
| 46 | | The event "changeset_modified" notifies that existing changesets |
| 47 | | have been modified in a repository. |
| 48 | | """, |
| 49 | | self._complete_notify, self._do_notify) |
| 50 | 56 | yield ('repository remove', '<repos>', |
| 51 | 57 | 'Remove a source repository', |
| 52 | 58 | self._complete_repos, self._do_remove) |
| … |
… |
|
| 75 | 81 | """, |
| 76 | 82 | self._complete_repos, self._do_sync) |
| 77 | 83 | |
| 78 | | _notify_events = [each for each in IRepositoryChangeListener.__dict__ |
| 79 | | if not each.startswith('_')] |
| 80 | | |
| 81 | 84 | def get_supported_types(self): |
| 82 | 85 | rm = RepositoryManager(self.env) |
| 83 | 86 | return [type_ for connector in rm.connectors |
| … |
… |
|
| 95 | 98 | elif len(args) == 3: |
| 96 | 99 | return self.get_supported_types() |
| 97 | 100 | |
| 98 | | def _complete_notify(self, args): |
| 99 | | if len(args) == 1: |
| 100 | | return self._notify_events |
| 101 | | elif len(args) == 2: |
| 102 | | return self.get_reponames() |
| 103 | | |
| 104 | 101 | def _complete_repos(self, args): |
| 105 | 102 | if len(args) == 1: |
| 106 | 103 | return self.get_reponames() |
| 107 | 104 | |
| | 105 | def _do_changeset_added(self, reponame, *revs): |
| | 106 | rm = RepositoryManager(self.env) |
| | 107 | rm.notify('changeset_added', reponame, revs, None) |
| | 108 | |
| | 109 | def _do_changeset_modified(self, reponame, *revs): |
| | 110 | rm = RepositoryManager(self.env) |
| | 111 | rm.notify('changeset_modified', reponame, revs, None) |
| | 112 | |
| 108 | 113 | def _do_add(self, reponame, dir, type_=None): |
| 109 | 114 | if reponame == '(default)': |
| 110 | 115 | reponame = '' |
| … |
… |
|
| 143 | 148 | alias, info.get('dir', ''))) |
| 144 | 149 | print_table(values, [_('Name'), _('Type'), _('Alias'), _('Directory')]) |
| 145 | 150 | |
| 146 | | def _do_notify(self, event, reponame, *revs): |
| 147 | | if event not in self._notify_events: |
| 148 | | raise TracError(_('Unknown notify event "%s"' % event)) |
| 149 | | rm = RepositoryManager(self.env) |
| 150 | | rm.notify(event, reponame, revs, None) |
| 151 | | |
| 152 | 151 | def _do_remove(self, reponame): |
| 153 | 152 | if reponame == '(default)': |
| 154 | 153 | reponame = '' |