~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/smart/branch.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2009-07-27 09:33:30 UTC
  • mfrom: (4556.2.10 hpss-push-tags)
  • Revision ID: pqm@pqm.ubuntu.com-20090727093330-882xn6s1tt1zbnw6
(andrew) Add Branch.set_tags_bytes verb, removing more VFS calls.

Show diffs side-by-side

added added

removed removed

Lines of Context:
103
103
        return SuccessfulSmartServerResponse((bytes,))
104
104
 
105
105
 
 
106
class SmartServerBranchSetTagsBytes(SmartServerLockedBranchRequest):
 
107
 
 
108
    def __init__(self, backing_transport, root_client_path='/'):
 
109
        SmartServerLockedBranchRequest.__init__(
 
110
            self, backing_transport, root_client_path)
 
111
        self.locked = False
 
112
        
 
113
    def do_with_locked_branch(self, branch):
 
114
        """Call _set_tags_bytes for a branch.
 
115
 
 
116
        New in 1.18.
 
117
        """
 
118
        # We need to keep this branch locked until we get a body with the tags
 
119
        # bytes.
 
120
        self.branch = branch
 
121
        self.branch.lock_write()
 
122
        self.locked = True
 
123
 
 
124
    def do_body(self, bytes):
 
125
        self.branch._set_tags_bytes(bytes)
 
126
        return SuccessfulSmartServerResponse(())
 
127
 
 
128
    def do_end(self):
 
129
        # TODO: this request shouldn't have to do this housekeeping manually.
 
130
        # Some of this logic probably belongs in a base class.
 
131
        if not self.locked:
 
132
            # We never acquired the branch successfully in the first place, so
 
133
            # there's nothing more to do.
 
134
            return
 
135
        try:
 
136
            return SmartServerLockedBranchRequest.do_end(self)
 
137
        finally:
 
138
            # Only try unlocking if we locked successfully in the first place
 
139
            self.branch.unlock()
 
140
 
 
141
 
106
142
class SmartServerBranchRequestGetStackedOnURL(SmartServerBranchRequest):
107
143
 
108
144
    def do_with_branch(self, branch):