/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: Lukáš Lalinský
  • Date: 2007-12-17 17:28:25 UTC
  • mfrom: (3120 +trunk)
  • mto: This revision was merged to the branch mainline in revision 3123.
  • Revision ID: lalinsky@gmail.com-20071217172825-tr3pqm1mhvs3gwnn
Merge bzr.dev.

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
    branch = property(
275
285
        fget=lambda self: self._branch,
1318
1328
                only_change_inv = True
1319
1329
            elif self.has_filename(from_rel) and not self.has_filename(to_rel):
1320
1330
                only_change_inv = False
 
1331
            elif (sys.platform == 'win32'
 
1332
                and from_rel.lower() == to_rel.lower()
 
1333
                and self.has_filename(from_rel)):
 
1334
                only_change_inv = False
1321
1335
            else:
1322
1336
                # something is wrong, so lets determine what exactly
1323
1337
                if not self.has_filename(from_rel) and \
1326
1340
                        errors.PathsDoNotExist(paths=(str(from_rel),
1327
1341
                        str(to_rel))))
1328
1342
                else:
1329
 
                    raise errors.RenameFailedFilesExist(from_rel, to_rel,
1330
 
                        extra="(Use --after to update the Bazaar id)")
 
1343
                    raise errors.RenameFailedFilesExist(from_rel, to_rel)
1331
1344
            rename_entry.only_change_inv = only_change_inv
1332
1345
        return rename_entries
1333
1346
 
1541
1554
                                change_reporter=change_reporter)
1542
1555
                    if (basis_tree.inventory.root is None and
1543
1556
                        new_basis_tree.inventory.root is not None):
1544
 
                        self.set_root_id(new_basis_tree.inventory.root.file_id)
 
1557
                        self.set_root_id(new_basis_tree.get_root_id())
1545
1558
                finally:
1546
1559
                    pb.finished()
1547
1560
                    basis_tree.unlock()
1890
1903
                     kind, executable) in self._iter_changes(self.basis_tree(),
1891
1904
                         include_unchanged=True, require_versioned=False,
1892
1905
                         want_unversioned=True, specific_files=files):
1893
 
                    # Check if it's an unknown (but not ignored) OR
1894
 
                    # changed (but not deleted) :
1895
 
                    if not self.is_ignored(path[1]) and (
1896
 
                        versioned == (False, False) or
1897
 
                        content_change and kind[1] != None):
 
1906
                    if versioned == (False, False):
 
1907
                        # The record is unknown ...
 
1908
                        if not self.is_ignored(path[1]):
 
1909
                            # ... but not ignored
 
1910
                            has_changed_files = True
 
1911
                            break
 
1912
                    elif content_change and (kind[1] != None):
 
1913
                        # Versioned and changed, but not deleted
1898
1914
                        has_changed_files = True
1899
1915
                        break
1900
1916
 
1979
1995
                self.set_parent_trees(parent_trees)
1980
1996
                resolve(self)
1981
1997
            else:
1982
 
                resolve(self, filenames, ignore_misses=True)
 
1998
                resolve(self, filenames, ignore_misses=True, recursive=True)
1983
1999
        finally:
1984
2000
            if basis_tree is not None:
1985
2001
                basis_tree.unlock()
2154
2170
            try:
2155
2171
                to_tree = self.branch.basis_tree()
2156
2172
                if basis.inventory.root is None:
2157
 
                    self.set_root_id(to_tree.inventory.root.file_id)
 
2173
                    self.set_root_id(to_tree.get_root_id())
2158
2174
                    self.flush()
2159
2175
                result += merge.merge_inner(
2160
2176
                                      self.branch,
2302
2318
            current_inv = None
2303
2319
            inv_finished = True
2304
2320
        while not inv_finished or not disk_finished:
 
2321
            if current_disk:
 
2322
                ((cur_disk_dir_relpath, cur_disk_dir_path_from_top),
 
2323
                    cur_disk_dir_content) = current_disk
 
2324
            else:
 
2325
                ((cur_disk_dir_relpath, cur_disk_dir_path_from_top),
 
2326
                    cur_disk_dir_content) = ((None, None), None)
2305
2327
            if not disk_finished:
2306
2328
                # strip out .bzr dirs
2307
 
                if current_disk[0][1][top_strip_len:] == '':
2308
 
                    # osutils.walkdirs can be made nicer - 
 
2329
                if (cur_disk_dir_path_from_top[top_strip_len:] == '' and
 
2330
                    len(cur_disk_dir_content) > 0):
 
2331
                    # osutils.walkdirs can be made nicer -
2309
2332
                    # yield the path-from-prefix rather than the pathjoined
2310
2333
                    # value.
2311
 
                    bzrdir_loc = bisect_left(current_disk[1], ('.bzr', '.bzr'))
2312
 
                    if current_disk[1][bzrdir_loc][0] == '.bzr':
 
2334
                    bzrdir_loc = bisect_left(cur_disk_dir_content,
 
2335
                        ('.bzr', '.bzr'))
 
2336
                    if cur_disk_dir_content[bzrdir_loc][0] == '.bzr':
2313
2337
                        # we dont yield the contents of, or, .bzr itself.
2314
 
                        del current_disk[1][bzrdir_loc]
 
2338
                        del cur_disk_dir_content[bzrdir_loc]
2315
2339
            if inv_finished:
2316
2340
                # everything is unknown
2317
2341
                direction = 1
2319
2343
                # everything is missing
2320
2344
                direction = -1
2321
2345
            else:
2322
 
                direction = cmp(current_inv[0][0], current_disk[0][0])
 
2346
                direction = cmp(current_inv[0][0], cur_disk_dir_relpath)
2323
2347
            if direction > 0:
2324
2348
                # disk is before inventory - unknown
2325
2349
                dirblock = [(relpath, basename, kind, stat, None, None) for
2326
 
                    relpath, basename, kind, stat, top_path in current_disk[1]]
2327
 
                yield (current_disk[0][0], None), dirblock
 
2350
                    relpath, basename, kind, stat, top_path in
 
2351
                    cur_disk_dir_content]
 
