~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/builtins.py

Merge bound branch test performance improvements.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2136
2136
                raise BzrCommandError("No missing location known or specified.")
2137
2137
            print "Using last location: " + local_branch.get_parent()
2138
2138
        remote_branch = bzrlib.branch.Branch.open(other_branch)
2139
 
        local_branch.lock_write()
2140
2139
        if remote_branch.base == local_branch.base:
2141
2140
            remote_branch = local_branch
 
2141
        local_branch.lock_read()
2142
2142
        try:
2143
2143
            remote_branch.lock_read()
2144
2144
            try:
2172
2172
                    print "Branches are up to date."
2173
2173
                else:
2174
2174
                    status_code = 1
2175
 
                if parent is None and other_branch is not None:
 
2175
            finally:
 
2176
                remote_branch.unlock()
 
2177
        finally:
 
2178
            local_branch.unlock()
 
2179
        if not status_code and parent is None and other_branch is not None:
 
2180
            local_branch.lock_write()
 
2181
            try:
 
2182
                # handle race conditions - a parent might be set while we run.
 
2183
                if local_branch.get_parent() is None:
2176
2184
                    local_branch.set_parent(other_branch)
2177
 
                return status_code
2178
2185
            finally:
2179
2186
                local_branch.unlock()
2180
 
        finally:
2181
 
            remote_branch.unlock()
 
2187
        return status_code
2182
2188
 
2183
2189
 
2184
2190
class cmd_plugins(Command):