Modify

Opened 12 years ago

Closed 12 years ago

#10843 closed defect (fixed)

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

Reported by: anonymous Owned by: Roman Mohr
Priority: normal Component: TracBibPlugin
Severity: blocker Keywords: BibtexSourceSource
Cc: Trac Release: 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'

Attachments (0)

Change History (4)

comment:1 Changed 12 years ago by Christopher Stelma

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 b This class provides different container implementations of bibtex files. 
    2828"""
    2929from api import IBibSourceProvider
    3030from trac.core import implements, Component, TracError
     31from trac.versioncontrol import RepositoryManager
    3132
    3233import bibtexparse
    3334from helper import def_strings
    class BibtexSourceSource(Component): 
    7980        if len(arg) < 2:
    8081            raise TracError('[[Usage: BibAdd(source:file[@rev])')
    8182        elif len(arg) == 2:
    82             revision = 'latest'
     83            revision = None
    8384        else:
    8485            revision = arg[2]
    8586
    8687        file = arg[1]
    8788
    88         repos = self.env.get_repository()
     89        (reponame, repos, path) = RepositoryManager(self.env).get_repository_by_path(file)
    8990
    9091        # load the file from the repository
    91         bib = repos.get_node(file, revision)
     92        bib = repos.get_node(path, revision)
    9293        file = bib.get_content()
    9394        text = file.read()
    9495

comment:2 in reply to:  1 ; Changed 12 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 12 years ago by Christopher Stelma

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 12 years ago by Roman Mohr

Resolution: fixed
Status: newclosed

Thank you for your reports! Fixed in r12604.

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

Roman

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Roman Mohr.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


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

 
Note: See TracTickets for help on using tickets.