/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-06-13 18:56:54 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-20060613185654-ce1cfe57f21138cd
* backend/commit.py: minor tweaks to push()
* backend/init.py: minor tweaks to checkout() and branch()

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, NonExistingSource,
30
 
                    RevisionValueError, TargetAlreadyExists)
 
30
                    TargetAlreadyExists)
31
31
 
32
32
def init(location):
33
33
    """ Initialize a directory.
68
68
    """
69
69
    from bzrlib.transport import get_transport
70
70
 
71
 
    if revision is None:
72
 
        revision = [None]
73
 
    elif len(revision) > 1:
74
 
        raise RevisionValueError
75
 
 
76
71
    try:
77
72
        br_from = Branch.open(from_location)
78
73
    except OSError, e:
85
80
 
86
81
    try:
87
82
        basis_dir = None
88
 
        if len(revision) == 1 and revision[0] is not None:
89
 
            revision_id = revision[0].in_history(br_from)[1]
 
83
        if revision is not None:
 
84
            revision_id = br_from.get_rev_id(revision)
90
85
        else:
91
 
            revision_id = br_from.last_revision()
 
86
            revision_id = None
92
87
 
93
88
        to_location = to_location + '/' + os.path.basename(from_location.rstrip("/\\"))
94
89
        name = None
115
110
        
116
111
    return branch.revno()
117
112
 
118
 
# FIXME - not tested yet
119
113
def checkout(branch_location, to_location, revision=None, lightweight=False):
120
114
    """ Create a new checkout of an existing branch.
121
115
    
127
121
    
128
122
    :param lightweight: perform a lightweight checkout (be aware!)
129
123
    """
130
 
    if revision is None:
131
 
        revision = [None]
132
 
    elif len(revision) > 1:
133
 
        raise RevisionValueError
134
 
 
135
124
    source = Branch.open(branch_location)
136
 
 
137
 
    if len(revision) == 1 and revision[0] is not None:
138
 
        revision_id = revision[0].in_history(source)[1]
 
125
    
 
126
    if revision is not None:
 
127
        revision_id = source.get_rev_id(revision)
139
128
    else:
140
129
        revision_id = None
141
130
 
142
131
    # if the source and to_location are the same, 
143
132
    # and there is no working tree,
144
133
    # then reconstitute a branch
145
 
    if (bzrlib.osutils.abspath(to_location) == 
 
134
    if (bzrlib.osutils.abspath(to_location) ==
146
135
        bzrlib.osutils.abspath(branch_location)):
147
136
        try:
148
137
            source.bzrdir.open_workingtree()
175
164
            if revision_id is not None:
176
165
                rh = checkout_branch.revision_history()
177
166
                checkout_branch.set_revision_history(rh[:rh.index(revision_id) + 1])
 
167
 
178
168
        checkout.create_workingtree(revision_id)
179
169
    finally:
180
170
        bzrlib.bzrdir.BzrDirFormat.set_default_format(old_format)