2352
                yield (cur_disk_dir_relpath, None), dirblock
2328
2353
                try:
2329
2354
                    current_disk = disk_iterator.next()
2330
2355
                except StopIteration:
2332
2357
            elif direction < 0:
2333
2358
                # inventory is before disk - missing.
2334
2359
                dirblock = [(relpath, basename, 'unknown', None, fileid, kind)
2335
 
                    for relpath, basename, dkind, stat, fileid, kind in 
 
2360
                    for relpath, basename, dkind, stat, fileid, kind in
2336
2361
                    current_inv[1]]
2337
2362
                yield (current_inv[0][0], current_inv[0][1]), dirblock
2338
2363
                try:
2344
2369
                # merge the inventory and disk data together
2345
2370
                dirblock = []
2346
2371
                for relpath, subiterator in itertools.groupby(sorted(
2347
 
                    current_inv[1] + current_disk[1], key=operator.itemgetter(0)), operator.itemgetter(1)):
 
2372
                    current_inv[1] + cur_disk_dir_content,
 
2373
                    key=operator.itemgetter(0)), operator.itemgetter(1)):
2348
2374
                    path_elements = list(subiterator)
2349
2375
                    if len(path_elements) == 2:
2350
2376
                        inv_row, disk_row = path_elements
2709
2735
        control_files.put_bytes('pending-merges', '')
2710
2736
        
2711
2737
 
2712
 
    def initialize(self, a_bzrdir, revision_id=None):
 
2738
    def initialize(self, a_bzrdir, revision_id=None, from_branch=None):
2713
2739
        """See WorkingTreeFormat.initialize()."""
2714
2740
        if not isinstance(a_bzrdir.transport, LocalTransport):
2715
2741
            raise errors.NotLocalUrl(a_bzrdir.transport.base)
2716
 
        branch = a_bzrdir.open_branch()
 
2742
        if from_branch is not None:
 
2743
            branch = from_branch
 
2744
        else:
 
2745
            branch = a_bzrdir.open_branch()
2717
2746
        if revision_id is None:
2718
2747
            revision_id = _mod_revision.ensure_null(branch.last_revision())
2719
2748
        branch.lock_write()
2730
2759
                         _bzrdir=a_bzrdir)
2731
2760
        basis_tree = branch.repository.revision_tree(revision_id)
2732
2761
        if basis_tree.inventory.root is not None:
2733
 
            wt.set_root_id(basis_tree.inventory.root.file_id)
 
2762
            wt.set_root_id(basis_tree.get_root_id())
2734
2763
        # set the parent list and cache the basis tree.
2735
2764
        if _mod_revision.is_null(revision_id):
2736
2765
            parent_trees = []
2798
2827
        return LockableFiles(transport, self._lock_file_name, 
2799
2828
                             self._lock_class)
2800
2829
 
2801
 
    def initialize(self, a_bzrdir, revision_id=None):
 
2830
    def initialize(self, a_bzrdir, revision_id=None, from_branch=None):
2802
2831
        """See WorkingTreeFormat.initialize().
2803
2832
        
2804
2833
        revision_id allows creating a working tree at a different
2811
2840
        control_files.create_lock()
2812
2841
        control_files.lock_write()
2813
2842
        control_files.put_utf8('format', self.get_format_string())
2814
 
        branch = a_bzrdir.open_branch()
 
2843
        if from_branch is not None:
 
2844
            branch = from_branch
 
2845
        else:
 
2846
            branch = a_bzrdir.open_branch()
2815
2847
        if revision_id is None:
2816
2848
            revision_id = _mod_revision.ensure_null(branch.last_revision())
2817
2849
        # WorkingTree3 can handle an inventory which has a unique root id.
2832
2864
            basis_tree = branch.repository.revision_tree(revision_id)
2833
2865
            # only set an explicit root id if there is one to set.
2834
2866
            if basis_tree.inventory.root is not None:
2835
 
                wt.set_root_id(basis_tree.inventory.root.file_id)
 
2867
                wt.set_root_id(basis_tree.get_root_id())
2836
2868
            if revision_id == NULL_REVISION:
2837
2869
                wt.set_parent_trees([])
2838
2870
            else: