~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/__init__.py

  • Committer: Robert Collins
  • Date: 2005-08-23 06:52:09 UTC
  • mto: (974.1.50) (1185.1.10) (1092.3.1)
  • mto: This revision was merged to the branch mainline in revision 1139.
  • Revision ID: robertc@robertcollins.net-20050823065209-81cd5962c401751b
move io redirection into each test case from the global runner

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
"""bzr library"""
18
18
 
 
19
# TODO: Do less imports here
 
20
from branch import Branch, ScratchBranch, find_branch
 
21
from errors import BzrError
 
22
 
19
23
BZRDIR = ".bzr"
20
24
 
21
25
DEFAULT_IGNORE = ['.bzr.log',
28
32
                  'BitKeeper',
29
33
                  '.git',
30
34
                  'TAGS', '.make.state', '.sconsign', '.tmp*',
31
 
                  '.del-*',
32
 
                  '.DS_Store',]
 
35
                  '.del-*']
33
36
 
34
37
IGNORE_FILENAME = ".bzrignore"
35
38
 
36
 
import os
37
39
import locale
38
40
user_encoding = locale.getpreferredencoding() or 'ascii'
39
41
del locale
40
42
 
41
43
__copyright__ = "Copyright 2005 Canonical Development Ltd."
42
 
__version__ = '0.6pre'
 
44
__author__ = "Martin Pool <mbp@canonical.com>"
 
45
__version__ = '0.0.7pre'
43
46
 
44
47
 
45
48
def get_bzr_revision():
46
49
    """If bzr is run from a branch, return (revno,revid) or None"""
47
 
    import bzrlib.errors
48
 
    from bzrlib.branch import Branch
49
 
    
50
50
    try:
51
 
        branch = Branch.open(os.path.dirname(__path__[0]))
 
51
        branch = Branch(__path__[0])
52
52
        rh = branch.revision_history()
53
53
        if rh:
54
54
            return len(rh), rh[-1]
55
55
        else:
56
56
            return None
57
 
    except bzrlib.errors.BzrError:
 
57
    except BzrError:
58
58
        return None
59
59
    
60
 
def test_suite():
61
 
    import selftest
62
 
    return selftest.test_suite()