~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/builtins.py

[merge] robert

Show diffs side-by-side

added added

removed removed

Lines of Context:
334
334
    If branches have diverged, you can use 'bzr merge' to pull the text changes
335
335
    from one into the other.
336
336
    """
337
 
    takes_options = ['remember']
 
337
    takes_options = ['remember', 'clobber']
338
338
    takes_args = ['location?']
339
339
 
340
 
    def run(self, location=None, remember=False):
 
340
    def run(self, location=None, remember=False, clobber=False):
341
341
        from bzrlib.merge import merge
342
342
        import tempfile
343
343
        from shutil import rmtree
351
351
            else:
352
352
                print "Using saved location: %s" % stored_loc
353
353
                location = stored_loc
354
 
        cache_root = tempfile.mkdtemp()
355
354
        br_from = Branch.open(location)
356
 
        br_from.lock_read()
357
355
        try:
358
 
            br_from.setup_caching(cache_root)
359
 
            location = br_from.base
360
 
            old_revno = br_to.revno()
361
 
            old_revision_history = br_to.revision_history()
362
 
            try:
363
 
                br_to.update_revisions(br_from)
364
 
            except DivergedBranches:
365
 
                raise BzrCommandError("These branches have diverged."
366
 
                    "  Try merge.")
367
 
            new_revision_history = br_to.revision_history()
368
 
            if new_revision_history != old_revision_history:
369
 
                merge(('.', -1), ('.', old_revno), check_clean=False)
370
 
            if stored_loc is None or remember:
371
 
                br_to.set_parent(location)
372
 
        finally:
373
 
            br_from.unlock()
374
 
            rmtree(cache_root)
375
 
 
 
356
            br_to.working_tree().pull(br_from, remember, clobber)
 
357
        except DivergedBranches:
 
358
            raise BzrCommandError("These branches have diverged."
 
359
                                  "  Try merge.")
376
360
 
377
361
 
378
362
class cmd_branch(Command):
439
423
                copy_branch(br_from, to_location, revision_id, basis_branch)
440
424
            except bzrlib.errors.NoSuchRevision:
441
425
                rmtree(to_location)
442
 
                msg = "The branch %s has no revision %d." % (from_location, revision[0])
 
426
                msg = "The branch %s has no revision %s." % (from_location, revision[0])
443
427
                raise BzrCommandError(msg)
444
428
            except bzrlib.errors.UnlistableBranch:
445
429
                msg = "The branch %s cannot be used as a --basis"