Lines 198-210
Link Here
|
198 |
|
198 |
|
199 |
def get_changes(self): |
199 |
def get_changes(self): |
200 |
""" |
200 |
""" |
201 |
Generator that produces a (path, kind, change, base_rev, base_path) |
201 |
Generator that produces a (path, kind, change, base_path, base_rev) |
202 |
tuple for every change in the changeset, where change can be one of |
202 |
tuple for every change in the changeset, where change can be one of |
203 |
Changeset.ADD, Changeset.COPY, Changeset.DELETE, Changeset.EDIT or |
203 |
Changeset.ADD, Changeset.COPY, Changeset.DELETE, Changeset.EDIT or |
204 |
Changeset.MOVE, and kind is one of Node.FILE or Node.DIRECTORY. |
204 |
Changeset.MOVE, and kind is one of Node.FILE or Node.DIRECTORY. |
205 |
""" |
205 |
""" |
206 |
raise NotImplementedError |
206 |
raise NotImplementedError |
207 |
|
207 |
|
|
|
208 |
def insert_in_cache(self, cursor, kindmap, actionmap, log): |
209 |
""" |
210 |
Insert this changeset in the cache db. |
211 |
""" |
212 |
cursor.execute("INSERT INTO revision (rev,time,author,message) " |
213 |
"VALUES (%s,%s,%s,%s)", (str(self.rev), |
214 |
self.date, self.author, |
215 |
self.message)) |
216 |
for path,kind,action,base_path,base_rev in self.get_changes(): |
217 |
log.debug("Caching node change in [%s]: %s" |
218 |
% (self.rev, (path, kind, action, |
219 |
base_path, base_rev))) |
220 |
kind = kindmap[kind] |
221 |
action = actionmap[action] |
222 |
cursor.execute("INSERT INTO node_change (rev,path,kind," |
223 |
"change,base_path,base_rev) " |
224 |
"VALUES (%s,%s,%s,%s,%s,%s)", |
225 |
(str(self.rev), path, kind, action, |
226 |
base_path, base_rev)) |
208 |
|
227 |
|
209 |
class PermissionDenied(PermissionError): |
228 |
class PermissionDenied(PermissionError): |
210 |
""" |
229 |
""" |
Lines 237-239
Link Here
|
237 |
def has_permission_for_changeset(self, rev): |
256 |
def has_permission_for_changeset(self, rev): |
238 |
return 1 |
257 |
return 1 |
239 |
|
258 |
|
|
|
259 |
|
260 |
def get_repository(env, authname): |
261 |
""" |
262 |
Return the right repository backend wrapped by a CachedRepository. |
263 |
|
264 |
This looks for a ``darcs:`` or ``bzr:`` prefix on the |
265 |
'repository_dir' from the configuration: if present it qualifies |
266 |
respectively a Darcs or a Bazaar-NG repository, otherwise it uses |
267 |
the Subversion backend. |
268 |
""" |
269 |
|
270 |
authz = None |
271 |
repos_dir = env.config.get('trac', 'repository_dir') |
272 |
db = env.get_db_cnx() |
273 |
if not repos_dir: |
274 |
raise EnvironmentError, 'Path to repository not configured' |
275 |
if repos_dir.startswith('darcs:'): |
276 |
from trac.versioncontrol.darcs import DarcsRepository, \ |
277 |
DarcsCachedRepository as CachedRepository |
278 |
repos = DarcsRepository(db, repos_dir[6:], env.log) |
279 |
elif repos_dir.startswith('bzr:'): |
280 |
from trac.versioncontrol.bzr import BzrRepository, \ |
281 |
BzrCachedRepository as CachedRepository |
282 |
#from trac.versioncontrol.cache import CachedRepository |
283 |
repos = BzrRepository(db, repos_dir[4:], env.log) |
284 |
else: |
285 |
from trac.versioncontrol.svn_authz import SubversionAuthorizer |
286 |
from trac.versioncontrol.svn_fs import SubversionRepository |
287 |
from trac.versioncontrol.cache import CachedRepository |
288 |
if authname: |
289 |
authz = SubversionAuthorizer(env, authname) |
290 |
repos = SubversionRepository(repos_dir, authz, env.log) |
291 |
return CachedRepository(db, repos, authz, env.log) |
292 |
|
293 |
|
294 |
def get_authorizer(env, authname): |
295 |
""" |
296 |
Return the right authorizer for the configured repository. |
297 |
|
298 |
Like ``get_repository()`` this looks for a ``darcs:`` or ``bzr:`` |
299 |
prefix on the 'repository_dir' setting: if present it returns |
300 |
a basic Authorizer(), otherwise a SubversionAuthorizer. |
301 |
""" |
302 |
|
303 |
authz = Authorizer() |
304 |
repos_dir = env.config.get('trac', 'repository_dir') |
305 |
if not repos_dir.startswith('darcs:') \ |
306 |
and not repos_dir.startswith('bzr:'): |
307 |
from trac.versioncontrol.svn_authz import SubversionAuthorizer |
308 |
if authname: |
309 |
authz = SubversionAuthorizer(env, authname) |
310 |
return authz |