Issue #150: Retrieving branch from changset in hook. (conservancy/kallithea)
jimka
issues-reply at bitbucket.org
Wed Jul 29 05:50:24 UTC 2015
New issue 150: Retrieving branch from changset in hook.
https://bitbucket.org/conservancy/kallithea/issues/150/retrieving-branch-from-changset-in-hook
jimka:
I'm working against a mercurial repository and i've added a hook that gets called when someone pushes a changeset.
I'd like to retrieve information regarding what branch the changeset belongs to.
The following code works 'sometimes';
```
#!python
def push_action(ui, repo, **kwargs):
ex = _extract_extras()
changeset_id = kwargs['node']
repo_name = ex.repository
print(" Repository: " + repo_name)
r = RepoModel().get_by_repo_name(repo_name)
changeset = r.get_changeset(changeset_id)
branch_name = changeset.branch
```
But more often then not it throws the following exception;
```
#!python
remote: Traceback (most recent call last):
remote: File "/opt/kallithea/venv/local/lib/python2.7/site-packages/kallithea/lib/bb.py", line 29, in push_action
remote: branch_name = changeset.branch
remote: File "/opt/kallithea/venv/local/lib/python2.7/site-packages/kallithea/lib/vcs/utils/lazy.py", line 40, in __get__
remote: value = self._func(obj)
remote: File "/opt/kallithea/venv/local/lib/python2.7/site-packages/kallithea/lib/vcs/backends/base.py", line 1004, in branch
remote: return get_backend(self.alias).DEFAULT_BRANCH_NAME
remote: File "/opt/kallithea/venv/local/lib/python2.7/site-packages/kallithea/lib/vcs/backends/__init__.py", line 53, in get_backend
remote: "%s" % (alias, pformat(settings.BACKENDS.keys())))
remote: VCSError: Given alias 'None' is not recognized! Allowed aliases:
remote: ['git', 'hg']
```
Is this a bug or do I need to do something else to make this work?
More information about the kallithea-general
mailing list