/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/builtins.py

  • Committer: Robert Collins
  • Date: 2007-04-04 05:19:38 UTC
  • mfrom: (2395 +trunk)
  • mto: This revision was merged to the branch mainline in revision 2401.
  • Revision ID: robertc@robertcollins.net-20070404051938-2lnvpsm2tbo5a6g2
Merge bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
148
148
    unknown
149
149
        Not versioned and not matching an ignore pattern.
150
150
 
151
 
    To see ignored files use 'bzr ignored'.  For details in the
 
151
    To see ignored files use 'bzr ignored'.  For details on the
152
152
    changes to file texts, use 'bzr diff'.
153
153
    
154
154
    --short gives a status flags for each item, similar to the SVN's status
183
183
    # TODO: --no-recurse, --recurse options
184
184
    
185
185
    takes_args = ['file*']
186
 
    takes_options = ['show-ids', 'revision', 'short',
 
186
    takes_options = ['show-ids', 'revision',
 
187
                     Option('short', help='Give short SVN-style status lines'),
187
188
                     Option('versioned', help='Only show versioned files')]
188
189
    aliases = ['st', 'stat']
189
190
 
568
569
            directory=None):
569
570
        from bzrlib.tag import _merge_tags_if_possible
570
571
        # FIXME: too much stuff is in the command class
 
572
        revision_id = None
 
573
        mergeable = None
571
574
        if directory is None:
572
575
            directory = u'.'
573
576
        try:
580
583
        reader = None
581
584
        if location is not None:
582
585
            try:
583
 
                reader = bundle.read_bundle_from_url(location)
 
586
                mergeable = bundle.read_mergeable_from_url(
 
587
                    location)
584
588
            except errors.NotABundle:
585
589
                pass # Continue on considering this url a Branch
586
590
 
595
599
                self.outf.write("Using saved location: %s\n" % display_url)
596
600
                location = stored_loc
597
601
 
598
 
        if reader is not None:
599
 
            install_bundle(branch_to.repository, reader)
 
602
        if mergeable is not None:
 
603
            if revision is not None:
 
604
                raise errors.BzrCommandError(
 
605
                    'Cannot use -r with merge directives or bundles')
 
606
            revision_id = mergeable.install_revisions(branch_to.repository)
600
607
            branch_from = branch_to
601
608
        else:
602
609
            branch_from = Branch.open(location)
604
611
            if branch_to.get_parent() is None or remember:
605
612
                branch_to.set_parent(branch_from.base)
606
613
 
607
 
        rev_id = None
608
 
        if revision is None:
609
 
            if reader is not None:
610
 
                rev_id = reader.target
611
 
        elif len(revision) == 1:
612
 
            rev_id = revision[0].in_history(branch_from).rev_id
613
 
        else:
614
 
            raise errors.BzrCommandError('bzr pull --revision takes one value.')
 
614
        if revision is not None:
 
615
            if len(revision) == 1:
 
616
                revision_id = revision[0].in_history(branch_from).rev_id
 
617
            else:
 
618
                raise errors.BzrCommandError(
 
619
                    'bzr pull --revision takes one value.')
615
620
 
616
621
        old_rh = branch_to.revision_history()
617
622
        if tree_to is not None:
