/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/workingtree.py

  • Committer: John Arbash Meinel
  • Date: 2007-12-20 12:34:06 UTC
  • mfrom: (3133 +trunk)
  • mto: This revision was merged to the branch mainline in revision 3134.
  • Revision ID: john@arbash-meinel.com-20071220123406-4ijq232s46ecsutz
[merge] bzr.dev 3133

Show diffs side-by-side

added added

removed removed

Lines of Context:
270
270
            # the Format factory and creation methods that are
271
271
            # permitted to do this.
272
272
            self._set_inventory(_inventory, dirty=False)
 
273
        self._detect_case_handling()
 
274
 
 
275
    def _detect_case_handling(self):
 
276
        wt_trans = self.bzrdir.get_workingtree_transport(None)
 
277
        try:
 
278
            wt_trans.stat("FoRMaT")
 
279
        except errors.NoSuchFile:
 
280
            self.case_sensitive = True
 
281
        else:
 
282
            self.case_sensitive = False
273
283
 
274
284
        self._setup_directory_is_tree_reference()
275
285
 
1026
1036
        sub_path = self.id2path(file_id)
1027
1037
        branch_transport = mkdirs(sub_path)
1028
1038
        if format is None:
1029
 
            format = bzrdir.format_registry.make_bzrdir('dirstate-with-subtree')
 
1039
            format = self.bzrdir.cloning_metadir()
1030
1040
        branch_transport.ensure_base()
1031
1041
        branch_bzrdir = format.initialize_on_transport(branch_transport)
1032
1042
        try:
1033
1043
            repo = branch_bzrdir.find_repository()
1034
1044
        except errors.NoRepositoryPresent:
1035
1045
            repo = branch_bzrdir.create_repository()
1036
 
            assert repo.supports_rich_root()
1037
 
        else:
1038
 
            if not repo.supports_rich_root():
1039
 
                raise errors.RootNotRich()
 
1046
        if not repo.supports_rich_root():
 
1047
            raise errors.RootNotRich()
1040
1048
        new_branch = branch_bzrdir.create_branch()
1041
1049
        new_branch.pull(self.branch)
1042
1050
        for parent_id in self.get_parent_ids():
1331
1339
                only_change_inv = True
1332
1340
            elif self.has_filename(from_rel) and not self.has_filename(to_rel):
1333
1341
                only_change_inv = False
 
1342
            elif (sys.platform == 'win32'
 
1343
                and from_rel.lower() == to_rel.lower()
 
1344
                and self.has_filename(from_rel)):
 
1345
                only_change_inv = False
1334
1346
            else:
1335
1347
                # something is wrong, so lets determine what exactly
1336
1348
                if not self.has_filename(from_rel) and \
1339
1351
                        errors.PathsDoNotExist(paths=(str(from_rel),
1340
1352
                        str(to_rel))))
1341
1353
                else:
1342
 
                    raise errors.RenameFailedFilesExist(from_rel, to_rel,
1343
 
                        extra="(Use --after to update the Bazaar id)")
 
1354
                    raise errors.RenameFailedFilesExist(from_rel, to_rel)
1344
1355
            rename_entry.only_change_inv = only_change_inv
1345
1356
        return rename_entries
1346
1357
 
1554
1565
                                change_reporter=change_reporter)
1555
1566
                    if (basis_tree.inventory.root is None and
1556
1567
                        new_basis_tree.inventory.root is not None):
1557
 
                        self.set_root_id(new_basis_tree.inventory.root.file_id)
 
1568
                        self.set_root_id(new_basis_tree.get_root_id())
1558
1569
                finally:
1559
1570
                    pb.finished()
1560
1571
                    basis_tree.unlock()
1903
1914
                     kind, executable) in self._iter_changes(self.basis_tree(),
1904
1915
                         include_unchanged=True, require_versioned=False,
1905
1916
                         want_unversioned=True, specific_files=files):
1906
 
                    # Check if it's an unknown (but not ignored) OR
1907
 
                    # changed (but not deleted) :
