~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/workingtree.py

  • Committer: John Arbash Meinel
  • Date: 2007-06-28 23:18:09 UTC
  • mfrom: (2562 +trunk)
  • mto: This revision was merged to the branch mainline in revision 2566.
  • Revision ID: john@arbash-meinel.com-20070628231809-pqbt7puoqj8bl07b
[merge] bzr.dev 2562

Show diffs side-by-side

added added

removed removed

Lines of Context:
813
813
                to_revision = osutils.safe_revision_id(to_revision)
814
814
            merger.other_rev_id = to_revision
815
815
            if merger.other_rev_id is None:
816
 
                raise error.NoCommits(branch)
 
816
                raise errors.NoCommits(branch)
817
817
            self.branch.fetch(branch, last_revision=merger.other_rev_id)
818
818
            merger.other_basis = merger.other_rev_id
819
819
            merger.other_tree = self.branch.repository.revision_tree(
932
932
            transport = self.branch.bzrdir.root_transport
933
933
            for name in segments:
934
934
                transport = transport.clone(name)
935
 
                try:
936
 
                    transport.mkdir('.')
937
 
                except errors.FileExists:
938
 
                    pass
 
935
                transport.ensure_base()
939
936
            return transport
940
937
            
941
938
        sub_path = self.id2path(file_id)
942
939
        branch_transport = mkdirs(sub_path)
943
940
        if format is None:
944
941
            format = bzrdir.format_registry.make_bzrdir('dirstate-with-subtree')
945
 
        try:
946
 
            branch_transport.mkdir('.')
947
 
        except errors.FileExists:
948
 
            pass
 
942
        branch_transport.ensure_base()
949
943
        branch_bzrdir = format.initialize_on_transport(branch_transport)
950
944
        try:
951
945
            repo = branch_bzrdir.find_repository()
1781
1775
        if isinstance(files, basestring):
1782
1776
            files = [files]
1783
1777
 
1784
 
        inv = self.inventory
 
1778
        inv_delta = []
1785
1779
 
1786
1780
        new_files=set()
1787
1781
        unknown_files_in_directory=set()
1789
1783
        def recurse_directory_to_add_files(directory):
1790
1784
            # recurse directory and add all files
1791
1785
            # so we can check if they have changed.
1792
 
            for contained_dir_info in self.walkdirs(directory):
1793
 
                for file_info in contained_dir_info[1]:
1794
 
                    if file_info[2] == 'file':
1795
 
                        relpath = self.relpath(file_info[0])
1796
 
                        if file_info[4]: #is it versioned?
 
1786
            for parent_info, file_infos in\
 
1787
                osutils.walkdirs(self.abspath(directory),
 
1788
                    directory):
 
1789
                for relpath, basename, kind, lstat, abspath in file_infos:
 
1790
                    if kind == 'file':
 
1791
                        if self.path2id(relpath): #is it versioned?
1797
1792
                            new_files.add(relpath)
1798
1793
                        else:
1799
1794
                            unknown_files_in_directory.add(
1800
 
                                (relpath, None, file_info[2]))
 
1795
                                (relpath, None, kind))
1801
1796
 
1802
1797
        for filename in files:
1803
1798
            # Get file name into canonical form.
1804
 
            filename = self.relpath(self.abspath(filename))
 
1799
            abspath = self.abspath(filename)
 
1800
            filename = self.relpath(abspath)
1805
1801
            if len(filename) > 0:
1806
1802
                new_files.add(filename)
1807
 
                if osutils.isdir(filename) and len(os.listdir(filename)) > 0:
 
1803
                if osutils.isdir(abspath):
1808
1804
                    recurse_directory_to_add_files(filename)
1809
1805
        files = [f for f in new_files]
1810
1806
 
1824
1820
 
1825
1821
        # do this before any modifications
1826
1822
        for f in files:
1827
 
            fid = inv.path2id(f)
 
1823
            fid = self.path2id(f)
1828
1824
            message=None
1829
1825
            if not fid:
1830
1826
                message="%s is not versioned." % (f,)
1835
1831
                        new_status = 'I'
1836
1832
                    else:
1837
1833
                        new_status = '?'
1838
 
                    textui.show_status(new_status, inv[fid].kind, f,
 
1834
                    textui.show_status(new_status, self.kind(fid), f,
1839
1835
                                       to_file=to_file)
1840
1836
                # unversion file
1841
 
                del inv[fid]
 
1837
                inv_delta.append((f, None, fid, None))
1842
1838
                message="removed %s" % (f,)
1843
1839
 
1844
1840
            if not keep_files:
1858
1854
            # print only one message (if any) per file.
1859
1855
            if message is not None:
1860
1856
                note(message)
1861
 
        self._write_inventory(inv)
 
1857
        self.apply_inventory_delta(inv_delta)
1862
1858
 
1863
1859
    @needs_tree_write_lock
1864
1860
    def revert(self, filenames, old_tree=None, backups=True, 
2089
2085
            #       inventory and calls tree._write_inventory(). Ultimately we
2090
2086
            #       should be able to remove this extra flush.
2091
2087
            self.flush()
2092
 
            from bzrlib.revision import common_ancestor
2093
 
            try:
2094
 
                base_rev_id = common_ancestor(self.branch.last_revision(),
2095
 
                                              old_tip,
2096
 
                                              self.branch.repository)
2097
 
            except errors.NoCommonAncestor:
2098
 
                base_rev_id = None
 
2088
            graph = self.branch.repository.get_graph()
 
2089
            base_rev_id = graph.find_unique_lca(self.branch.last_revision(),
 
2090
                                                old_tip)
2099
2091
            base_tree = self.branch.repository.revision_tree(base_rev_id)
2100
2092
            other_tree = self.branch.repository.revision_tree(old_tip)
2101
2093
            result += merge.merge_inner(