~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/builtins.py

[merge] olaf's --remember changes

Show diffs side-by-side

added added

removed removed

Lines of Context:
362
362
class cmd_pull(Command):
363
363
    """Turn this branch into a mirror of another branch.
364
364
 
365
 
    If there is no default location set, the first pull will set it.  After
366
 
    that, you can omit the location to use the default.  To change the
367
 
    default, use --remember.
368
 
 
369
365
    This command only works on branches that have not diverged.  Branches are
370
366
    considered diverged if the destination branch's most recent commit is one
371
367
    that has not been merged (directly or indirectly) into the parent.
372
368
 
 
369
    If branches have diverged, you can use 'bzr merge' to integrate the changes
 
370
    from one into the other.  Once one branch has merged, the other should
 
371
    be able to pull it again.
 
372
 
373
373
    If branches have diverged, you can use 'bzr merge' to pull the text changes
374
374
    from one into the other.  Once one branch has merged, the other should
375
375
    be able to pull it again.
376
376
 
377
377
    If you want to forget your local changes and just update your branch to
378
 
    match the remote one, use --overwrite.
 
378
    match the remote one, use pull --overwrite.
 
379
 
 
380
    If there is no default location set, the first pull will set it.  After
 
381
    that, you can omit the location to use the default.  To change the
 
382
    default, use --remember.
379
383
    """
380
384
    takes_options = ['remember', 'overwrite', 'revision', 'verbose']
381
385
    takes_args = ['location?']
396
400
                print "Using saved location: %s" % stored_loc
397
401
                location = stored_loc
398
402
 
399
 
        br_from = Branch.open(location)
 
403
        if branch_to.get_parent() is None or remember:
 
404
            branch_to.set_parent(location)
 
405
 
 
406
        branch_from = Branch.open(location)
400
407
 
401
408
        if revision is None:
402
409
            rev_id = None
403
410
        elif len(revision) == 1:
404
 
            rev_id = revision[0].in_history(br_from).rev_id
 
411
            rev_id = revision[0].in_history(branch_from).rev_id
405
412
        else:
406
413
            raise BzrCommandError('bzr pull --revision takes one value.')
407
414
 
408
415
        old_rh = branch_to.revision_history()
409
416
        if tree_to is not None:
410
 
            count = tree_to.pull(br_from, overwrite, rev_id)
 
417
            count = tree_to.pull(branch_from, overwrite, rev_id)
411
418
        else:
412
 
            count = branch_to.pull(br_from, overwrite, rev_id)
413
 
 
414
 
        if branch_to.get_parent() is None or remember:
415
 
            branch_to.set_parent(location)
 
419
            count = branch_to.pull(branch_from, overwrite, rev_id)
416
420
        note('%d revision(s) pulled.' % (count,))
417
421
 
418
422
        if verbose:
432
436
    Some smart servers or protocols *may* put the working tree in place in
433
437
    the future.
434
438
 
435
 
    If there is no default push location set, the first push will set it.
436
 
    After that, you can omit the location to use the default.  To change the
437
 
    default, use --remember.
438
 
 
439
439
    This command only works on branches that have not diverged.  Branches are
440
440
    considered diverged if the destination branch's most recent commit is one
441
441
    that has not been merged (directly or indirectly) by the source branch.
446
446
    If you want to ensure you have the different changes in the other branch,
447
447
    do a merge (see bzr help merge) from the other branch, and commit that.
448
448
    After that you will be able to do a push without '--overwrite'.
 
449
 
 
450
    If there is no default push location set, the first push will set it.
 
451
    After that, you can omit the location to use the default.  To change the
 
452
    default, use --remember.
449
453
    """
450
454
    takes_options = ['remember', 'overwrite', 
451
455
                     Option('create-prefix', 
468
472
            else:
469
473
                print "Using saved location: %s" % stored_loc
470
474
                location = stored_loc
 
475
        if br_from.get_push_location() is None or remember:
 
476
            br_from.set_push_location(location)
471
477
        try:
472
478
            dir_to = bzrlib.bzrdir.BzrDir.open(location)
473
479
            br_to = dir_to.open_branch()
515
521
        except DivergedBranches:
516
522
            raise BzrCommandError("These branches have diverged."
517
523
                                  "  Try a merge then push with overwrite.")
518
 
        if br_from.get_push_location() is None or remember:
519
 
            br_from.set_push_location(location)
520
524
        note('%d revision(s) pushed.' % (count,))
521
525
 
522
526
        if verbose:
1838
1842
 
1839
1843
    Use bzr resolve when you have fixed a problem.  See also bzr conflicts.
1840
1844
 
 
1845
    If there is no default branch set, the first merge will set it. After
 
1846
    that, you can omit the branch to use the default.  To change the
 
1847
    default, use --remember.
 
1848
 
1841
1849
    Examples:
1842
1850
 
1843
1851
    To merge the latest revision from bzr.dev
1853
1861
    --force is given.
1854
1862
    """
1855
1863
    takes_args = ['branch?']
1856
 
    takes_options = ['revision', 'force', 'merge-type', 'reprocess',
 
1864
    takes_options = ['revision', 'force', 'merge-type', 'reprocess', 'remember',
1857
1865
                     Option('show-base', help="Show base revision text in "
1858
1866
                            "conflicts")]
1859
1867
 
1860
1868
    def run(self, branch=None, revision=None, force=False, merge_type=None,
1861
 
            show_base=False, reprocess=False):
 
1869
            show_base=False, reprocess=False, remember=False):
1862
1870
        if merge_type is None:
1863
1871
            merge_type = Merge3Merger
 
1872
 
 
1873
        tree = WorkingTree.open_containing(u'.')[0]
 
1874
        stored_loc = tree.branch.get_parent()
1864
1875
        if branch is None:
1865
 
            branch = WorkingTree.open_containing(u'.')[0].branch.get_parent()
1866
 
            if branch is None:
1867
 
                raise BzrCommandError("No merge location known or specified.")
 
1876
            if stored_loc is None:
 
1877
                raise BzrCommandError("No merge branch known or specified.")
1868
1878
            else:
1869
 
                print "Using saved location: %s" % branch 
 
1879
                print "Using saved branch: %s" % stored_loc
 
1880
                branch = stored_loc
 
1881
 
 
1882
        if tree.branch.get_parent() is None or remember:
 
1883
            tree.branch.set_parent(branch)
 
1884
 
1870
1885
        if revision is None or len(revision) < 1:
1871
1886
            base = [None, None]
1872
1887
            other = [branch, -1]