1
# -*- coding: utf-8 -*-"
2
# Copyright (C) 2011 enn.io UG (haftungsbeschränkt)
3
# Copyright (C) 2011-2012 Linaro Limited
5
# Author: Jannis Leidel <jannis@leidel.info>
6
# Author: Zygmunt Krynicki <zygmunt.krynicki@linaro.org>
8
# This file is part of versiontools.
10
# versiontools is free software: you can redistribute it and/or modify
11
# it under the terms of the GNU Lesser General Public License version 3
12
# as published by the Free Software Foundation
14
# versiontools is distributed in the hope that it will be useful,
15
# but WITHOUT ANY WARRANTY; without even the implied warranty of
16
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
# GNU General Public License for more details.
19
# You should have received a copy of the GNU Lesser General Public License
20
# along with versiontools. If not, see <http://www.gnu.org/licenses/>.
25
versiontools.hg_support
26
=======================
28
Mercurial (Hg) support for versiontools.
32
To work with Mercurial repositories you will need `Mercurial
33
<http://mercurial.selenic.com/>`_. You can install it with pip or from the
34
`mercurial` package on Ubuntu.
40
class HgIntegration(object):
42
Hg integration for versiontools
44
def __init__(self, repo):
45
tip = repo.changectx('tip')
46
self._revno = tip.rev()
48
self._branch_nick = tip.branch()
50
self._branch_nick = None
55
Revision number of the branch
60
def branch_nick(self):
62
Nickname of the branch
64
.. versionadded:: 1.0.4
66
return self._branch_nick
69
def from_source_tree(cls, source_tree):
71
Initialize :class:`~versiontools.hg_support.HgIntegration` by
72
pointing at the source tree. Any file or directory inside the
73
source tree may be used.
77
from mercurial.hg import repository
78
from mercurial.ui import ui
79
repo = repository(ui(), source_tree)
81
from versiontools import _get_exception_message
82
message = _get_exception_message(*sys.exc_info())
83
logging.debug("Unable to get branch revision because "
84
"directory %r is not a hg repo. Error: %s",
85
(source_tree, message))