~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/builtins.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2006-04-13 23:16:57 UTC
  • mfrom: (1662.1.1 bzr.mbp.integration)
  • Revision ID: pqm@pqm.ubuntu.com-20060413231657-bce3d67d3e7a4f2b
(mbp/olaf) push/pull/merge --remember improvements

Show diffs side-by-side

added added

removed removed

Lines of Context:
373
373
class cmd_pull(Command):
374
374
    """Turn this branch into a mirror of another branch.
375
375
 
376
 
    If there is no default location set, the first pull will set it.  After
377
 
    that, you can omit the location to use the default.  To change the
378
 
    default, use --remember.
379
 
 
380
376
    This command only works on branches that have not diverged.  Branches are
381
377
    considered diverged if the destination branch's most recent commit is one
382
378
    that has not been merged (directly or indirectly) into the parent.
383
379
 
 
380
    If branches have diverged, you can use 'bzr merge' to integrate the changes
 
381
    from one into the other.  Once one branch has merged, the other should
 
382
    be able to pull it again.
 
383
 
384
384
    If branches have diverged, you can use 'bzr merge' to pull the text changes
385
385
    from one into the other.  Once one branch has merged, the other should
386
386
    be able to pull it again.
387
387
 
388
388
    If you want to forget your local changes and just update your branch to
389
 
    match the remote one, use --overwrite.
 
389
    match the remote one, use pull --overwrite.
 
390
 
 
391
    If there is no default location set, the first pull will set it.  After
 
392
    that, you can omit the location to use the default.  To change the
 
393
    default, use --remember.
390
394
    """
391
395
    takes_options = ['remember', 'overwrite', 'revision', 'verbose']
392
396
    takes_args = ['location?']
407
411
                print "Using saved location: %s" % stored_loc
408
412
                location = stored_loc
409
413
 
410
 
        br_from = Branch.open(location)
 
414
        if branch_to.get_parent() is None or remember:
 
415
            branch_to.set_parent(location)
 
416
 
 
417
        branch_from = Branch.open(location)
411
418
 
412
419
        if revision is None:
413
420
            rev_id = None
414
421
        elif len(revision) == 1:
415
 
            rev_id = revision[0].in_history(br_from).rev_id
 
422
            rev_id = revision[0].in_history(branch_from).rev_id
416
423
        else:
417
424
            raise BzrCommandError('bzr pull --revision takes one value.')
418
425
 
419
426
        old_rh = branch_to.revision_history()
420
427
        if tree_to is not None:
421
 
            count = tree_to.pull(br_from, overwrite, rev_id)
 
428
            count = tree_to.pull(branch_from, overwrite, rev_id)
422
429
        else:
423
 
            count = branch_to.pull(br_from, overwrite, rev_id)
424
 
 
425
 
        if branch_to.get_parent() is None or remember:
426
 
            branch_to.set_parent(location)
 
430
            count = branch_to.pull(branch_from, overwrite, rev_id)
427
431
        note('%d revision(s) pulled.' % (count,))
428
432
 
429
433
        if verbose:
443
447
    Some smart servers or protocols *may* put the working tree in place in
444
448
    the future.
445
449
 
446
 
    If there is no default push location set, the first push will set it.
447
 
    After that, you can omit the location to use the default.  To change the
448
 
    default, use --remember.
449
 
 
450
450
    This command only works on branches that have not diverged.  Branches are
451
451
    considered diverged if the destination branch's most recent commit is one
452
452
    that has not been merged (directly or indirectly) by the source branch.
457
457
    If you want to ensure you have the different changes in the other branch,
458
458
    do a merge (see bzr help merge) from the other branch, and commit that.
459
459
    After that you will be able to do a push without '--overwrite'.
 
460
 
 
461
    If there is no default push location set, the first push will set it.
 
462
    After that, you can omit the location to use the default.  To change the
 
463
    default, use --remember.
460
464
    """
461
465
    takes_options = ['remember', 'overwrite', 
462
466
                     Option('create-prefix', 
479
483
            else:
480
484
                print "Using saved location: %s" % stored_loc
481
485
                location = stored_loc
 
486
        if br_from.get_push_location() is None or remember:
 
487
            br_from.set_push_location(location)
482
488
        try:
483
489
            dir_to = bzrlib.bzrdir.BzrDir.open(location)
484
490
            br_to = dir_to.open_branch()
526
532
        except DivergedBranches:
527
533
            raise BzrCommandError("These branches have diverged."
528
534
                                  "  Try a merge then push with overwrite.")
529
 
        if br_from.get_push_location() is None or remember:
530
 
            br_from.set_push_location(location)
531
535
        note('%d revision(s) pushed.' % (count,))
532
536
 
533
537
        if verbose:
1862
1866
 
1863
1867
    Use bzr resolve when you have fixed a problem.  See also bzr conflicts.
1864
1868
 
 
1869
    If there is no default branch set, the first merge will set it. After
 
1870
    that, you can omit the branch to use the default.  To change the
 
1871
    default, use --remember.
 
1872
 
1865
1873
    Examples:
1866
1874
 
1867
1875
    To merge the latest revision from bzr.dev
1877
1885
    --force is given.
1878
1886
    """
1879
1887
    takes_args = ['branch?']
1880
 
    takes_options = ['revision', 'force', 'merge-type', 'reprocess',
 
1888
    takes_options = ['revision', 'force', 'merge-type', 'reprocess', 'remember',
1881
1889
                     Option('show-base', help="Show base revision text in "
1882
1890
                            "conflicts")]
1883
1891
 
1884
1892
    def run(self, branch=None, revision=None, force=False, merge_type=None,
1885
 
            show_base=False, reprocess=False):
 
1893
            show_base=False, reprocess=False, remember=False):
1886
1894
        if merge_type is None:
1887
1895
            merge_type = Merge3Merger
 
1896
 
 
1897
        tree = WorkingTree.open_containing(u'.')[0]
 
1898
        stored_loc = tree.branch.get_parent()
1888
1899
        if branch is None:
1889
 
            branch = WorkingTree.open_containing(u'.')[0].branch.get_parent()
1890
 
            if branch is None:
1891
 
                raise BzrCommandError("No merge location known or specified.")
 
1900
            if stored_loc is None:
 
1901
                raise BzrCommandError("No merge branch known or specified.")
1892
1902
            else:
1893
 
                print "Using saved location: %s" % branch 
 
1903
                print "Using saved branch: %s" % stored_loc
 
1904
                branch = stored_loc
 
1905
 
 
1906
        if tree.branch.get_parent() is None or remember:
 
1907
            tree.branch.set_parent(branch)
 
1908
 
1894
1909
        if revision is None or len(revision) < 1:
1895
1910
            base = [None, None]
1896
1911
            other = [branch, -1]