~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/smart/branch.py

  • Committer: Andrew Bennetts
  • Date: 2007-02-08 06:51:30 UTC
  • mto: (2018.5.73 hpss)
  • mto: This revision was merged to the branch mainline in revision 2435.
  • Revision ID: andrew.bennetts@canonical.com-20070208065130-gpzocn512ppmcm72
Add a Branch.set_last_revision smart method, and make RemoteBranch.set_revision_history use it.

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
class SmartServerBranchRequest(SmartServerRequest):
27
27
    """Base class for handling common branch request logic."""
28
28
 
29
 
    def do(self, path):
 
29
    def do(self, path, *args):
30
30
        """Execute a request for a branch at path.
31
31
 
32
32
        If the branch is a branch reference, NotBranchError is raised.
36
36
        if bzrdir.get_branch_reference() is not None:
37
37
            raise errors.NotBranchError(transport.base)
38
38
        branch = bzrdir.open_branch()
39
 
        return self.do_with_branch(branch)
 
39
        return self.do_with_branch(branch, *args)
40
40
 
41
41
 
42
42
class SmartServerBranchGetConfigFile(SmartServerBranchRequest):
79
79
            ('ok', str(revno), last_revision.encode('utf8')))
80
80
 
81
81
 
 
82
class SmartServerBranchRequestSetLastRevision(SmartServerBranchRequest):
 
83
    
 
84
    def do_with_branch(self, branch, new_last_revision_id):
 
85
        unicode_new_last_revision_id = new_last_revision_id.decode('utf-8')  # XXX test
 
86
        if new_last_revision_id == '':
 
87
            branch.set_revision_history([])
 
88
        else:
 
89
            if not branch.repository.has_revision(unicode_new_last_revision_id):
 
90
                return SmartServerResponse(
 
91
                    ('NoSuchRevision', new_last_revision_id))
 
92
            branch.generate_revision_history(unicode_new_last_revision_id)
 
93
        return SmartServerResponse(('ok',))
 
94