~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/builtins.py

[merge] speedups from robertc

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
import bzrlib.trace
23
23
from bzrlib.trace import mutter, note, log_error, warning
24
24
from bzrlib.errors import BzrError, BzrCheckError, BzrCommandError, NotBranchError
 
25
from bzrlib.errors import DivergedBranches
25
26
from bzrlib.branch import Branch
26
27
from bzrlib import BZRDIR
27
28
from bzrlib.commands import Command
341
342
                print "Using saved location: %s" % stored_loc
342
343
                location = stored_loc
343
344
        cache_root = tempfile.mkdtemp()
344
 
        from bzrlib.errors import DivergedBranches
345
 
        br_from = Branch.open_containing(location)
346
 
        location = br_from.base
347
 
        old_revno = br_to.revno()
 
345
        br_from = Branch.open(location)
 
346
        br_from.lock_read()
348
347
        try:
349
 
            from bzrlib.errors import DivergedBranches
350
 
            br_from = Branch.open(location)
351
348
            br_from.setup_caching(cache_root)
352
349
            location = br_from.base
353
350
            old_revno = br_to.revno()
 
351
            old_revision_history = br_to.revision_history()
354
352
            try:
355
353
                br_to.update_revisions(br_from)
356
354
            except DivergedBranches:
357
355
                raise BzrCommandError("These branches have diverged."
358
356
                    "  Try merge.")
359
 
                
360
 
            merge(('.', -1), ('.', old_revno), check_clean=False)
 
357
            new_revision_history = br_to.revision_history()
 
358
            if new_revision_history != old_revision_history:
 
359
                merge(('.', -1), ('.', old_revno), check_clean=False)
361
360
            if stored_loc is None or remember:
362
361
                br_to.set_parent(location)
363
362
        finally:
 
363
            br_from.unlock()
364
364
            rmtree(cache_root)
365
365
 
366
366