618
 
            result = tree_to.pull(branch_from, overwrite, rev_id,
 
623
            result = tree_to.pull(branch_from, overwrite, revision_id,
619
624
                delta._ChangeReporter(unversioned_filter=tree_to.is_ignored))
620
625
        else:
621
 
            result = branch_to.pull(branch_from, overwrite, rev_id)
 
626
            result = branch_to.pull(branch_from, overwrite, revision_id)
622
627
 
623
628
        result.report(self.outf)
624
629
        if verbose:
625
630
            from bzrlib.log import show_changed_revisions
626
631
            new_rh = branch_to.revision_history()
627
 
            show_changed_revisions(branch_to, old_rh, new_rh, to_file=self.outf)
 
632
            show_changed_revisions(branch_to, old_rh, new_rh,
 
633
                                   to_file=self.outf)
628
634
 
629
635
 
630
636
class cmd_push(Command):
834
840
 
835
841
    To retrieve the branch as of a particular revision, supply the --revision
836
842
    parameter, as in "branch foo/bar -r 5".
837
 
 
838
 
    --basis is to speed up branching from remote branches.  When specified, it
839
 
    copies all the file-contents, inventory and revision data from the basis
840
 
    branch before copying anything from the remote branch.
841
843
    """
842
844
    takes_args = ['from_location', 'to_location?']
843
 
    takes_options = ['revision', 'basis']
 
845
    takes_options = ['revision']
844
846
    aliases = ['get', 'clone']
845
847
 
846
 
    def run(self, from_location, to_location=None, revision=None, basis=None):
 
848
    def run(self, from_location, to_location=None, revision=None):
847
849
        from bzrlib.tag import _merge_tags_if_possible
848
850
        if revision is None:
849
851
            revision = [None]
854
856
        br_from = Branch.open(from_location)
855
857
        br_from.lock_read()
856
858
        try:
857
 
            if basis is not None:
858
 
                basis_dir = bzrdir.BzrDir.open_containing(basis)[0]
859
 
            else:
860
 
                basis_dir = None
861
859
            if len(revision) == 1 and revision[0] is not None:
862
860
                revision_id = revision[0].in_history(br_from)[1]
863
861
            else:
882
880
                                             % to_location)
883
881
            try:
884
882
                # preserve whatever source format we have.
885
 
                dir = br_from.bzrdir.sprout(to_transport.base,
886
 
                        revision_id, basis_dir)
 
883
                dir = br_from.bzrdir.sprout(to_transport.base, revision_id)
887
884
                branch = dir.open_branch()
888
885
            except errors.NoSuchRevision:
889
886
                to_transport.delete_tree('.')
890
887
                msg = "The branch %s has no revision %s." % (from_location, revision[0])
891
888
                raise errors.BzrCommandError(msg)
892
 
            except errors.UnlistableBranch:
893
 
                osutils.rmtree(to_location)
894
 
                msg = "The branch %s cannot be used as a --basis" % (basis,)
895
 
                raise errors.BzrCommandError(msg)
896
889
            if name:
897
890
                branch.control_files.put_utf8('branch-name', name)
898
891
            _merge_tags_if_possible(br_from, branch)
917
910
    out of date [so you cannot commit] but it may be useful (i.e. to examine old
918
911
    code.)
919
912
 
920
 
    --basis is to speed up checking out from remote branches.  When specified, it
921
 
    uses the inventory and file contents from the basis branch in preference to the
922
 
    branch being checked out.
923
 
 
924
913
    See "help checkouts" for more information on checkouts.
925
914
    """
926
915
    takes_args = ['branch_location?', 'to_location?']
927
 
    takes_options = ['revision', # , 'basis']
 
916
    takes_options = ['revision',
928
917
                     Option('lightweight',
929
918
                            help="perform a lightweight checkout. Lightweight "
930
919
                                 "checkouts depend on access to the branch for "
935
924
                     ]
936
925
    aliases = ['co']
937
926
 
938
 
    def run(self, branch_location=None, to_location=None, revision=None, basis=None,
 
927
    def run(self, branch_location=None, to_location=None, revision=None,
939
928
            lightweight=False):
940
929
        if revision is None:
941
930
            revision = [None]
1213
1202
 
1214
1203
    If there is a repository in a parent directory of the location, then 
1215
1204
    the history of the branch will be stored in the repository.  Otherwise
1216
 
    init creates a standalone branch which carries its own history in 
1217
 
    .bzr.
 
1205
    init creates a standalone branch which carries its own history
 
1206
    in the .bzr directory.
1218
1207
 
1219
1208
    If there is already a branch at the location but it has no working tree,
1220
1209
    the tree can be populated with 'bzr checkout'.
1917
1906
 
1918
1907
 
1919
1908
class cmd_export(Command):
1920
 
    """Export past revision to destination directory.
 
1909
    """Export current or past revision to a destination directory or archive.
1921
1910
 
1922
1911
    If no revision is specified this exports the last committed revision.
1923
1912
 
1928
1917
    Root may be the top directory for tar, tgz and tbz2 formats. If none
1929
1918
    is given, the top directory will be the root name of the file.
1930
1919
 
1931
 
    If branch is omitted then the branch containing the CWD will be used.
 
1920
    If branch is omitted then the branch containing the current working
 
1921
    directory will be used.
1932
1922
 
1933
1923
    Note: export of tree with non-ascii filenames to zip is not supported.
1934
1924
 
1966
1956
 
1967
1957
 
1968
1958
class cmd_cat(Command):
1969
 
    """Write a file's text from a previous revision."""
 
1959
    """Write the contents of a file as of a given revision to standard output.
 
1960
 
 
1961
    If no revision is nominated, the last revision is used.
 
1962
 
 
1963
    Note: Take care to redirect standard output when using this command on a
 
1964
    binary file. 
 
1965
    """
1970
1966
 
1971
1967
    takes_options = ['revision', 'name-from-revision']
1972
1968
    takes_args = ['filename']
2239
2235
 
2240
2236
    @display_command
2241
2237
    def printme(self, branch):
2242
 
        print branch.nick 
 
2238
        print branch.nick
2243
2239
 
2244
2240
 
2245
2241
class cmd_selftest(Command):
2468
2464
    
2469
2465
    merge refuses to run if there are any uncommitted changes, unless
2470
2466
    --force is given.
2471
 
 
2472
 
    The following merge types are available:
2473
2467
    """
2474
2468
    takes_args = ['branch?']
2475
2469
    takes_options = ['revision', 'force', 'merge-type', 'reprocess', 'remember',
2495
2489
            directory=None,
2496
2490
            ):
2497
2491
        from bzrlib.tag import _merge_tags_if_possible
 
2492
        other_revision_id = None
2498
2493
        if merge_type is None:
2499
2494
            merge_type = _mod_merge.Merge3Merger
2500
2495
 
2512
2507
 
2513
2508
        if branch is not None:
2514
2509
            try:
2515
 
                reader = bundle.read_bundle_from_url(branch)
 
2510
                mergeable = bundle.read_mergeable_from_url(
 
2511
                    branch)
2516
2512
            except errors.NotABundle:
2517
2513
                pass # Continue on considering this url a Branch
2518
2514
            else:
2519
 
                conflicts = merge_bundle(reader, tree, not force, merge_type,
2520
 
                                         reprocess, show_base, change_reporter)
2521
 
                if conflicts == 0:
2522
 
                    return 0
2523
 
                else:
2524
 
                    return 1
 
2515
                if revision is not None:
 
2516
                    raise errors.BzrCommandError(
 
2517
                        'Cannot use -r with merge directives or bundles')
 
2518
                other_revision_id = mergeable.install_revisions(
 
2519
                    tree.branch.repository)
 
2520
                revision = [RevisionSpec.from_string(
 
2521
                    'revid:' + other_revision_id)]
2525
2522
 
2526
2523
        if revision is None \
2527
2524
                or len(revision) < 1 or revision[0].needs_branch():
2542
2539
            branch = revision[0].get_branch() or branch
2543
2540
            if len(revision) == 1:
2544
2541
                base = [None, None]
2545
 
                other_branch, path = Branch.open_containing(branch)
2546
 
                revno = revision[0].in_history(other_branch).revno
2547
 
                other = [branch, revno]
 
2542
                if other_revision_id is not None:
 
2543
                    other_branch = None
 
2544
                    path = ""
 
2545
                    other = None
 
2546
                else:
 
2547
                    other_branch, path = Branch.open_containing(branch)
 
2548
                    revno = revision[0].in_history(other_branch).revno
 
2549
                    other = [branch, revno]
2548
2550
            else:
2549
2551
                assert len(revision) == 2
2550
2552
                if None in revision:
2560
2562
                base = [branch, revision[0].in_history(base_branch).revno]
2561
2563
                other = [branch1, revision[1].in_history(other_branch).revno]
2562
2564
 
2563
 
        if tree.branch.get_parent() is None or remember:
 
2565
        if ((tree.branch.get_parent() is None or remember) and
 
2566
            other_branch is not None):
2564
2567
            tree.branch.set_parent(other_branch.base)
2565
2568
 
2566
2569
        # pull tags now... it's a bit inconsistent to do it ahead of copying
2567
2570
        # the history but that's done inside the merge code
2568
 
        _merge_tags_if_possible(other_branch, tree.branch)
 
2571
        if other_branch is not None:
 
2572
            _merge_tags_if_possible(other_branch, tree.branch)
2569
2573
 
2570
2574
        if path != "":
2571
2575
            interesting_files = [path]
2575
2579
        try:
2576
2580
            try:
2577
2581
                conflict_count = _merge_helper(
2578
 
                    other, base, check_clean=(not force),
 
2582
                    other, base, other_rev_id=other_revision_id,
 
2583
                    check_clean=(not force),
2579
2584
                    merge_type=merge_type,
2580
2585
                    reprocess=reprocess,
2581
2586
                    show_base=show_base,
2634
2639
    $ bzr remerge --merge-type weave --reprocess foobar
2635
2640
        Re-do the merge of "foobar", using the weave merge algorithm, with
2636
2641
        additional processing to reduce the size of conflict regions.
2637
 
    
2638
 
    The following merge types are available:"""
 
2642
    """
2639
2643
    takes_args = ['file*']
2640
2644
    takes_options = ['merge-type', 'reprocess',
2641
2645
                     Option('show-base', help="Show base revision text in "
3502
3506
                  file_list=None, show_base=False, reprocess=False,
3503
3507
                  pull=False,
3504
3508
                  pb=DummyProgress(),
3505
 
                  change_reporter=None):
 
3509
                  change_reporter=None,
 
3510
                  other_rev_id=None):
3506
3511
    """Merge changes into a tree.
3507
3512
 
3508
3513
    base_revision
3558
3563
        merger.pp = ProgressPhase("Merge phase", 5, pb)
3559
3564
        merger.pp.next_phase()
3560
3565
        merger.check_basis(check_clean)
3561
 
        merger.set_other(other_revision)
 
3566
        if other_rev_id is not None:
 
3567
            merger.set_other_revision(other_rev_id, this_tree.branch)
 
3568
        else:
 
3569
            merger.set_other(other_revision)
3562
3570
        merger.pp.next_phase()
3563
3571
        merger.set_base(base_revision)
3564
3572
        if merger.base_rev_id == merger.other_rev_id: