Recently I had an SVN repository with a couple of corrupt revisions that I couldn’t figure out how to fix, which caused Trac to stop displaying revisions after the corruption.
Trying trac-admin resync was no help, throwing this exception :
$ sudo trac-admin /path/to/your/repository/ resync
Resyncing repository history...
Traceback (most recent call last):
File "/usr/bin/trac-admin", line 7, in ?
sys.exit(
File "/usr/lib/python2.4/site-packages/Trac-0.11-py2.4.egg/trac/admin/console.py", line 1249, in run
return admin.onecmd(command)
File "/usr/lib/python2.4/site-packages/Trac-0.11-py2.4.egg/trac/admin/console.py", line 104, in onecmd
rv = cmd.Cmd.onecmd(self, line) or 0
File "/usr/lib64/python2.4/cmd.py", line 219, in onecmd
return func(arg)
File "/usr/lib/python2.4/site-packages/Trac-0.11-py2.4.egg/trac/admin/console.py", line 632, in do_resync
repos = env.get_repository().sync(self._resync_feedback)
File "/usr/lib/python2.4/site-packages/Trac-0.11-py2.4.egg/trac/versioncontrol/cache.py", line 195, in sync
for path,kind,action,bpath,brev in cset.get_changes():
File "/usr/lib/python2.4/site-packages/Trac-0.11-py2.4.egg/trac/versioncontrol/svn_fs.py", line 882, in get_changes
repos.svn_repos_replay(root, e_ptr, e_baton, pool())
File "/usr/lib64/python2.4/site-packages/libsvn/repos.py", line 245, in svn_repos_replay
return apply(_repos.svn_repos_replay, args)
libsvn._core.SubversionException: ("Filesystem path 'trunk/path/to/corrupt/file' is neither a file nor a directory", 160013)
I wasted several days trying to export svn and re-create the repository etc, but continued to get the same corrupt revision.
To get around this error (note this doesn’t fix the corrupt revision - it just allows you to continue using Trac to see later revisions), edit the ‘svn_fs.py’ file listed in the trac-admin stack trace:
$ sudo vi /usr/lib/python2.4/site-packages/Trac-0.11-py2.4.egg/trac/versioncontrol/svn_fs.py
Go to the line mentioned in the stacktrace (line 882 in my case) :
repos.svn_repos_replay(root, e_ptr, e_baton, pool())
and put a try/catch around it :
try:
repos.svn_repos_replay(root, e_ptr, e_baton, pool())
except:
print "Warning : Revision " + str(self.rev) + " could not be read."
Now when you run trac-admin resync , it should display a warning for the corrupted revisions, but continue to sync the repository instead of crashing:
$ sudo trac-admin /path/to/your/repository/ resync
Resyncing repository history...
Warning : Revision 297 could not be read.
Warning : Revision 678 could not be read.
Warning : Revision 906 could not be read.
1101 revisions cached. Done.