~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/builtins.py

MergeĀ lp:bzr.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005-2011 Canonical Ltd
 
1
# Copyright (C) 2005-2012 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
955
955
            tree = work_tree
956
956
            extra_trees = []
957
957
 
 
958
        self.add_cleanup(tree.lock_read().unlock)
958
959
        if file_list is not None:
959
960
            file_ids = tree.paths2ids(file_list, trees=extra_trees,
960
961
                                      require_versioned=True)
961
962
            # find_ids_across_trees may include some paths that don't
962
963
            # exist in 'tree'.
963
 
            entries = sorted(
964
 
                (tree.id2path(file_id), tree.inventory[file_id])
965
 
                for file_id in file_ids if tree.has_id(file_id))
 
964
            entries = tree.iter_entries_by_dir(specific_file_ids=file_ids)
966
965
        else:
967
 
            entries = tree.inventory.entries()
 
966
            entries = tree.iter_entries_by_dir()
968
967
 
969
 
        self.cleanup_now()
970
 
        for path, entry in entries:
 
968
        for path, entry in sorted(entries):
971
969
            if kind and kind != entry.kind:
972
970
                continue
 
971
            if path == "":
 
972
                continue
973
973
            if show_ids:
974
974
                self.outf.write('%-50s %s\n' % (path, entry.file_id))
975
975
            else:
1047
1047
                and rel_names[0].lower() == rel_names[1].lower()):
1048
1048
                into_existing = False
1049
1049
            else:
1050
 
                inv = tree.inventory
1051
1050
                # 'fix' the case of a potential 'from'
1052
1051
                from_id = tree.path2id(
1053
1052
                            tree.get_canonical_inventory_path(rel_names[0]))
1054
1053
                if (not osutils.lexists(names_list[0]) and
1055
 
                    from_id and inv.get_file_kind(from_id) == "directory"):
 
1054
                    from_id and tree.stored_kind(from_id) == "directory"):
1056
1055
                    into_existing = False
1057
1056
        # move/rename
1058
1057
        if into_existing:
1224
1223
            # Remembers if asked explicitly or no previous location is set
1225
1224
            if (remember
1226
1225
                or (remember is None and branch_to.get_parent() is None)):
 
1226
                # FIXME: This shouldn't be done before the pull
 
1227
                # succeeds... -- vila 2012-01-02
1227
1228
                branch_to.set_parent(branch_from.base)
1228
1229
 
1229
1230
        if revision is not None:
1667
1668
    def run(self, dir=u'.'):
1668
1669
        tree = WorkingTree.open_containing(dir)[0]
1669
1670
        self.add_cleanup(tree.lock_read().unlock)
1670
 
        new_inv = tree.inventory
1671
1671
        old_tree = tree.basis_tree()
1672
1672
        self.add_cleanup(old_tree.lock_read().unlock)
1673
 
        old_inv = old_tree.inventory
1674
1673
        renames = []
1675
1674
        iterator = tree.iter_changes(old_tree, include_unchanged=True)
1676
1675
        for f, paths, c, v, p, n, k, e in iterator:
2390
2389
        self.add_cleanup(tree.lock_read().unlock)
2391
2390
        old = tree.basis_tree()
2392
2391
        self.add_cleanup(old.lock_read().unlock)
2393
 
        for path, ie in old.inventory.iter_entries():
 
2392
        for path, ie in old.iter_entries_by_dir():
2394
2393
            if not tree.has_id(ie.file_id):
2395
2394
                self.outf.write(path)
2396
2395
                if show_ids:
2434
2433
        self.add_cleanup(wt.lock_read().unlock)
2435
2434
        basis = wt.basis_tree()
2436
2435
        self.add_cleanup(basis.lock_read().unlock)
2437
 
        basis_inv = basis.inventory
2438
 
        inv = wt.inventory
2439
 
        for file_id in inv:
2440
 
            if basis_inv.has_id(file_id):
2441
 
                continue
2442
 
            if inv.is_root(file_id) and len(basis_inv) == 0:
2443
 
                continue
2444
 
            path = inv.id2path(file_id)
 
2436
        root_id = wt.get_root_id()
 
2437
        for file_id in wt.all_file_ids():
 
2438
            if basis.has_id(file_id):
 
2439
                continue
 
2440
            if root_id == file_id:
 
2441
                continue
 
2442
            path = wt.id2path(file_id)
2445
2443
            if not os.access(osutils.pathjoin(wt.basedir, path), os.F_OK):
2446
2444
                continue
2447
2445
            if null:
2809
2807
            self.add_cleanup(b.lock_read().unlock)
2810
2808
            rev1, rev2 = _get_revision_range(revision, b, self.name())
2811
2809
 
2812
 
        if b.get_config().validate_signatures_in_log():
 
2810
        if b.get_config_stack().get('validate_signatures_in_log'):
2813
2811
            signatures = True
2814
2812
 
2815
2813
        if signatures:
3535
3533
            tokens = fixed_bug.split(':')
3536
3534
            if len(tokens) == 1:
3537
3535
                if default_bugtracker is None:
3538
 
                    branch_config = branch.get_config()
3539
 
                    default_bugtracker = branch_config.get_user_option(
 
3536
                    branch_config = branch.get_config_stack()
 
3537
                    default_bugtracker = branch_config.get(
3540
3538
                        "bugtracker")
3541
3539
                if default_bugtracker is None:
3542
3540
                    raise errors.BzrCommandError(gettext(
3881
3879
            if directory is None:
3882
3880
                c = Branch.open_containing(u'.')[0].get_config_stack()
3883
3881
            else:
3884
 
                c = Branch.open(directory).get_config_stack()
 
3882
                b = Branch.open(directory)
 
3883
                self.add_cleanup(b.lock_write().unlock)
 
3884
                c = b.get_config_stack()
3885
3885
        else:
3886
3886
            c = _mod_config.GlobalStack()
3887
3887
        c.set('email', name)
4694
4694
                if tree.kind(file_id) != "directory":
4695
4695
                    continue
4696
4696
 
4697
 
                for name, ie in tree.inventory.iter_entries(file_id):
 
4697
                # FIXME: Support nested trees
 
4698
                for name, ie in tree.root_inventory.iter_entries(file_id):
4698
4699
                    interesting_ids.add(ie.file_id)
4699
4700
            new_conflicts = conflicts.select_conflicts(tree, file_list)[0]
4700
4701
        else:
5281
5282
            else:
5282
5283
                if location is None:
5283
5284
                    if b.get_bound_location() is not None:
5284
 
                        raise errors.BzrCommandError(gettext('Branch is already bound'))
 
5285
                        raise errors.BzrCommandError(
 
5286
                            gettext('Branch is already bound'))
5285
5287
                    else:
5286
 
                        raise errors.BzrCommandError(gettext('No location supplied '
5287
 
                            'and no previous location known'))
 
5288
                        raise errors.BzrCommandError(
 
5289
                            gettext('No location supplied'
 
5290
                                    ' and no previous location known'))
5288
5291
        b_other = Branch.open(location)
5289
5292
        try:
5290
5293
            b.bind(b_other)
5700
5703
        if public_branch is None:
5701
5704
            public_branch = stored_public_branch
5702
5705
        elif stored_public_branch is None:
 
5706
            # FIXME: Should be done only if we succeed ? -- vila 2012-01-03
5703
5707
            branch.set_public_branch(public_branch)
5704
5708
        if not include_bundle and public_branch is None:
5705
5709
            raise errors.BzrCommandError(gettext('No public branch specified or'