Opened 9 years ago
Closed 9 years ago
#12274 closed defect (fixed)
Trap exceptions in Subversion backend when revision number is negative
Reported by: | Ryan J Ollos | Owned by: | Ryan J Ollos |
---|---|---|---|
Priority: | normal | Milestone: | 1.0.10 |
Component: | version control | Version: | |
Severity: | normal | Keywords: | svn |
Cc: | Branch: | ||
Release Notes: |
|
||
API Changes: | |||
Internal Changes: |
Description
Invalid revisions such as a
are trapped in the Subversion backend and a NoSuchChangeset
exception is raised. However a negative revision number is not trapped and the SubversionException
propagates. We should trap the exception and raise a NoSuchChangeset
exception.
20:47:11 Trac[formatter] ERROR: Macro Include(source:proj1/workflow@-1) failed: Traceback (most recent call last): File "/Users/rjollos/Documents/Workspace/th-dev/IncludeMacro/pve/lib/python2.7/site-packages/trac/wiki/formatter.py", line 789, in _macro_formatter return macro.ensure_inline(macro.process(args)) File "/Users/rjollos/Documents/Workspace/th-dev/IncludeMacro/pve/lib/python2.7/site-packages/trac/wiki/formatter.py", line 358, in process text = self.processor(text) File "/Users/rjollos/Documents/Workspace/th-dev/IncludeMacro/pve/lib/python2.7/site-packages/trac/wiki/formatter.py", line 345, in _macro_processor text) File "/Users/rjollos/Documents/Workspace/th-dev/IncludeMacro/trunk/includemacro/macros.py", line 130, in expand_macro dest_format) File "/Users/rjollos/Documents/Workspace/th-dev/IncludeMacro/trunk/includemacro/macros.py", line 202, in _get_source node = repos.get_node(path, rev) File "/Users/rjollos/Documents/Workspace/th-dev/IncludeMacro/pve/lib/python2.7/site-packages/trac/versioncontrol/cache.py", line 298, in get_node return self.repos.get_node(path, self.normalize_rev(rev)) File "/Users/rjollos/Documents/Workspace/th-dev/IncludeMacro/pve/lib/python2.7/site-packages/tracopt/versioncontrol/svn/svn_fs.py", line 511, in get_node return SubversionNode(path, rev, self, self.pool) File "/Users/rjollos/Documents/Workspace/th-dev/IncludeMacro/pve/lib/python2.7/site-packages/tracopt/versioncontrol/svn/svn_fs.py", line 768, in __init__ self.root = fs.revision_root(self.fs_ptr, rev, pool) File "/Users/rjollos/Documents/Workspace/th-dev/IncludeMacro/pve/lib/python2.7/site-packages/libsvn/fs.py", line 319, in svn_fs_revision_root return _fs.svn_fs_revision_root(*args) SubversionException: 160006 - Invalid revision number '-1'
Attachments (0)
Change History (4)
comment:1 by , 9 years ago
Release Notes: | modified (diff) |
---|
comment:2 by , 9 years ago
I think we should raise NoSuchChangeset
/NoSuchNode
rather than TracError
from SubversionRepository.get_node
and SubversionNode.__init__
.
-
tracopt/versioncontrol/svn/svn_fs.py
diff --git a/tracopt/versioncontrol/svn/svn_fs.py b/tracopt/versioncontrol/svn/svn_fs.py index ed20a356d..6d0b7e756 100644
a b class SvnCachedRepository(CachedRepository): 258 258 def rev_db(self, rev): 259 259 return int(rev or 0) 260 260 261 def normalize_rev(self, rev): 262 return self.repos.normalize_rev(rev) 263 261 264 262 265 class SubversionConnector(Component): 263 266 … … class SubversionRepository(Repository): 429 432 else: 430 433 try: 431 434 rev = int(rev) 432 if rev <= self.youngest_rev:435 if 0 <= rev <= self.youngest_rev: 433 436 return rev 434 437 except (ValueError, TypeError): 435 438 pass … … class SubversionNode(Node): 768 771 try: 769 772 self.root = fs.revision_root(self.fs_ptr, rev, pool) 770 773 except core.SubversionException, e: 771 raise TracError(e)774 raise NoSuchNode(path, rev, exception_to_unicode(e)) 772 775 node_type = fs.check_path(self.root, self._scoped_path_utf8, pool) 773 776 if not node_type in _kindmap: 774 777 raise NoSuchNode(path, rev) -
tracopt/versioncontrol/svn/tests/svn_fs.py
diff --git a/tracopt/versioncontrol/svn/tests/svn_fs.py b/tracopt/versioncontrol/svn/tests/svn_fs.py index 4b69e7fea..d1484aec8 100644
a b class NormalTests(object): 130 130 self.assertEqual(HEAD, self.repos.normalize_rev(None)) 131 131 self.assertEqual(11, self.repos.normalize_rev('11')) 132 132 self.assertEqual(11, self.repos.normalize_rev(11)) 133 self.assertRaises(NoSuchChangeset, self.repos.normalize_rev, -1) 134 self.assertRaises(NoSuchChangeset, self.repos.normalize_rev, -42) 133 135 134 136 def test_rev_navigation(self): 135 137 self.assertEqual(1, self.repos.oldest_rev) … … class NormalTests(object): 169 171 self.assertEqual(HEAD, node.created_rev) 170 172 self.assertEqual(datetime(2015, 6, 15, 14, 9, 13, 664490, utc), 171 173 node.last_modified) 172 self.assertRaises( TracError, self.repos.get_node, u'/', -1)174 self.assertRaises(NoSuchChangeset, self.repos.get_node, u'/', -1) 173 175 node = self.repos.get_node(u'/tête') 174 176 self.assertEqual(u'tête', node.name) 175 177 self.assertEqual(u'/tête', node.path)
comment:3 by , 9 years ago
Thanks, I should have thought to use the NoSuchChangeset
exception. I'll push the changes later today.
comment:4 by , 9 years ago
Release Notes: | modified (diff) |
---|---|
Resolution: | → fixed |
Status: | assigned → closed |
comment:2 changes committed in [14469,14471], merged in [14470,14472].
Fixed on 1.0-stable in [14454] , merged to trunk in [14455].