/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 breezy/builtins.py

  • Committer: Jelmer Vernooij
  • Date: 2018-03-24 17:48:04 UTC
  • mfrom: (6921 work)
  • mto: This revision was merged to the branch mainline in revision 6923.
  • Revision ID: jelmer@jelmer.uk-20180324174804-xf22o05byoj12x1q
Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
 
31
31
import breezy
32
32
from breezy import (
 
33
    branch as _mod_branch,
33
34
    bugtracker,
34
35
    bundle,
35
36
    cache_utf8,
52
53
    symbol_versioning,
53
54
    timestamp,
54
55
    transport,
 
56
    tree as _mod_tree,
55
57
    ui,
56
58
    urlutils,
57
59
    views,
60
62
from breezy.bzr import (
61
63
    btree_index,
62
64
    )
63
 
from breezy.branch import Branch, UnstackableBranchFormat
 
65
from breezy.branch import Branch
64
66
from breezy.conflicts import ConflictList
65
67
from breezy.transport import memory
66
68
from breezy.smtp_connection import SMTPConnection
875
877
 
876
878
    @classmethod
877
879
    def add_file_with_parents(cls, wt, relpath):
878
 
        if wt.path2id(relpath) is not None:
 
880
        if wt.is_versioned(relpath):
879
881
            return
880
882
        cls.add_file_with_parents(wt, osutils.dirname(relpath))
881
883
        wt.add([relpath])
959
961
 
960
962
        self.add_cleanup(tree.lock_read().unlock)
961
963
        if file_list is not None:
962
 
            file_ids = tree.paths2ids(file_list, trees=extra_trees,
963
 
                                      require_versioned=True)
 
964
            paths = tree.find_related_paths_across_trees(
 
965
                    file_list, extra_trees, require_versioned=True)
964
966
            # find_ids_across_trees may include some paths that don't
965
967
            # exist in 'tree'.
966
 
            entries = tree.iter_entries_by_dir(specific_file_ids=file_ids)
 
968
            entries = tree.iter_entries_by_dir(specific_files=paths)
967
969
        else:
968
970
            entries = tree.iter_entries_by_dir()
969
971
 
1111
1113
        work_tree, file_list = WorkingTree.open_containing_paths(
1112
1114
            names_list, default_directory='.')
1113
1115
        self.add_cleanup(work_tree.lock_tree_write().unlock)
1114
 
        rename_map.RenameMap.guess_renames(work_tree, dry_run)
 
1116
        rename_map.RenameMap.guess_renames(
 
1117
                work_tree.basis_tree(), work_tree, dry_run)
1115
1118
 
1116
1119
    def _run(self, tree, names_list, rel_names, after):
1117
1120
        into_existing = osutils.isdir(names_list[-1])
1127
1130
            else:
1128
1131
                # 'fix' the case of a potential 'from'
1129
1132
                from_path = tree.get_canonical_inventory_path(rel_names[0])
1130
 
                from_id = tree.path2id(from_path)
1131
1133
                if (not osutils.lexists(names_list[0]) and
1132
 
                    from_id and
1133
 
                    tree.stored_kind(from_path, from_id) == "directory"):
 
1134
                    tree.is_versioned(from_path) and
 
1135
                    tree.stored_kind(from_path) == "directory"):
1134
1136
                    into_existing = False
1135
1137
        # move/rename
1136
1138
        if into_existing:
1601
1603
        try:
1602
1604
            note(gettext('Created new stacked branch referring to %s.') %
1603
1605
                branch.get_stacked_on_url())
1604
 
        except (errors.NotStacked, UnstackableBranchFormat,
 
1606
        except (errors.NotStacked, _mod_branch.UnstackableBranchFormat,
1605
1607
            errors.UnstackableRepositoryFormat) as e:
1606
1608
            note(ngettext('Branched %d revision.', 'Branched %d revisions.', branch.revno()) % branch.revno())
1607
1609
        if bind:
1651
1653
                if name == "":
1652
1654
                    continue
1653
1655
                active = (active_branch is not None and
1654
 
                          active_branch.base == branch.base)
 
1656
                          active_branch.user_url == branch.user_url)
1655
1657
                names[name] = active
1656
1658
            # Only mention the current branch explicitly if it's not
1657
1659
            # one of the colocated branches
3023
3025
    @display_command
3024
3026
    def run(self, filename):
3025
3027
        tree, relpath = WorkingTree.open_containing(filename)
3026
 
        file_id = tree.path2id(relpath)
3027
 
        b = tree.branch
3028
 
        self.add_cleanup(b.lock_read().unlock)
3029
 
        touching_revs = log.find_touching_revisions(b, file_id)
3030
 
        for revno, revision_id, what in touching_revs:
3031
 
            self.outf.write("%6d %s\n" % (revno, what))
 
3028
        with tree.lock_read():
 
3029
            touching_revs = log.find_touching_revisions(
 
3030
                    tree.branch.repository, tree.branch.last_revision(), tree, relpath)
 
3031
            for revno, revision_id, what in reversed(list(touching_revs)):
 
3032
                self.outf.write("%6d %s\n" % (revno, what))
3032
3033
 
3033
3034
 
3034
3035
class cmd_ls(Command):
3476
3477
                raise errors.BzrCommandError(gettext(
3477
3478
                    "{0!r} is not present in revision {1}").format(
3478
3479
                        filename, rev_tree.get_revision_id()))
 
