~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/__init__.py

  • Committer: Robert Collins
  • Date: 2005-10-06 11:40:12 UTC
  • mto: This revision was merged to the branch mainline in revision 1420.
  • Revision ID: robertc@robertcollins.net-20051006114012-c0acdb4146f9ea26
add sample test script

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
 
 
23
19
BZRDIR = ".bzr"
24
20
 
25
21
DEFAULT_IGNORE = ['.bzr.log',
32
28
                  'BitKeeper',
33
29
                  '.git',
34
30
                  'TAGS', '.make.state', '.sconsign', '.tmp*',
35
 
                  '.del-*']
 
31
                  '.del-*',
 
32
                  '.DS_Store',]
36
33
 
37
34
IGNORE_FILENAME = ".bzrignore"
38
35
 
 
36
import os
39
37
import locale
40
38
user_encoding = locale.getpreferredencoding() or 'ascii'
41
39
del locale
42
40
 
43
41
__copyright__ = "Copyright 2005 Canonical Development Ltd."
44
 
__author__ = "Martin Pool <mbp@canonical.com>"
45
 
__version__ = '0.0.7pre'
 
42
__version__ = '0.10pre(newformat)'
46
43
 
47
44
 
48
45
def get_bzr_revision():
49
46
    """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(__path__[0])
 
51
        branch = Branch.open(os.path.dirname(__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 BzrError:
 
57
    except bzrlib.errors.BzrError:
58
58
        return None
59
59
    
 
60
def test_suite():
 
61
    import selftest
 
62
    return selftest.test_suite()