Exemple #1
0
 def from_source_tree(cls, source_tree):
     """
     Initialize :class:`~versiontools.bzr_support.BzrIntegration` by
     pointing at the source tree.  Any file or directory inside the
     source tree may be used.
     """
     branch = None
     try:
         import bzrlib
         if bzrlib.__version__ >= (2, 2, 1):
             # Python 2.4 the with keyword is not supported
             # and so you need to use the context manager manually, sigh.
             library_state = bzrlib.initialize()
             library_state.__enter__()
             try:
                 from bzrlib.branch import Branch
                 branch = Branch.open_containing(source_tree)[0]
             finally:
                 library_state.__exit__(None, None, None)
         else:
             from bzrlib.branch import Branch
             branch = Branch.open_containing(source_tree)[0]
     except Exception:
         from versiontools import get_exception_message
         message = get_exception_message(*sys.exc_info())
         logging.debug("Unable to get branch revision because "
                       "directory %r is not a bzr branch. Erorr: %s",
                       (source_tree, message))
     if branch:
         return cls(branch)
Exemple #2
0
 def from_source_tree(cls, source_tree):
     """
     Initialize :class:`~versiontools.bzr_support.BzrIntegration` by
     pointing at the source tree.  Any file or directory inside the
     source tree may be used.
     """
     branch = None
     try:
         import bzrlib
         if bzrlib.__version__ >= (2, 2, 1):
             # Python 2.4 the with keyword is not supported
             # and so you need to use the context manager manually, sigh.
             library_state = bzrlib.initialize()
             library_state.__enter__()
             try:
                 from bzrlib.branch import Branch
                 branch = Branch.open_containing(source_tree)[0]
             finally:
                 library_state.__exit__(None, None, None)
         else:
             from bzrlib.branch import Branch
             branch = Branch.open_containing(source_tree)[0]
     except Exception:
         from versiontools import get_exception_message
         message = get_exception_message(*sys.exc_info())
         logging.debug(
             "Unable to get branch revision because "
             "directory %r is not a bzr branch. Erorr: %s",
             (source_tree, message))
     if branch:
         return cls(branch)
Exemple #3
0
 def from_source_tree(cls, source_tree):
     """
     Initialize :class:`~versiontools.git_support.GitIntegration` by
     pointing at the source tree.  Any file or directory inside the
     source tree may be used.
     """
     repo = None
     try:
         from git import Repo
         repo = Repo(source_tree)
     except Exception:
         from versiontools import get_exception_message
         message = get_exception_message(*sys.exc_info())
         logging.debug("Unable to get branch revision because "
                       "directory %r is not a git repo. Error: %s",
                       (source_tree, message))
     if repo:
         return cls(repo)
Exemple #4
0
 def from_source_tree(cls, source_tree):
     """
     Initialize :class:`~versiontools.git_support.GitIntegration` by
     pointing at the source tree.  Any file or directory inside the
     source tree may be used.
     """
     repo = None
     try:
         from git import Repo
         repo = Repo(source_tree)
     except Exception:
         from versiontools import get_exception_message
         message = get_exception_message(*sys.exc_info())
         logging.debug(
             "Unable to get branch revision because "
             "directory %r is not a git repo. Error: %s",
             (source_tree, message))
     if repo:
         return cls(repo)