Edgewall Software
Home
Trac
Trac Hacks
Genshi
Babel
Bitten
Home
Download
Documentation
Mailing Lists
License
FAQ
Search:
Login
Preferences
Help/Guide
About Trac
Wiki
Timeline
Roadmap
Browse Source
View Tickets
New Ticket
Search
Context Navigation
+0
Start Page
Index
History
Editing TracDev/VersionControlApi
Adjust edit area height:
8
12
16
20
24
28
32
36
40
Edit side-by-side
= Trac Version Control System API = Trac uses a thin abstraction layer between the Trac application code and the code that accesses concrete version control systems. This layer can be found in the [source:/trunk/trac/versioncontrol/api.py#latest trac.versioncontrol] package. == Accessing the Version Control System == You can get access to a concrete {{{Repository}}} implementation using the {{{get_repository()}}} method of the {{{Environment}}} object: {{{ #!python from trac.env import Environment env = Environment('/path/to/projenv') repos = env.get_repository() try: # Do whatever you like with the repository object here finally: repos.close() }}} From Trac 0.12 {{{env.get_repository()}}} is deprecated, replaced by the {{{RepositoryManager}}} interface. The above code becomes: {{{ #!python from trac.env import Environment from trac.versioncontrol import RepositoryManager env = Environment('/path/to/projenv') repos = RepositoryManager(env).get_repository(None) try: # Do whatever you like with the repository object here finally: repos.close() }}} To access a repository other than the default pass a {{{reponame}}} in place of {{{None}}}. In class that inherits from {{{Component}}} it is more convenient to use {{{self.env}}} than instantiate {{{Environment}}} manually. ---- See also: TracDev
Note:
See
WikiFormatting
and
TracWiki
for help on editing wiki content.
Change information
Your email or username:
E-mail address and name can be saved in the
Preferences
Comment about this change (optional):
Note:
See
TracWiki
for help on using the wiki.