Opened 4 years ago

Closed 4 years ago

Adding bibfile from svn source fails with Trac 1.0 and tracbibplugin-r12578

Reported by: Owned by: anonymous Amfortas normal TracBibPlugin blocker BibtexSourceSource 1.0

Description

On a Trac 1.0 instance I installed the trunk version of tracbibplugin-r12578.zip. Having the following repository setup

[repositories]
project.description = This is the ''main'' project repository.
project.dir = /var/share/svn/myrepo
project.type = svn
project.url = https://myserver/repos/myrepo


a wiki page with the BibAdd macro

[[BibAdd(source:project/trunk/vat.bib)]]


produces the following error (the source path was verified to be accessible with a simple [source:project/trunk/vat.bib]-macro):

2013-01-29 17:32:12,223 Trac[formatter] DEBUG: Executing Wiki macro BibAdd by provider <tracbib.tracbib.BibAddMacro object at 0x7f19eae6dad0>
2013-01-29 17:32:12,227 Trac[formatter] ERROR: Macro BibAdd(source:project/trunk/vat.bib) failed:
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/trac/wiki/formatter.py", line 765, in _macro_formatter
return macro.ensure_inline(macro.process(args))
File "/usr/local/lib/python2.7/dist-packages/trac/wiki/formatter.py", line 356, in process
text = self.processor(text)
File "/usr/local/lib/python2.7/dist-packages/trac/wiki/formatter.py", line 343, in _macro_processor
text)
File "build/bdist.linux-x86_64/egg/tracbib/tracbib.py", line 198, in expand_macro
loaded.append(source.source(formatter.req, args[0]))
File "build/bdist.linux-x86_64/egg/tracbib/source.py", line 91, in source
bib = repos.get_node(file, revision)
AttributeError: 'NoneType' object has no attribute 'get_node'


comment:1 follow-up: ↓ 2 Changed 4 years ago by stelminator

yup, I ran into this, too. I think it's do with the default configuration to be for there to not be a default repository. Basically, TracBib is expecting the old style where there's only one repository, and even if there's more than one, for the common use case (and the default configuration in Trac) is for there to be a default repository.

Anyway, looks like TracBib hasn't been updated for multiple repositories (at least not for this use case).

Fix below for

1. don't hardcode default revision for SVN (I'm using Git). (latest -> None).
• This may or may not solve #9028, it's not very specific, and I don't have a Mercurial repository set up to test with at the moment.
2. use the new API method get_repository_by_path on RepositoryManager to just magically do the right thing.
• tracbib/source.py

diff --git a/tracbib/source.py b/tracbib/source.py
index 0a75f5d..5a5b574 100644
 a This class provides different container implementations of bibtex files. """ from api import IBibSourceProvider from trac.core import implements, Component, TracError from trac.versioncontrol import RepositoryManager import bibtexparse from helper import def_strings class BibtexSourceSource(Component): if len(arg) < 2: raise TracError('[[Usage: BibAdd(source:file[@rev])') elif len(arg) == 2: revision = 'latest' revision = None else: revision = arg[2] file = arg[1] repos = self.env.get_repository() (reponame, repos, path) = RepositoryManager(self.env).get_repository_by_path(file) # load the file from the repository bib = repos.get_node(file, revision) bib = repos.get_node(path, revision) file = bib.get_content() text = file.read()

comment:2 in reply to: ↑ 1 ; follow-up: ↓ 3 Changed 4 years ago by anonymous

Replying to stelminator:

I tried your patch(es) with the environment described in this ticket's description:

• 1. (don't hardcode default revision for SVN) doesn't fix the behavior
• 2. (use the new API method) suffices to fix the reported problem
• 1. + 2. (complete patch from stelminator) also fixes the problem

So I hope your patch is going to be part of the next version of TracBibPlugin.

comment:3 in reply to: ↑ 2 Changed 4 years ago by stelminator

Replying to anonymous:

Replying to stelminator:

I tried your patch(es) with the environment described in this ticket's description:

• 1. (don't hardcode default revision for SVN) doesn't fix the behavior
• 2. (use the new API method) suffices to fix the reported problem
• 1. + 2. (complete patch from stelminator) also fixes the problem

So I hope your patch is going to be part of the next version of TracBibPlugin.

My description of 1. was incomplete. 'latest' and None are functionally equivalent for SVN, but not for other version control systems, where None is correct. I wouldn't expect it to have any effect for someone using SVN. The rest of the patch compensates for multiple repositories, including the related API changes for Trac 1.0.

Glad to hear that it worked for someone else.

comment:4 Changed 4 years ago by Amfortas

• Resolution set to fixed
• Status changed from new to closed

Thank you for your reports! Fixed in r12604.

Tested with git, svn and hg on Trac 1.0 and 0.12.

Roman

Modify Ticket

Action
as closed The owner will remain Amfortas.
The resolution will be deleted. Next status will be 'reopened'.
Author

E-mail address and user name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.