/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

merge bzr.dev into cleanup

Show diffs side-by-side

added added

removed removed

Lines of Context:
43
43
    reconfigure,
44
44
    rename_map,
45
45
    revision as _mod_revision,
 
46
    static_tuple,
46
47
    symbol_versioning,
 
48
    timestamp,
47
49
    transport,
48
50
    ui,
49
51
    urlutils,
257
259
    unknown
258
260
        Not versioned and not matching an ignore pattern.
259
261
 
 
262
    Additionally for directories, symlinks and files with an executable
 
263
    bit, Bazaar indicates their type using a trailing character: '/', '@'
 
264
    or '*' respectively.
 
265
 
260
266
    To see ignored files use 'bzr ignored'.  For details on the
261
267
    changes to file texts, use 'bzr diff'.
262
268
 
431
437
        for node in bt.iter_all_entries():
432
438
            # Node is made up of:
433
439
            # (index, key, value, [references])
434
 
            refs_as_tuples = tuple([tuple([tuple(ref) for ref in ref_list])
435
 
                                   for ref_list in node[3]])
 
440
            refs_as_tuples = static_tuple.as_tuples(node[3])
436
441
            as_tuple = (tuple(node[1]), node[2], refs_as_tuples)
437
442
            self.outf.write('%s\n' % (as_tuple,))
438
443
 
655
660
        if base_tree:
656
661
            base_tree.lock_read()
657
662
        try:
658
 
            file_list = self._maybe_expand_globs(file_list)
659
663
            tree, file_list = tree_files_for_add(file_list)
660
664
            added, ignored = tree.smart_add(file_list, not
661
665
                no_recurse, action=action, save=not dry_run)
850
854
            # All entries reference existing inventory items, so fix them up
851
855
            # for cicp file-systems.
852
856
            rel_names = tree.get_canonical_inventory_paths(rel_names)
853
 
            for pair in tree.move(rel_names[:-1], rel_names[-1], after=after):
854
 
                self.outf.write("%s => %s\n" % pair)
 
857
            for src, dest in tree.move(rel_names[:-1], rel_names[-1], after=after):
 
858
                if not is_quiet():
 
859
                    self.outf.write("%s => %s\n" % (src, dest))
855
860
        else:
856
861
            if len(names_list) != 2:
857
862
                raise errors.BzrCommandError('to mv multiple files the'
901
906
            dest = osutils.pathjoin(dest_parent, dest_tail)
902
907
            mutter("attempting to move %s => %s", src, dest)
903
908
            tree.rename_one(src, dest, after=after)
904
 
            self.outf.write("%s => %s\n" % (src, dest))
 
909
            if not is_quiet():
 
910
                self.outf.write("%s => %s\n" % (src, dest))
905
911
 
906
912
 
907
913
class cmd_pull(Command):
908
914
    """Turn this branch into a mirror of another branch.
909
915
 
910
 
    This command only works on branches that have not diverged.  Branches are
911
 
    considered diverged if the destination branch's most recent commit is one
912
 
    that has not been merged (directly or indirectly) into the parent.
 
916
    By default, this command only works on branches that have not diverged.
 
917
    Branches are considered diverged if the destination branch's most recent 
 
918
    commit is one that has not been merged (directly or indirectly) into the 
 
919
    parent.
913
920
 
914
921
    If branches have diverged, you can use 'bzr merge' to integrate the changes
915
922
    from one into the other.  Once one branch has merged, the other should
916
923
    be able to pull it again.
917
924
 
918
 
    If you want to forget your local changes and just update your branch to
919
 
    match the remote one, use pull --overwrite.
 
925
    If you want to replace your local changes and just want your branch to
 
926
    match the remote one, use pull --overwrite. This will work even if the two
 
927
    branches have diverged.
920
928
 
921
929
    If there is no default location set, the first pull will set it.  After
922
930
    that, you can omit the location to use the default.  To change the
1201
1209
        from bzrlib.tag import _merge_tags_if_possible
1202
1210
        accelerator_tree, br_from = bzrdir.BzrDir.open_tree_or_branch(
1203
1211
            from_location)
1204
 
        if (accelerator_tree is not None and
1205
 
            accelerator_tree.supports_content_filtering()):
1206
 
            accelerator_tree = None
1207
1212
        revision = _get_one_revision('branch', revision)
1208
1213
        br_from.lock_read()
1209
1214
        try:
1749
1754
 
1750
1755
 
1751
1756
class cmd_init_repository(Command):
1752
 
    """Create a shared repository to hold branches.
 
1757
    """Create a shared repository for branches to share storage space.
1753
1758
 
1754
1759
    New branches created under the repository directory will store their
1755
 
    revisions in the repository, not in the branch directory.
 
1760
    revisions in the repository, not in the branch directory.  For branches
 
1761
    with shared history, this reduces the amount of storage needed and 
 
1762
    speeds up the creation of new branches.
1756
1763
 
1757
 
    If the --no-trees option is used then the branches in the repository
1758
 
    will not have working trees by default.
 
1764
    If the --no-trees option is given then the branches in the repository
 
1765
    will not have working trees by default.  They will still exist as 
 
1766
    directories on disk, but they will not have separate copies of the 
 
1767
    files at a certain revision.  This can be useful for repositories that
 
1768
    store branches which are interacted with through checkouts or remote
 
1769
    branches, such as on a server.
1759
1770
 
1760
1771
    :Examples:
1761
 
        Create a shared repositories holding just branches::
 
1772
        Create a shared repository holding just branches::
1762
1773
 
1763
1774
            bzr init-repo --no-trees repo
1764
1775
            bzr init repo/trunk
1830
1841
 
1831
1842
            bzr diff -r1
1832
1843
 
1833
 
        Difference between revision 2 and revision 1::
1834
 
 
1835
 
            bzr diff -r1..2
1836
 
 
1837
 
        Difference between revision 2 and revision 1 for branch xxx::
1838
 
 
1839
 
            bzr diff -r1..2 xxx
 
1844
        Difference between revision 3 and revision 1::
 
1845
 
 
1846
            bzr diff -r1..3
 
1847
 
 
1848
        Difference between revision 3 and revision 1 for branch xxx::
 
1849
 
 
1850
            bzr diff -r1..3 xxx
 
1851
 
 
1852
        To see the changes introduced in revision X::
 
1853
        
 
1854
            bzr diff -cX
 
1855
 
 
1856
        Note that in the case of a merge, the -c option shows the changes
 
1857
        compared to the left hand parent. To see the changes against
 
1858
        another parent, use::
 
1859
 
 
1860
            bzr diff -r<chosen_parent>..X
 
1861
 
 
1862
        The changes introduced by revision 2 (equivalent to -r1..2)::
 
1863
 
 
1864
            bzr diff -c2
1840
1865
 
1841
1866
        Show just the differences for file NEWS::
1842
1867
 
2276
2301
 
2277
2302
        file_ids = []
2278
2303
        filter_by_dir = False
2279
 
        if file_list:
2280
 
            # find the file ids to log and check for directory filtering
2281
 
            b, file_info_list, rev1, rev2 = _get_info_for_log_files(revision,
2282
 
                file_list)
2283
 
            for relpath, file_id, kind in file_info_list:
2284
 
                if file_id is None:
2285
 
                    raise errors.BzrCommandError(
2286
 
                        "Path unknown at end or start of revision range: %s" %
2287
 
                        relpath)
2288
 
                # If the relpath is the top of the tree, we log everything
2289
 
                if relpath == '':
2290
 
                    file_ids = []
2291
 
                    break
 
2304
        b = None
 
2305
        try:
 
2306
            if file_list:
 
2307
                # find the file ids to log and check for directory filtering
 
2308
                b, file_info_list, rev1, rev2 = _get_info_for_log_files(
 
2309
                    revision, file_list)
 
2310
                for relpath, file_id, kind in file_info_list:
 
2311
                    if file_id is None:
 
2312
                        raise errors.BzrCommandError(
 
2313
                            "Path unknown at end or start of revision range: %s" %
 
2314
                            relpath)
 
2315
                    # If the relpath is the top of the tree, we log everything
 
2316
                    if relpath == '':
 
2317
                        file_ids = []
 
2318
                        break
 
2319
                    else:
 
2320
                        file_ids.append(file_id)
 
2321
                    filter_by_dir = filter_by_dir or (
 
2322
                        kind in ['directory', 'tree-reference'])
 
2323
            else:
 
2324
                # log everything
 
2325
                # FIXME ? log the current subdir only RBC 20060203
 
2326
                if revision is not None \
 
2327
                        and len(revision) > 0 and revision[0].get_branch():
 
2328
                    location = revision[0].get_branch()
2292
2329
                else:
2293
 
                    file_ids.append(file_id)
2294
 
                filter_by_dir = filter_by_dir or (
2295
 
                    kind in ['directory', 'tree-reference'])
2296
 
        else:
2297
 
            # log everything
2298
 
            # FIXME ? log the current subdir only RBC 20060203
2299
 
            if revision is not None \
2300
 
                    and len(revision) > 0 and revision[0].get_branch():
2301
 
                location = revision[0].get_branch()
2302
 
            else:
2303
 
                location = '.'
2304
 
            dir, relpath = bzrdir.BzrDir.open_containing(location)
2305
 
            b = dir.open_branch()
2306
 
            rev1, rev2 = _get_revision_range(revision, b, self.name())
2307
 
 
2308
 
        # Decide on the type of delta & diff filtering to use
2309
 
        # TODO: add an --all-files option to make this configurable & consistent
2310
 
        if not verbose:
2311
 
            delta_type = None
2312
 
        else:
2313
 
            delta_type = 'full'
2314
 
        if not show_diff:
2315
 
            diff_type = None
2316
 
        elif file_ids:
2317
 
            diff_type = 'partial'
2318
 
        else:
2319
 
            diff_type = 'full'
2320
 
 
2321
 
        b.lock_read()
2322
 
        try:
 
2330
                    location = '.'
 
2331
                dir, relpath = bzrdir.BzrDir.open_containing(location)
 
2332
                b = dir.open_branch()
 
2333
                b.lock_read()
 
2334
                rev1, rev2 = _get_revision_range(revision, b, self.name())
 
2335
 
 
2336
            # Decide on the type of delta & diff filtering to use
 
2337
            # TODO: add an --all-files option to make this configurable & consistent
 
2338
            if not verbose:
 
2339
                delta_type = None
 
2340
            else:
 
2341
                delta_type = 'full'
 
2342
            if not show_diff:
 
2343
                diff_type = None
 
2344
            elif file_ids:
 
2345
                diff_type = 'partial'
 
2346
            else:
 
2347
                diff_type = 'full'
 
2348
 
2323
2349
            # Build the log formatter
2324
2350
            if log_format is None:
2325
2351
                log_format = log.log_formatter_registry.get_default(b)
 
2352
            # Make a non-encoding output to include the diffs - bug 328007
 
2353
            unencoded_output = ui.ui_factory.make_output_stream(encoding_type='exact')
2326
2354
            lf = log_format(show_ids=show_ids, to_file=self.outf,
 
2355
                            to_exact_file=unencoded_output,
2327
2356
                            show_timezone=timezone,
2328
2357
                            delta_format=get_verbosity_level(),
2329
2358
                            levels=levels,
2355
2384
                diff_type=diff_type, _match_using_deltas=match_using_deltas)
2356
2385
            Logger(b, rqst).show(lf)
2357
2386
        finally:
2358
 
            b.unlock()
 
2387
            if b is not None:
 
2388
                b.unlock()
2359
2389
 
2360
2390
 
2361
2391
def _get_revision_range(revisionspec_list, branch, command_name):
2425
2455
    @display_command
2426
2456
    def run(self, filename):
2427
2457
        tree, relpath = WorkingTree.open_containing(filename)
 
2458
        file_id = tree.path2id(relpath)
2428
2459
        b = tree.branch
2429
 
        file_id = tree.path2id(relpath)
2430
 
        for revno, revision_id, what in log.find_touching_revisions(b, file_id):
2431
 
            self.outf.write("%6d %s\n" % (revno, what))
 
2460
        b.lock_read()
 
2461
        try:
 
2462
            touching_revs = log.find_touching_revisions(b, file_id)
 
2463
            for revno, revision_id, what in touching_revs:
 
2464
                self.outf.write("%6d %s\n" % (revno, what))
 
2465
        finally:
 
2466
            b.unlock()
2432
2467
 
2433
2468
 
2434
2469
class cmd_ls(Command):
2486
2521
        if from_root:
2487
2522
            if relpath:
2488
2523
                prefix = relpath + '/'
2489
 
        elif fs_path != '.':
 
2524
        elif fs_path != '.' and not fs_path.endswith('/'):
2490
2525
            prefix = fs_path + '/'
2491
2526
 
2492
2527
        if revision is not None or tree is None:
2568
2603
 
2569
2604
    See ``bzr help patterns`` for details on the syntax of patterns.
2570
2605
 
 
2606
    If a .bzrignore file does not exist, the ignore command
 
2607
    will create one and add the specified files or patterns to the newly
 
2608
    created file. The ignore command will also automatically add the 
 
2609
    .bzrignore file to be versioned. Creating a .bzrignore file without
 
2610
    the use of the ignore command will require an explicit add command.
 
2611
 
2571
2612
    To remove patterns from the ignore list, edit the .bzrignore file.
2572
2613
    After adding, editing or deleting that file either indirectly by
2573
2614
    using this command or directly by using an editor, be sure to commit
2941
2982
             Option('strict',
2942
2983
                    help="Refuse to commit if there are unknown "
2943
2984
                    "files in the working tree."),
 
2985
             Option('commit-time', type=str,
 
2986
                    help="Manually set a commit time using commit date "
 
2987
                    "format, e.g. '2009-10-10 08:00:00 +0100'."),
2944
2988
             ListOption('fixes', type=str,
2945
2989
                    help="Mark a bug as being fixed by this revision "
2946
2990
                         "(see \"bzr help bugs\")."),
2953
2997
                         "the master branch until a normal commit "
2954
2998
                         "is performed."
2955
2999
                    ),
2956
 
              Option('show-diff',
2957
 
                     help='When no message is supplied, show the diff along'
2958
 
                     ' with the status summary in the message editor.'),
 
3000
             Option('show-diff',
 
3001
                    help='When no message is supplied, show the diff along'
 
3002
                    ' with the status summary in the message editor.'),
2959
3003
             ]
2960
3004
    aliases = ['ci', 'checkin']
2961
3005
 
2980
3024
 
2981
3025
    def run(self, message=None, file=None, verbose=False, selected_list=None,
2982
3026
            unchanged=False, strict=False, local=False, fixes=None,
2983
 
            author=None, show_diff=False, exclude=None):
 
3027
            author=None, show_diff=False, exclude=None, commit_time=None):
2984
3028
        from bzrlib.errors import (
2985
3029
            PointlessCommit,
2986
3030
            ConflictsInTree,
2992
3036
            make_commit_message_template_encoded
2993
3037
        )
2994
3038
 
 
3039
        commit_stamp = offset = None
 
3040
        if commit_time is not None:
 
3041
            try:
 
3042
                commit_stamp, offset = timestamp.parse_patch_date(commit_time)
 
3043
            except ValueError, e:
 
3044
                raise errors.BzrCommandError(
 
3045
                    "Could not parse --commit-time: " + str(e))
 
3046
 
2995
3047
        # TODO: Need a blackbox test for invoking the external editor; may be
2996
3048
        # slightly problematic to run this cross-platform.
2997
3049
 
3017
3069
        if local and not tree.branch.get_bound_location():
3018
3070
            raise errors.LocalRequiresBoundBranch()
3019
3071
 
 
3072
        if message is not None:
 
3073
            try:
 
3074
                file_exists = osutils.lexists(message)
 
3075
            except UnicodeError:
 
3076
                # The commit message contains unicode characters that can't be
 
3077
                # represented in the filesystem encoding, so that can't be a
 
3078
                # file.
 
3079
                file_exists = False
 
3080
            if file_exists:
 
3081
                warning_msg = (
 
3082
                    'The commit message is a file name: "%(f)s".\n'
 
3083
                    '(use --file "%(f)s" to take commit message from that file)'
 
3084
                    % { 'f': message })
 
3085
                ui.ui_factory.show_warning(warning_msg)
 
3086
 
3020
3087
        def get_message(commit_obj):
3021
3088
            """Callback to get commit message"""
3022
3089
            my_message = message
 
3090
            if my_message is not None and '\r' in my_message:
 
3091
                my_message = my_message.replace('\r\n', '\n')
 
3092
                my_message = my_message.replace('\r', '\n')
3023
3093
            if my_message is None and not file:
3024
3094
                t = make_commit_message_template_encoded(tree,
3025
3095
                        selected_list, diff=show_diff,
3049
3119
                        specific_files=selected_list,
3050
3120
                        allow_pointless=unchanged, strict=strict, local=local,
3051
3121
                        reporter=None, verbose=verbose, revprops=properties,
3052
 
                        authors=author,
 
3122
                        authors=author, timestamp=commit_stamp,
 
3123
                        timezone=offset,
3053
3124
                        exclude=safe_relpath_files(tree, exclude))
3054
3125
        except PointlessCommit:
3055
3126
            # FIXME: This should really happen before the file is read in;
3605
3676
 
3606
3677
            bzr merge -r 81..82 ../bzr.dev
3607
3678
 
3608
 
        To apply a merge directive contained in /tmp/merge:
 
3679
        To apply a merge directive contained in /tmp/merge::
3609
3680
 
3610
3681
            bzr merge /tmp/merge
3611
3682
    """
3775
3846
        shelver = shelf_ui.Shelver(merger.this_tree, result_tree, destroy=True,
3776
3847
                                   reporter=shelf_ui.ApplyReporter(),
3777
3848
                                   diff_writer=writer(sys.stdout))
3778
 
        shelver.run()
 
3849
        try:
 
3850
            shelver.run()
 
3851
        finally:
 
3852
            shelver.finalize()
3779
3853
 
3780
3854
    def sanity_check_merger(self, merger):
3781
3855
        if (merger.show_base and
4025
4099
    name.  If you name a directory, all the contents of that directory will be
4026
4100
    reverted.
4027
4101
 
4028
 
    Any files that have been newly added since that revision will be deleted,
4029
 
    with a backup kept if appropriate.  Directories containing unknown files
4030
 
    will not be deleted.
 
4102
    If you have newly added files since the target revision, they will be
 
4103
    removed.  If the files to be removed have been changed, backups will be
 
4104
    created as above.  Directories containing unknown files will not be
 
4105
    deleted.
4031
4106
 
4032
4107
    The working tree contains a list of pending merged revisions, which will
4033
4108
    be included as parents in the next commit.  Normally, revert clears that
4036
4111
    revert ." in the tree root to revert all files but keep the merge record,
4037
4112
    and "bzr revert --forget-merges" to clear the pending merge list without
4038
4113
    reverting any files.
 
4114
 
 
4115
    Using "bzr revert --forget-merges", it is possible to apply the changes
 
4116
    from an arbitrary merge as a single revision.  To do this, perform the
 
4117
    merge as desired.  Then doing revert with the "--forget-merges" option will
 
4118
    keep the content of the tree as it was, but it will clear the list of
 
4119
    pending merges.  The next commit will then contain all of the changes that
 
4120
    would have been in the merge, but without any mention of the other parent
 
4121
    revisions.  Because this technique forgets where these changes originated,
 
4122
    it may cause additional conflicts on later merges involving the source and
 
4123
    target branches.
4039
4124
    """
4040
4125
 
4041
4126
    _see_also = ['cat', 'export']
4122
4207
    To filter on a range of revisions, you can use the command -r begin..end
4123
4208
    -r revision requests a specific revision, -r ..end or -r begin.. are
4124
4209
    also valid.
 
4210
            
 
4211
    :Exit values:
 
4212
        1 - some missing revisions
 
4213
        0 - no missing revisions
4125
4214
 
4126
4215
    :Examples:
4127
4216
 
4511
4600
    before they will be applied to the local branch.
4512
4601
 
4513
4602
    Bound branches use the nickname of its master branch unless it is set
4514
 
    locally, in which case binding will update the the local nickname to be
 
4603
    locally, in which case binding will update the local nickname to be
4515
4604
    that of the master.
4516
4605
    """
4517
4606
 
4717
4806
    takes_options = [
4718
4807
        Option('inet',
4719
4808
               help='Serve on stdin/out for use from inetd or sshd.'),
4720
 
        RegistryOption('protocol', 
4721
 
               help="Protocol to serve.", 
 
4809
        RegistryOption('protocol',
 
4810
               help="Protocol to serve.",
4722
4811
               lazy_registry=('bzrlib.transport', 'transport_server_registry'),
4723
4812
               value_switches=True),
4724
4813
        Option('port',
4733
4822
        Option('allow-writes',
4734
4823
               help='By default the server is a readonly server.  Supplying '
4735
4824
                    '--allow-writes enables write access to the contents of '
4736
 
                    'the served directory and below.'
 
4825
                    'the served directory and below.  Note that ``bzr serve`` '
 
4826
                    'does not perform authentication, so unless some form of '
 
4827
                    'external authentication is arranged supplying this '
 
4828
                    'option leads to global uncontrolled write access to your '
 
4829
                    'file system.'
4737
4830
                ),
4738
4831
        ]
4739
4832
 
5362
5455
    /path/to/newbranch.
5363
5456
 
5364
5457
    Bound branches use the nickname of its master branch unless it is set
5365
 
    locally, in which case switching will update the the local nickname to be
 
5458
    locally, in which case switching will update the local nickname to be
5366
5459
    that of the master.
5367
5460
    """
5368
5461
 
5662
5755
            try:
5663
5756
                shelver.run()
5664
5757
            finally:
5665
 
                shelver.work_tree.unlock()
 
5758
                shelver.finalize()
5666
5759
        except errors.UserAbort:
5667
5760
            return 0
5668
5761