3480
        relpath = rev_tree.id2path(actual_file_id)
3479
3481
        if filtered:
3480
3482
            from .filter_tree import ContentFilterTree
3481
3483
            filter_tree = ContentFilterTree(rev_tree,
4197
4199
        # error reporting for past duplicate imports won't have useful
4198
4200
        # backtraces.
4199
4201
        if sys.version_info[0] < 3:
4200
 
            # TODO(jelmer): Disable proxying on Python 3, until it's fixed.
4201
 
            # pad.lv/1696545
 
4202
            # TODO(pad.lv/1696545): Allow proxying on Python 3, since
 
4203
            # disallowing it currently leads to failures in many places.
4202
4204
            lazy_import.disallow_proxying()
4203
4205
 
4204
4206
        from . import tests
4380
4382
    committed to record the result of the merge.
4381
4383
 
4382
4384
    merge refuses to run if there are any uncommitted changes, unless
4383
 
    --force is given.  If --force is given, then the changes from the source 
 
4385
    --force is given.  If --force is given, then the changes from the source
4384
4386
    will be merged with the current working tree, including any uncommitted
4385
4387
    changes in the tree.  The --force option can also be used to create a
4386
4388
    merge revision which has more than two parents.
4609
4611
            raise errors.BzrCommandError(gettext("Cannot do conflict reduction and"
4610
4612
                                         " show base."))
4611
4613
 
 
4614
        if (merger.merge_type.requires_file_merge_plan and
 
4615
            (not getattr(merger.this_tree, 'plan_file_merge', None) or
 
4616
             not getattr(merger.other_tree, 'plan_file_merge', None) or
 
4617
             (merger.base_tree is not None and
 
4618
                 not getattr(merger.base_tree, 'plan_file_merge', None)))):
 
4619
            raise errors.BzrCommandError(
 
4620
                 gettext('Plan file merge unsupported: '
 
4621
                         'Merge type incompatible with tree formats.'))
 
4622
 
4612
4623
    def _get_merger_from_branch(self, tree, location, revision, remember,
4613
4624
                                possible_transports, pb):
4614
4625
        """Produce a merger from a location, assuming it refers to a branch."""
4766
4777
                                         " merges.  Not cherrypicking or"
4767
4778
                                         " multi-merges."))
4768
4779
        repository = tree.branch.repository
4769
 
        interesting_ids = None
 
4780
        interesting_files = None
4770
4781
        new_conflicts = []
4771
4782
        conflicts = tree.conflicts()
4772
4783
        if file_list is not None:
4773
 
            interesting_ids = set()
 
4784
            interesting_files = set()
4774
4785
            for filename in file_list:
4775
 
                file_id = tree.path2id(filename)
4776
 
                if file_id is None:
 
4786
                if not tree.is_versioned(filename):
4777
4787
                    raise errors.NotVersionedError(filename)
4778
 
                interesting_ids.add(file_id)
4779
 
                if tree.kind(filename, file_id) != "directory":
 
4788
                interesting_files.add(filename)
 
4789
                if tree.kind(filename) != "directory":
4780
4790
                    continue
4781
4791
 
4782
 
                # FIXME: Support nested trees
4783
 
                for name, ie in tree.root_inventory.iter_entries(file_id):
4784
 
                    interesting_ids.add(ie.file_id)
 
4792
                for path, ie in tree.iter_entries_by_dir(specific_files=[filename]):
 
4793
                    interesting_files.add(path)
4785
4794
            new_conflicts = conflicts.select_conflicts(tree, file_list)[0]
4786
4795
        else:
4787
4796
            # Remerge only supports resolving contents conflicts
4788
4797
            allowed_conflicts = ('text conflict', 'contents conflict')
4789
4798
            restore_files = [c.path for c in conflicts
4790
4799
                             if c.typestring in allowed_conflicts]
4791
 
        _mod_merge.transform_tree(tree, tree.basis_tree(), interesting_ids)
 
4800
        _mod_merge.transform_tree(tree, tree.basis_tree(), interesting_files)
4792
4801
        tree.set_conflicts(ConflictList(new_conflicts))
4793
4802
        if file_list is not None:
4794
4803
            restore_files = file_list
4805
4814
        tree.set_parent_ids(parents[:1])
4806
4815
        try:
4807
4816
            merger = _mod_merge.Merger.from_revision_ids(tree, parents[1])
4808
 
            merger.interesting_ids = interesting_ids
 
4817
            merger.interesting_files = interesting_files
4809
4818
            merger.merge_type = merge_type
4810
4819
            merger.show_base = show_base
4811
4820
            merger.reprocess = reprocess
5688
5697
        if sub_id is None:
5689
5698
            raise errors.NotVersionedError(subdir)
5690
5699
        try:
5691
 
            containing_tree.extract(sub_id)
 
5700
            containing_tree.extract(subdir, sub_id)
5692
5701
        except errors.RootNotRich:
5693
5702
            raise errors.RichRootUpgradeRequired(containing_tree.branch.base)
5694
5703
 
6765
6774
    __doc__ = """Export command helps and error messages in po format."""
6766
6775
 
6767
6776
    hidden = True
6768
 
    takes_options = [Option('plugin', 
 
6777
    takes_options = [Option('plugin',
6769
6778
                            help='Export help text from named command '\
6770
6779
                                 '(defaults to all built in commands).',
6771
6780
                            type=text_type),