/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: Andrew Bennetts
  • Date: 2009-11-19 06:28:13 UTC
  • mfrom: (4811 +trunk)
  • mto: This revision was merged to the branch mainline in revision 4812.
  • Revision ID: andrew.bennetts@canonical.com-20091119062813-t6sd6gwbot8nfyze
MergeĀ lp:bzr.

Show diffs side-by-side

added added

removed removed

Lines of Context:
656
656
        if base_tree:
657
657
            base_tree.lock_read()
658
658
        try:
659
 
            file_list = self._maybe_expand_globs(file_list)
660
659
            tree, file_list = tree_files_for_add(file_list)
661
660
            added, ignored = tree.smart_add(file_list, not
662
661
                no_recurse, action=action, save=not dry_run)
851
850
            # All entries reference existing inventory items, so fix them up
852
851
            # for cicp file-systems.
853
852
            rel_names = tree.get_canonical_inventory_paths(rel_names)
854
 
            for pair in tree.move(rel_names[:-1], rel_names[-1], after=after):
855
 
                self.outf.write("%s => %s\n" % pair)
 
853
            for src, dest in tree.move(rel_names[:-1], rel_names[-1], after=after):
 
854
                if not is_quiet():
 
855
                    self.outf.write("%s => %s\n" % (src, dest))
856
856
        else:
857
857
            if len(names_list) != 2:
858
858
                raise errors.BzrCommandError('to mv multiple files the'
902
902
            dest = osutils.pathjoin(dest_parent, dest_tail)
903
903
            mutter("attempting to move %s => %s", src, dest)
904
904
            tree.rename_one(src, dest, after=after)
905
 
            self.outf.write("%s => %s\n" % (src, dest))
 
905
            if not is_quiet():
 
906
                self.outf.write("%s => %s\n" % (src, dest))
906
907
 
907
908
 
908
909
class cmd_pull(Command):
2277
2278
 
2278
2279
        file_ids = []
2279
2280
        filter_by_dir = False
2280
 
        if file_list:
2281
 
            # find the file ids to log and check for directory filtering
2282
 
            b, file_info_list, rev1, rev2 = _get_info_for_log_files(revision,
2283
 
                file_list)
2284
 
            for relpath, file_id, kind in file_info_list:
2285
 
                if file_id is None:
2286
 
                    raise errors.BzrCommandError(
2287
 
                        "Path unknown at end or start of revision range: %s" %
2288
 
                        relpath)
2289
 
                # If the relpath is the top of the tree, we log everything
2290
 
                if relpath == '':
2291
 
                    file_ids = []
2292
 
                    break
 
2281
        b = None
 
2282
        try:
 
2283
            if file_list:
 
2284
                # find the file ids to log and check for directory filtering
 
2285
                b, file_info_list, rev1, rev2 = _get_info_for_log_files(
 
2286
                    revision, file_list)
 
2287
                for relpath, file_id, kind in file_info_list:
 
2288
                    if file_id is None:
 
2289
                        raise errors.BzrCommandError(
 
2290
                            "Path unknown at end or start of revision range: %s" %
 
2291
                            relpath)
 
2292
                    # If the relpath is the top of the tree, we log everything
 
2293
                    if relpath == '':
 
2294
                        file_ids = []
 
2295
                        break
 
2296
                    else:
 
2297
                        file_ids.append(file_id)
 
2298
                    filter_by_dir = filter_by_dir or (
 
2299
                        kind in ['directory', 'tree-reference'])
 
2300
            else:
 
2301
                # log everything
 
2302
                # FIXME ? log the current subdir only RBC 20060203
 
2303
                if revision is not None \
 
2304
                        and len(revision) > 0 and revision[0].get_branch():
 
2305
                    location = revision[0].get_branch()
2293
2306
                else:
2294
 
                    file_ids.append(file_id)
2295
 
                filter_by_dir = filter_by_dir or (
2296
 
                    kind in ['directory', 'tree-reference'])
2297
 
        else:
2298
 
            # log everything
2299
 
            # FIXME ? log the current subdir only RBC 20060203
2300
 
            if revision is not None \
2301
 
                    and len(revision) > 0 and revision[0].get_branch():
2302
 
                location = revision[0].get_branch()
2303
 
            else:
2304
 
                location = '.'
2305
 
            dir, relpath = bzrdir.BzrDir.open_containing(location)
2306
 
            b = dir.open_branch()
2307
 
            rev1, rev2 = _get_revision_range(revision, b, self.name())
2308
 
 
2309
 
        # Decide on the type of delta & diff filtering to use
2310
 
        # TODO: add an --all-files option to make this configurable & consistent
2311
 
        if not verbose:
2312
 
            delta_type = None
2313
 
        else:
2314
 
            delta_type = 'full'
2315
 
        if not show_diff:
2316
 
            diff_type = None
2317
 
        elif file_ids:
2318
 
            diff_type = 'partial'
2319
 
        else:
2320
 
            diff_type = 'full'
2321
 
 
2322
 
        b.lock_read()
2323
 
        try:
 
2307
                    location = '.'
 
2308
                dir, relpath = bzrdir.BzrDir.open_containing(location)
 
2309
                b = dir.open_branch()
 
2310
                b.lock_read()
 
2311
                rev1, rev2 = _get_revision_range(revision, b, self.name())
 
2312
 
 
2313
            # Decide on the type of delta & diff filtering to use
 
2314
            # TODO: add an --all-files option to make this configurable & consistent
 
2315
            if not verbose:
 
2316
                delta_type = None
 
2317
            else:
 
2318
                delta_type = 'full'
 
2319
            if not show_diff:
 
2320
                diff_type = None
 
2321
            elif file_ids:
 
2322
                diff_type = 'partial'
 
2323
            else:
 
2324
                diff_type = 'full'
 
2325
 
2324
2326
            # Build the log formatter
2325
2327
            if log_format is None:
2326
2328
                log_format = log.log_formatter_registry.get_default(b)
2356
2358
                diff_type=diff_type, _match_using_deltas=match_using_deltas)
