| 1 | = Trac Version Control System API = |
| 2 | |
| 3 | 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/main.py#latest trac.versioncontrol] package. |
| 4 | |
| 5 | == Accessing the Version Vontrol System == |
| 6 | |
| 7 | You can get access to a concrete {{{Repository}}} implementation using the {{{get_repository()}}} method of the {{{Environment}}} object: |
| 8 | {{{ |
| 9 | #!python |
| 10 | from trac.env import Environment |
| 11 | |
| 12 | env = Environment('/path/to/projenv') |
| 13 | repos = env.get_repository() |
| 14 | try: |
| 15 | # Do whatever you like with the repository object here |
| 16 | finally: |
| 17 | repos.close() |
| 18 | }}} |
| 19 | |
| 20 | ---- |
| 21 | See also: TracDev |