Skip to content

Commit

Permalink
refs #12510, show the prompt if revision is not provided for 'trac-ad…
Browse files Browse the repository at this point in the history
…min changeset added/modified'
  • Loading branch information
walty8 committed Jun 16, 2016
1 parent 1bef9d9 commit de475a1
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 5 deletions.
44 changes: 44 additions & 0 deletions trac/admin/tests/console-tests.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1088,3 +1088,47 @@ The file specified in the --config argument does not exist: %(config_file)s.
Initenv for '%(env_path)s' failed.
File contains parsing errors: %(config_file)s
[line 3]: '[components\n'
===== test_changeset_add_no_project_revision =====
Error: Invalid arguments

changeset added <repos> <rev> [rev] [...]

Notify trac about changesets added to a repository

This command should be called from a post-commit hook. It will trigger a
cache update and notify components about the addition.

===== test_changeset_add_no_revision =====
Error: Invalid arguments

changeset added <repos> <rev> [rev] [...]

Notify trac about changesets added to a repository

This command should be called from a post-commit hook. It will trigger a
cache update and notify components about the addition.

===== test_changeset_modify_no_project_revision =====
Error: Invalid arguments

changeset modified <repos> <rev> [rev] [...]

Notify trac about changesets modified in a repository

This command should be called from a post-revprop hook after revision
properties like the commit message, author or date have been changed. It
will trigger a cache update for the given revisions and notify components
about the change.

===== test_changeset_modify_no_revision =====
Error: Invalid arguments

changeset modified <repos> <rev> [rev] [...]

Notify trac about changesets modified in a repository

This command should be called from a post-revprop hook after revision
properties like the commit message, author or date have been changed. It
will trigger a cache update for the given revisions and notify components
about the change.

22 changes: 21 additions & 1 deletion trac/admin/tests/console.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ def diff():
expected_lines = ['%s\n' % x for x in expected_results.split('\n')]
return ''.join(difflib.unified_diff(expected_lines, output_lines,
'expected', 'actual'))
if '[...]' in expected_results:
if '[...]' in expected_results and 'changeset' not in expected_results:
m = re.match(expected_results.replace('[...]', '.*'), output,
re.MULTILINE)
unittest.TestCase.assertTrue(self, m,
Expand Down Expand Up @@ -1503,6 +1503,26 @@ def test_help_session_purge(self):
doc = self._get_command_help('session', 'purge')
self.assertIn(u'"YYYY-MM-DDThh:mm:ss±hh:mm"', doc)

def test_changeset_add_no_project_revision(self):
rv, output = self._execute('changeset added')
self.assertEqual(2, rv, output)
self.assertExpectedResult(output)

def test_changeset_add_no_revision(self):
rv, output = self._execute('changeset added project')
self.assertEqual(2, rv, output)
self.assertExpectedResult(output)

def test_changeset_modify_no_project_revision(self):
rv, output = self._execute('changeset modified')
self.assertEqual(2, rv, output)
self.assertExpectedResult(output)

def test_changeset_modify_no_revision(self):
rv, output = self._execute('changeset modified project')
self.assertEqual(2, rv, output)
self.assertExpectedResult(output)


class TracadminNoEnvTestCase(unittest.TestCase):

Expand Down
8 changes: 4 additions & 4 deletions trac/versioncontrol/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,19 +88,19 @@ def _complete_repos(self, args):
if len(args) == 1:
return self.get_reponames()

def _do_changeset_added(self, reponame, *revs):
def _do_changeset_added(self, reponame, first_rev, *revs):
if is_default(reponame):
reponame = ''
rm = RepositoryManager(self.env)
errors = rm.notify('changeset_added', reponame, revs)
errors = rm.notify('changeset_added', reponame, (first_rev,) + revs)
for error in errors:
printout(error)

def _do_changeset_modified(self, reponame, *revs):
def _do_changeset_modified(self, reponame, first_rev, *revs):
if is_default(reponame):
reponame = ''
rm = RepositoryManager(self.env)
errors = rm.notify('changeset_modified', reponame, revs)
errors = rm.notify('changeset_modified', reponame, (first_rev,) + revs)
for error in errors:
printout(error)

Expand Down

0 comments on commit de475a1

Please sign in to comment.