~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/smart/branch.py

  • Committer: Andrew Bennetts
  • Date: 2008-08-07 00:25:38 UTC
  • mfrom: (3612 +trunk)
  • mto: This revision was merged to the branch mainline in revision 3613.
  • Revision ID: andrew.bennetts@canonical.com-20080807002538-mtl1fcgy2fdabha4
Merge from bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
115
115
        return SuccessfulSmartServerResponse(('ok', str(revno), last_revision))
116
116
 
117
117
 
118
 
class SmartServerBranchRequestSetLastRevision(SmartServerLockedBranchRequest):
 
118
class SmartServerSetTipRequest(SmartServerLockedBranchRequest):
 
119
    """Base class for handling common branch request logic for requests that
 
120
    update the branch tip.
 
121
    """
 
122
 
 
123
    def do_with_locked_branch(self, branch, *args):
 
124
        try:
 
125
            return self.do_tip_change_with_locked_branch(branch, *args)
 
126
        except errors.TipChangeRejected, e:
 
127
            msg = e.msg
 
128
            if isinstance(msg, unicode):
 
129
                msg = msg.encode('utf-8')
 
130
            return FailedSmartServerResponse(('TipChangeRejected', msg))
 
131
 
 
132
 
 
133
class SmartServerBranchRequestSetLastRevision(SmartServerSetTipRequest):
119
134
    
120
 
    def do_with_locked_branch(self, branch, new_last_revision_id):
 
135
    def do_tip_change_with_locked_branch(self, branch, new_last_revision_id):
121
136
        if new_last_revision_id == 'null:':
122
137
            branch.set_revision_history([])
123
138
        else:
128
143
        return SuccessfulSmartServerResponse(('ok',))
129
144
 
130
145
 
131
 
class SmartServerBranchRequestSetLastRevisionEx(SmartServerLockedBranchRequest):
 
146
class SmartServerBranchRequestSetLastRevisionEx(SmartServerSetTipRequest):
132
147
    
133
 
    def do_with_locked_branch(self, branch, new_last_revision_id,
 
148
    def do_tip_change_with_locked_branch(self, branch, new_last_revision_id,
134
149
            allow_divergence, allow_overwrite_descendant):
135
150
        """Set the last revision of the branch.
136
151
 
176
191
            ('ok', new_revno, new_last_revision_id))
177
192
 
178
193
 
179
 
class SmartServerBranchRequestSetLastRevisionInfo(
180
 
    SmartServerLockedBranchRequest):
 
194
class SmartServerBranchRequestSetLastRevisionInfo(SmartServerSetTipRequest):
181
195
    """Branch.set_last_revision_info.  Sets the revno and the revision ID of
182
196
    the specified branch.
183
197
 
184
198
    New in bzrlib 1.4.
185
199
    """
186
200
    
187
 
    def do_with_locked_branch(self, branch, new_revno, new_last_revision_id):
 
201
    def do_tip_change_with_locked_branch(self, branch, new_revno,
 
202
            new_last_revision_id):
188
203
        try:
189
204
            branch.set_last_revision_info(int(new_revno), new_last_revision_id)
190
205
        except errors.NoSuchRevision: