~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/smart/branch.py

  • Committer: Patch Queue Manager
  • Date: 2011-10-14 16:54:26 UTC
  • mfrom: (6216.1.1 remove-this-file)
  • Revision ID: pqm@pqm.ubuntu.com-20111014165426-tjix4e6idryf1r2z
(jelmer) Remove an accidentally committed .THIS file. (Jelmer Vernooij)

Show diffs side-by-side

added added

removed removed

Lines of Context:
77
77
            branch.repository.unlock()
78
78
 
79
79
 
80
 
class SmartServerBranchBreakLock(SmartServerBranchRequest):
81
 
 
82
 
    def do_with_branch(self, branch):
83
 
        """Break a branch lock.
84
 
        """
85
 
        branch.break_lock()
86
 
        return SuccessfulSmartServerResponse(('ok', ), )
87
 
 
88
 
 
89
80
class SmartServerBranchGetConfigFile(SmartServerBranchRequest):
90
81
 
91
82
    def do_with_branch(self, branch):
94
85
        The body is not utf8 decoded - its the literal bytestream from disk.
95
86
        """
96
87
        try:
97
 
            content = branch.control_transport.get_bytes('branch.conf')
 
88
            content = branch._transport.get_bytes('branch.conf')
98
89
        except errors.NoSuchFile:
99
90
            content = ''
100
91
        return SuccessfulSmartServerResponse( ('ok', ), content)
101
92
 
102
93
 
103
 
class SmartServerBranchPutConfigFile(SmartServerBranchRequest):
104
 
    """Set the configuration data for a branch.
105
 
 
106
 
    New in 2.5.
107
 
    """
108
 
 
109
 
    def do_with_branch(self, branch, branch_token, repo_token):
110
 
        """Set the content of branch.conf.
111
 
 
112
 
        The body is not utf8 decoded - its the literal bytestream for disk.
113
 
        """
114
 
        self._branch = branch
115
 
        self._branch_token = branch_token
116
 
        self._repo_token = repo_token
117
 
        # Signal we want a body
118
 
        return None
119
 
 
120
 
    def do_body(self, body_bytes):
121
 
        self._branch.repository.lock_write(token=self._repo_token)
122
 
        try:
123
 
            self._branch.lock_write(token=self._branch_token)
124
 
            try:
125
 
                self._branch.control_transport.put_bytes(
126
 
                    'branch.conf', body_bytes)
127
 
            finally:
128
 
                self._branch.unlock()
129
 
        finally:
130
 
            self._branch.repository.unlock()
131
 
        return SuccessfulSmartServerResponse(('ok', ))
132
 
 
133
 
 
134
94
class SmartServerBranchGetParent(SmartServerBranchRequest):
135
95
 
136
96
    def do_with_branch(self, branch):
235
195
        return SuccessfulSmartServerResponse(('ok', str(revno), last_revision))
236
196
 
237
197
 
238
 
class SmartServerBranchRequestRevisionIdToRevno(SmartServerBranchRequest):
239
 
 
240
 
    def do_with_branch(self, branch, revid):
241
 
        """Return branch.revision_id_to_revno().
242
 
 
243
 
        New in 2.5.
244
 
 
245
 
        The revno is encoded in decimal, the revision_id is encoded as utf8.
246
 
        """
247
 
        try:
248
 
            dotted_revno = branch.revision_id_to_dotted_revno(revid)
249
 
        except errors.NoSuchRevision:
250
 
            return FailedSmartServerResponse(('NoSuchRevision', revid))
251
 
        return SuccessfulSmartServerResponse(
252
 
            ('ok', ) + tuple(map(str, dotted_revno)))
253
 
 
254
 
 
255
198
class SmartServerSetTipRequest(SmartServerLockedBranchRequest):
256
199
    """Base class for handling common branch request logic for requests that
257
200
    update the branch tip.
434
377
        branch.unlock()
435
378
        return SuccessfulSmartServerResponse(('ok',))
436
379
 
437
 
 
438
 
class SmartServerBranchRequestGetPhysicalLockStatus(SmartServerBranchRequest):
439
 
    """Get the physical lock status for a branch.
440
 
 
441
 
    New in 2.5.
442
 
    """
443
 
 
444
 
    def do_with_branch(self, branch):
445
 
        if branch.get_physical_lock_status():
446
 
            return SuccessfulSmartServerResponse(('yes',))
447
 
        else:
448
 
            return SuccessfulSmartServerResponse(('no',))