Show More
@@ -311,6 +311,27 b' class BaseRepository(object):' | |||||
311 | """ |
|
311 | """ | |
312 | raise NotImplementedError |
|
312 | raise NotImplementedError | |
313 |
|
313 | |||
|
314 | def inject_ui(self, **extras): | |||
|
315 | """ | |||
|
316 | Injects extra parameters into UI object of this repo | |||
|
317 | """ | |||
|
318 | required_extras = [ | |||
|
319 | 'ip', | |||
|
320 | 'username', | |||
|
321 | 'action', | |||
|
322 | 'repository', | |||
|
323 | 'scm', | |||
|
324 | 'config', | |||
|
325 | 'server_url', | |||
|
326 | 'make_lock', | |||
|
327 | 'locked_by', | |||
|
328 | ] | |||
|
329 | for req in required_extras: | |||
|
330 | if req not in extras: | |||
|
331 | raise AttributeError('Missing attribute %s in extras' % (req)) | |||
|
332 | for k, v in extras.items(): | |||
|
333 | self._repo.ui.setconfig('rhodecode_extras', k, v) | |||
|
334 | ||||
314 |
|
335 | |||
315 | class BaseChangeset(object): |
|
336 | class BaseChangeset(object): | |
316 | """ |
|
337 | """ |
@@ -938,15 +938,7 b' class Repository(Base, BaseModel):' | |||||
938 |
|
938 | |||
939 | @classmethod |
|
939 | @classmethod | |
940 | def inject_ui(cls, repo, extras={}): |
|
940 | def inject_ui(cls, repo, extras={}): | |
941 | from rhodecode.lib.vcs.backends.hg import MercurialRepository |
|
941 | repo.inject_ui(extras) | |
942 | from rhodecode.lib.vcs.backends.git import GitRepository |
|
|||
943 | required = (MercurialRepository, GitRepository) |
|
|||
944 | if not isinstance(repo, required): |
|
|||
945 | raise Exception('repo must be instance of %s' % required) |
|
|||
946 |
|
||||
947 | # inject ui extra param to log this action via push logger |
|
|||
948 | for k, v in extras.items(): |
|
|||
949 | repo._repo.ui.setconfig('rhodecode_extras', k, v) |
|
|||
950 |
|
942 | |||
951 | @classmethod |
|
943 | @classmethod | |
952 | def is_valid(cls, repo_name): |
|
944 | def is_valid(cls, repo_name): |
General Comments 0
You need to be logged in to leave comments.
Login now