1908
 
                    if not self.is_ignored(path[1]) and (
1909
 
                        versioned == (False, False) or
1910
 
                        content_change and kind[1] != None):
 
1917
                    if versioned == (False, False):
 
1918
                        # The record is unknown ...
 
1919
                        if not self.is_ignored(path[1]):
 
1920
                            # ... but not ignored
 
1921
                            has_changed_files = True
 
1922
                            break
 
1923
                    elif content_change and (kind[1] != None):
 
1924
                        # Versioned and changed, but not deleted
1911
1925
                        has_changed_files = True
1912
1926
                        break
1913
1927
 
1992
2006
                self.set_parent_trees(parent_trees)
1993
2007
                resolve(self)
1994
2008
            else:
1995
 
                resolve(self, filenames, ignore_misses=True)
 
2009
                resolve(self, filenames, ignore_misses=True, recursive=True)
1996
2010
        finally:
1997
2011
            if basis_tree is not None:
1998
2012
                basis_tree.unlock()
2167
2181
            try:
2168
2182
                to_tree = self.branch.basis_tree()
2169
2183
                if basis.inventory.root is None:
2170
 
                    self.set_root_id(to_tree.inventory.root.file_id)
 
2184
                    self.set_root_id(to_tree.get_root_id())
2171
2185
                    self.flush()
2172
2186
                result += merge.merge_inner(
2173
2187
                                      self.branch,
2315
2329
            current_inv = None
2316
2330
            inv_finished = True
2317
2331
        while not inv_finished or not disk_finished:
 
2332
            if current_disk:
 
2333
                ((cur_disk_dir_relpath, cur_disk_dir_path_from_top),
 
2334
                    cur_disk_dir_content) = current_disk
 
2335
            else:
 
2336
                ((cur_disk_dir_relpath, cur_disk_dir_path_from_top),
 
2337
                    cur_disk_dir_content) = ((None, None), None)
2318
2338
            if not disk_finished:
2319
2339
                # strip out .bzr dirs
2320
 
                if current_disk[0][1][top_strip_len:] == '':
2321
 
                    # osutils.walkdirs can be made nicer - 
 
2340
                if (cur_disk_dir_path_from_top[top_strip_len:] == '' and
 
2341
                    len(cur_disk_dir_content) > 0):
 
2342
                    # osutils.walkdirs can be made nicer -
2322
2343
                    # yield the path-from-prefix rather than the pathjoined
2323
2344
                    # value.
2324
 
                    bzrdir_loc = bisect_left(current_disk[1], ('.bzr', '.bzr'))
2325
 
                    if current_disk[1][bzrdir_loc][0] == '.bzr':
 
2345
                    bzrdir_loc = bisect_left(cur_disk_dir_content,
 
2346
                        ('.bzr', '.bzr'))
 
2347
                    if cur_disk_dir_content[bzrdir_loc][0] == '.bzr':
2326
2348
                        # we dont yield the contents of, or, .bzr itself.
2327
 
                        del current_disk[1][bzrdir_loc]
 
2349
                        del cur_disk_dir_content[bzrdir_loc]
2328
2350
            if inv_finished:
2329
2351
                # everything is unknown
2330
2352
                direction = 1
2332
2354
                # everything is missing
2333
2355
                direction = -1
2334
2356
            else:
2335
 
                direction = cmp(current_inv[0][0], current_disk[0][0])
 
2357
                direction = cmp(current_inv[0][0], cur_disk_dir_relpath)
2336
2358
            if direction > 0:
2337
2359
                # disk is before inventory - unknown
2338
2360
                dirblock = [(relpath, basename, kind, stat, None, None) for
2339
 
                    relpath, basename, kind, stat, top_path in current_disk[1]]
2340
 
                yield (current_disk[0][0], None), dirblock
 
2361
                    relpath, basename, kind, stat, top_path in
 
2362
                    cur_disk_dir_content]
 
2363
                yield (cur_disk_dir_relpath, None), dirblock
2341
2364
                try:
2342
2365
                    current_disk = disk_iterator.next()