2357
2359
            Logger(b, rqst).show(lf)
2358
2360
        finally:
2359
 
            b.unlock()
 
2361
            if b is not None:
 
2362
                b.unlock()
2360
2363
 
2361
2364
 
2362
2365
def _get_revision_range(revisionspec_list, branch, command_name):
2426
2429
    @display_command
2427
2430
    def run(self, filename):
2428
2431
        tree, relpath = WorkingTree.open_containing(filename)
 
2432
        file_id = tree.path2id(relpath)
2429
2433
        b = tree.branch
2430
 
        file_id = tree.path2id(relpath)
2431
 
        for revno, revision_id, what in log.find_touching_revisions(b, file_id):
2432
 
            self.outf.write("%6d %s\n" % (revno, what))
 
2434
        b.lock_read()
 
2435
        try:
 
2436
            touching_revs = log.find_touching_revisions(b, file_id)
 
2437
            for revno, revision_id, what in touching_revs:
 
2438
                self.outf.write("%6d %s\n" % (revno, what))
 
2439
        finally:
 
2440
            b.unlock()
2433
2441
 
2434
2442
 
2435
2443
class cmd_ls(Command):
3032
3040
        def get_message(commit_obj):
3033
3041
            """Callback to get commit message"""
3034
3042
            my_message = message
 
3043
            if my_message is not None and '\r' in my_message:
 
3044
                my_message = my_message.replace('\r\n', '\n')
 
3045
                my_message = my_message.replace('\r', '\n')
3035
3046
            if my_message is None and not file:
3036
3047
                t = make_commit_message_template_encoded(tree,
3037
3048
                        selected_list, diff=show_diff,
4524
4535
    before they will be applied to the local branch.
4525
4536
 
4526
4537
    Bound branches use the nickname of its master branch unless it is set
4527
 
    locally, in which case binding will update the the local nickname to be
 
4538
    locally, in which case binding will update the local nickname to be
4528
4539
    that of the master.
4529
4540
    """
4530
4541
 
5375
5386
    /path/to/newbranch.
5376
5387
 
5377
5388
    Bound branches use the nickname of its master branch unless it is set
5378
 
    locally, in which case switching will update the the local nickname to be
 
5389
    locally, in which case switching will update the local nickname to be
5379
5390
    that of the master.
5380
5391
    """
5381
5392
 
5675
5686
            try:
5676
5687
                shelver.run()
5677
5688
            finally:
5678
 
                shelver.work_tree.unlock()
 
5689
                shelver.finalize()
5679
5690
        except errors.UserAbort:
5680
5691
            return 0
5681
5692