~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/smart/branch.py

  • Committer: Vincent Ladeuil
  • Date: 2010-10-07 06:08:01 UTC
  • mto: This revision was merged to the branch mainline in revision 5491.
  • Revision ID: v.ladeuil+lp@free.fr-20101007060801-wfdhizfhfmctl8qa
Fix some typos and propose a release planning.

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
from bzrlib import (
21
21
    bencode,
22
22
    errors,
23
 
    revision as _mod_revision,
24
23
    )
25
 
from bzrlib.controldir import ControlDir
 
24
from bzrlib.bzrdir import BzrDir
26
25
from bzrlib.smart.request import (
27
26
    FailedSmartServerResponse,
28
27
    SmartServerRequest,
46
45
        :return: A SmartServerResponse from self.do_with_branch().
47
46
        """
48
47
        transport = self.transport_from_client_path(path)
49
 
        controldir = ControlDir.open_from_transport(transport)
50
 
        if controldir.get_branch_reference() is not None:
 
48
        bzrdir = BzrDir.open_from_transport(transport)
 
49
        if bzrdir.get_branch_reference() is not None:
51
50
            raise errors.NotBranchError(transport.base)
52
 
        branch = controldir.open_branch(ignore_fallbacks=True)
 
51
        branch = bzrdir.open_branch(ignore_fallbacks=True)
53
52
        return self.do_with_branch(branch, *args)
54
53
 
55
54
 
143
142
            self.branch.unlock()
144
143
 
145
144
 
146
 
class SmartServerBranchHeadsToFetch(SmartServerBranchRequest):
147
 
 
148
 
    def do_with_branch(self, branch):
149
 
        """Return the heads-to-fetch for a Branch as two bencoded lists.
150
 
        
151
 
        See Branch.heads_to_fetch.
152
 
 
153
 
        New in 2.4.
154
 
        """
155
 
        must_fetch, if_present_fetch = branch.heads_to_fetch()
156
 
        return SuccessfulSmartServerResponse(
157
 
            (list(must_fetch), list(if_present_fetch)))
158
 
 
159
 
 
160
145
class SmartServerBranchRequestGetStackedOnURL(SmartServerBranchRequest):
161
146
 
162
147
    def do_with_branch(self, branch):
172
157
        The revision list is returned as the body content,
173
158
        with each revision utf8 encoded and \x00 joined.
174
159
        """
175
 
        branch.lock_read()
176
 
        try:
177
 
            graph = branch.repository.get_graph()
178
 
            stop_revisions = (None, _mod_revision.NULL_REVISION)
179
 
            history = list(graph.iter_lefthand_ancestry(
180
 
                branch.last_revision(), stop_revisions))
181
 
        finally:
182
 
            branch.unlock()
183
160
        return SuccessfulSmartServerResponse(
184
 
            ('ok', ), ('\x00'.join(reversed(history))))
 
161
            ('ok', ), ('\x00'.join(branch.revision_history())))
185
162
 
186
163
 
187
164
class SmartServerBranchRequestLastRevisionInfo(SmartServerBranchRequest):
241
218
 
242
219
    def do_tip_change_with_locked_branch(self, branch, new_last_revision_id):
243
220
        if new_last_revision_id == 'null:':
244
 
            branch._set_revision_history([])
 
221
            branch.set_revision_history([])
245
222
        else:
246
223
            if not branch.repository.has_revision(new_last_revision_id):
247
224
                return FailedSmartServerResponse(
248
225
                    ('NoSuchRevision', new_last_revision_id))
249
 
            branch._set_revision_history(branch._lefthand_history(
 
226
            branch.set_revision_history(branch._lefthand_history(
250
227
                new_last_revision_id, None, None))
251
228
        return SuccessfulSmartServerResponse(('ok',))
252
229