2343
2366
                except StopIteration:
2345
2368
            elif direction < 0:
2346
2369
                # inventory is before disk - missing.
2347
2370
                dirblock = [(relpath, basename, 'unknown', None, fileid, kind)
2348
 
                    for relpath, basename, dkind, stat, fileid, kind in 
 
2371
                    for relpath, basename, dkind, stat, fileid, kind in
2349
2372
                    current_inv[1]]
2350
2373
                yield (current_inv[0][0], current_inv[0][1]), dirblock
2351
2374
                try:
2357
2380
                # merge the inventory and disk data together
2358
2381
                dirblock = []
2359
2382
                for relpath, subiterator in itertools.groupby(sorted(
2360
 
                    current_inv[1] + current_disk[1], key=operator.itemgetter(0)), operator.itemgetter(1)):
 
2383
                    current_inv[1] + cur_disk_dir_content,
 
2384
                    key=operator.itemgetter(0)), operator.itemgetter(1)):
2361
2385
                    path_elements = list(subiterator)
2362
2386
                    if len(path_elements) == 2:
2363
2387
                        inv_row, disk_row = path_elements
2722
2746
        control_files.put_bytes('pending-merges', '')
2723
2747
        
2724
2748
 
2725
 
    def initialize(self, a_bzrdir, revision_id=None):
 
2749
    def initialize(self, a_bzrdir, revision_id=None, from_branch=None):
2726
2750
        """See WorkingTreeFormat.initialize()."""
2727
2751
        if not isinstance(a_bzrdir.transport, LocalTransport):
2728
2752
            raise errors.NotLocalUrl(a_bzrdir.transport.base)
2729
 
        branch = a_bzrdir.open_branch()
 
2753
        if from_branch is not None:
 
2754
            branch = from_branch
 
2755
        else:
 
2756
            branch = a_bzrdir.open_branch()
2730
2757
        if revision_id is None:
2731
2758
            revision_id = _mod_revision.ensure_null(branch.last_revision())
2732
2759
        branch.lock_write()
2743
2770
                         _bzrdir=a_bzrdir)
2744
2771
        basis_tree = branch.repository.revision_tree(revision_id)
2745
2772
        if basis_tree.inventory.root is not None:
2746
 
            wt.set_root_id(basis_tree.inventory.root.file_id)
 
2773
            wt.set_root_id(basis_tree.get_root_id())
2747
2774
        # set the parent list and cache the basis tree.
2748
2775
        if _mod_revision.is_null(revision_id):
2749
2776
            parent_trees = []
2811
2838
        return LockableFiles(transport, self._lock_file_name, 
2812
2839
                             self._lock_class)
2813
2840
 
2814
 
    def initialize(self, a_bzrdir, revision_id=None):
 
2841
    def initialize(self, a_bzrdir, revision_id=None, from_branch=None):
2815
2842
        """See WorkingTreeFormat.initialize().
2816
2843
        
2817
2844
        revision_id allows creating a working tree at a different
2824
2851
        control_files.create_lock()
2825
2852
        control_files.lock_write()
2826
2853
        control_files.put_utf8('format', self.get_format_string())
2827
 
        branch = a_bzrdir.open_branch()
 
2854
        if from_branch is not None:
 
2855
            branch = from_branch
 
2856
        else:
 
2857
            branch = a_bzrdir.open_branch()
2828
2858
        if revision_id is None:
2829
2859
            revision_id = _mod_revision.ensure_null(branch.last_revision())
2830
2860
        # WorkingTree3 can handle an inventory which has a unique root id.
2845
2875
            basis_tree = branch.repository.revision_tree(revision_id)
2846
2876
            # only set an explicit root id if there is one to set.
2847
2877
            if basis_tree.inventory.root is not None:
2848
 
                wt.set_root_id(basis_tree.inventory.root.file_id)
 
2878
                wt.set_root_id(basis_tree.get_root_id())
2849
2879
            if revision_id == NULL_REVISION:
2850
2880
                wt.set_parent_trees([])
2851
2881
            else: