~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/workingtree.py

  • Committer: Alexander Belchenko
  • Date: 2007-11-19 22:54:30 UTC
  • mfrom: (3006 +trunk)
  • mto: This revision was merged to the branch mainline in revision 3008.
  • Revision ID: bialix@ukr.net-20071119225430-x0ewosrsagis0yno
merge bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
1330
1330
                        errors.PathsDoNotExist(paths=(str(from_rel),
1331
1331
                        str(to_rel))))
1332
1332
                else:
1333
 
                    raise errors.RenameFailedFilesExist(from_rel, to_rel,
1334
 
                        extra="(Use --after to update the Bazaar id)")
 
1333
                    raise errors.RenameFailedFilesExist(from_rel, to_rel)
1335
1334
            rename_entry.only_change_inv = only_change_inv
1336
1335
        return rename_entries
1337
1336
 
1545
1544
                                change_reporter=change_reporter)
1546
1545
                    if (basis_tree.inventory.root is None and
1547
1546
                        new_basis_tree.inventory.root is not None):
1548
 
                        self.set_root_id(new_basis_tree.inventory.root.file_id)
 
1547
                        self.set_root_id(new_basis_tree.get_root_id())
1549
1548
                finally:
1550
1549
                    pb.finished()
1551
1550
                    basis_tree.unlock()
1896
1895
                         want_unversioned=True, specific_files=files):
1897
1896
                    # Check if it's an unknown (but not ignored) OR
1898
1897
                    # changed (but not deleted) :
1899
 
                    if not self.is_ignored(path[1]) and (
1900
 
                        versioned == (False, False) or
1901
 
                        content_change and kind[1] != None):
 
1898
                    if ((versioned == (False, False) or
 
1899
                         content_change and kind[1] != None)
 
1900
                        and not self.is_ignored(path[1])):
1902
1901
                        has_changed_files = True
1903
1902
                        break
1904
1903
 
2158
2157
            try:
2159
2158
                to_tree = self.branch.basis_tree()
2160
2159
                if basis.inventory.root is None:
2161
 
                    self.set_root_id(to_tree.inventory.root.file_id)
 
2160
                    self.set_root_id(to_tree.get_root_id())
2162
2161
                    self.flush()
2163
2162
                result += merge.merge_inner(
2164
2163
                                      self.branch,
2306
2305
            current_inv = None
2307
2306
            inv_finished = True
2308
2307
        while not inv_finished or not disk_finished:
 
2308
            if current_disk:
 
2309
                ((cur_disk_dir_relpath, cur_disk_dir_path_from_top),
 
2310
                    cur_disk_dir_content) = current_disk
 
2311
            else:
 
2312
                ((cur_disk_dir_relpath, cur_disk_dir_path_from_top),
 
2313
                    cur_disk_dir_content) = ((None, None), None)
2309
2314
            if not disk_finished:
2310
2315
                # strip out .bzr dirs
2311
 
                if current_disk[0][1][top_strip_len:] == '':
2312
 
                    # osutils.walkdirs can be made nicer - 
 
2316
                if (cur_disk_dir_path_from_top[top_strip_len:] == '' and
 
2317
                    len(cur_disk_dir_content) > 0):
 
2318
                    # osutils.walkdirs can be made nicer -
2313
2319
                    # yield the path-from-prefix rather than the pathjoined
2314
2320
                    # value.
2315
 
                    bzrdir_loc = bisect_left(current_disk[1], ('.bzr', '.bzr'))
2316
 
                    if current_disk[1][bzrdir_loc][0] == '.bzr':
 
2321
                    bzrdir_loc = bisect_left(cur_disk_dir_content,
 
2322
                        ('.bzr', '.bzr'))
 
2323
                    if cur_disk_dir_content[bzrdir_loc][0] == '.bzr':
2317
2324
                        # we dont yield the contents of, or, .bzr itself.
2318
 
                        del current_disk[1][bzrdir_loc]
 
2325
                        del cur_disk_dir_content[bzrdir_loc]
2319
2326
            if inv_finished:
2320
2327
                # everything is unknown
2321
2328
                direction = 1
2323
2330
                # everything is missing
2324
2331
                direction = -1
2325
2332
            else:
2326
 
                direction = cmp(current_inv[0][0], current_disk[0][0])
 
2333
                direction = cmp(current_inv[0][0], cur_disk_dir_relpath)
2327
2334
            if direction > 0:
2328
2335
                # disk is before inventory - unknown
2329
2336
                dirblock = [(relpath, basename, kind, stat, None, None) for
2330
 
                    relpath, basename, kind, stat, top_path in current_disk[1]]
2331
 
                yield (current_disk[0][0], None), dirblock
 
2337
                    relpath, basename, kind, stat, top_path in
 
2338
                    cur_disk_dir_content]
 
2339
                yield (cur_disk_dir_relpath, None), dirblock
2332
2340
                try:
2333
2341
                    current_disk = disk_iterator.next()
2334
2342
                except StopIteration:
2336
2344
            elif direction < 0:
2337
2345
                # inventory is before disk - missing.
2338
2346
                dirblock = [(relpath, basename, 'unknown', None, fileid, kind)
2339
 
                    for relpath, basename, dkind, stat, fileid, kind in 
 
2347
                    for relpath, basename, dkind, stat, fileid, kind in
2340
2348
                    current_inv[1]]
2341
2349
                yield (current_inv[0][0], current_inv[0][1]), dirblock
2342
2350
                try:
2348
2356
                # merge the inventory and disk data together
2349
2357
                dirblock = []
2350
2358
                for relpath, subiterator in itertools.groupby(sorted(
2351
 
                    current_inv[1] + current_disk[1], key=operator.itemgetter(0)), operator.itemgetter(1)):
 
2359
                    current_inv[1] + cur_disk_dir_content,
 
2360
                    key=operator.itemgetter(0)), operator.itemgetter(1)):
2352
2361
                    path_elements = list(subiterator)
2353
2362
                    if len(path_elements) == 2:
2354
2363
                        inv_row, disk_row = path_elements
2713
2722
        control_files.put_bytes('pending-merges', '')
2714
2723
        
2715
2724
 
2716
 
    def initialize(self, a_bzrdir, revision_id=None):
 
2725
    def initialize(self, a_bzrdir, revision_id=None, from_branch=None):
2717
2726
        """See WorkingTreeFormat.initialize()."""
2718
2727
        if not isinstance(a_bzrdir.transport, LocalTransport):
2719
2728
            raise errors.NotLocalUrl(a_bzrdir.transport.base)
2720
 
        branch = a_bzrdir.open_branch()
 
2729
        if from_branch is not None:
 
2730
            branch = from_branch
 
2731
        else:
 
2732
            branch = a_bzrdir.open_branch()
2721
2733
        if revision_id is None:
2722
2734
            revision_id = _mod_revision.ensure_null(branch.last_revision())
2723
2735
        branch.lock_write()
2734
2746
                         _bzrdir=a_bzrdir)
2735
2747
        basis_tree = branch.repository.revision_tree(revision_id)
2736
2748
        if basis_tree.inventory.root is not None:
2737
 
            wt.set_root_id(basis_tree.inventory.root.file_id)
 
2749
            wt.set_root_id(basis_tree.get_root_id())
2738
2750
        # set the parent list and cache the basis tree.
2739
2751
        if _mod_revision.is_null(revision_id):
2740
2752
            parent_trees = []
2802
2814
        return LockableFiles(transport, self._lock_file_name, 
2803
2815
                             self._lock_class)
2804
2816
 
2805
 
    def initialize(self, a_bzrdir, revision_id=None):
 
2817
    def initialize(self, a_bzrdir, revision_id=None, from_branch=None):
2806
2818
        """See WorkingTreeFormat.initialize().
2807
2819
        
2808
2820
        revision_id allows creating a working tree at a different
2815
2827
        control_files.create_lock()
2816
2828
        control_files.lock_write()
2817
2829
        control_files.put_utf8('format', self.get_format_string())
2818
 
        branch = a_bzrdir.open_branch()
 
2830
        if from_branch is not None:
 
2831
            branch = from_branch
 
2832
        else:
 
2833
            branch = a_bzrdir.open_branch()
2819
2834
        if revision_id is None:
2820
2835
            revision_id = _mod_revision.ensure_null(branch.last_revision())
2821
2836
        # WorkingTree3 can handle an inventory which has a unique root id.
2836
2851
            basis_tree = branch.repository.revision_tree(revision_id)
2837
2852
            # only set an explicit root id if there is one to set.
2838
2853
            if basis_tree.inventory.root is not None:
2839
 
                wt.set_root_id(basis_tree.inventory.root.file_id)
 
2854
                wt.set_root_id(basis_tree.get_root_id())
2840
2855
            if revision_id == NULL_REVISION:
2841
2856
                wt.set_parent_trees([])
2842
2857
            else: