/b-gtk/fix-viz

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/b-gtk/fix-viz

« back to all changes in this revision

Viewing changes to backend/init.py

  • Committer: Szilveszter Farkas (Phanatic)
  • Date: 2006-07-08 17:36:59 UTC
  • mto: (0.14.1 main) (93.1.1 win32.bialix)
  • mto: This revision was merged to the branch mainline in revision 83.
  • Revision ID: Szilveszter.Farkas@gmail.com-20060708173659-8ab442681dadd8ea
2006-07-08  Szilveszter Farkas <Szilveszter.Farkas@gmail.com>

    * backend/errors.py: added some exceptions related to diff() and log()
    * backend/info.py: implemented log()
    * backend/info.py: diff() works well with revnos
    * added e-mail address to copyright header

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
 
28
28
from errors import (AlreadyBranchError, BranchExistsWithoutWorkingTree,
29
29
                    NonExistingParent, NonExistingRevision,
30
 
                    NonExistingSource, NotBranchError, TargetAlreadyExists)
 
30
                    NonExistingSource, TargetAlreadyExists)
 
31
 
 
32
def init(location):
 
33
    """ Initialize a directory.
 
34
    
 
35
    :param location: full path to the directory you want to be versioned
 
36
    """
 
37
    from bzrlib.builtins import get_format_type
 
38
 
 
39
    format = get_format_type('default')
 
40
 
 
41
    if not os.path.exists(location):
 
42
        os.mkdir(location)
 
43
 
 
44
    try:
 
45
        existing_bzrdir = bzrdir.BzrDir.open(location)
 
46
    except errors.NotBranchError:
 
47
        bzrdir.BzrDir.create_branch_convenience(location, format=format)
 
48
    else:
 
49
        if existing_bzrdir.has_branch():
 
50
            if existing_bzrdir.has_workingtree():
 
51
                raise AlreadyBranchError(location)
 
52
            else:
 
53
                raise BranchExistsWithoutWorkingTree(location)
 
54
        else:
 
55
            existing_bzrdir.create_branch()
 
56
            existing_bzrdir.create_workingtree()
31
57
 
32
58
def branch(from_location, to_location, revision=None):
33
59
    """ Create a branch from a local/remote location.
49
75
            raise NonExistingSource(from_location)
50
76
        else:
51
77
            raise
52
 
    except errors.NotBranchError:
53
 
        raise NotBranchError(from_location)
54
78
 
55
79
    br_from.lock_read()
56
80
 
97
121
    
98
122
    :param lightweight: perform a lightweight checkout (be aware!)
99
123
    """
100
 
    try:
101
 
        source = Branch.open(branch_location)
102
 
    except errors.NotBranchError:
103
 
        raise NotBranchError(branch_location)
 
124
    source = Branch.open(branch_location)
104
125
    
105
126
    if revision is not None:
106
127
        revision_id = source.get_rev_id(revision)
118
139
            source.bzrdir.create_workingtree()
119
140
            return
120
141
 
121
 
    to_location = to_location + '/' + os.path.basename(branch_location.rstrip("/\\"))
122
 
    
123
142
    try:
124
143
        os.mkdir(to_location)
125
144
    except OSError, e:
149
168
        checkout.create_workingtree(revision_id)
150
169
    finally:
151
170
        bzrlib.bzrdir.BzrDirFormat.set_default_format(old_format)
152
 
 
153
 
def init(location):
154
 
    """ Initialize a directory.
155
 
    
156
 
    :param location: full path to the directory you want to be versioned
157
 
    """
158
 
    from bzrlib.builtins import get_format_type
159
 
 
160
 
    format = get_format_type('default')
161
 
 
162
 
    if not os.path.exists(location):
163
 
        os.mkdir(location)
164
 
 
165
 
    try:
166
 
        existing_bzrdir = bzrdir.BzrDir.open(location)
167
 
    except errors.NotBranchError:
168
 
        bzrdir.BzrDir.create_branch_convenience(location, format=format)
169
 
    else:
170
 
        if existing_bzrdir.has_branch():
171
 
            if existing_bzrdir.has_workingtree():
172
 
                raise AlreadyBranchError(location)
173
 
            else:
174
 
                raise BranchExistsWithoutWorkingTree(location)
175
 
        else:
176
 
            existing_bzrdir.create_branch()
177
 
            existing_bzrdir.create_workingtree()