/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: Vincent Ladeuil
  • Date: 2008-05-08 21:22:06 UTC
  • mfrom: (3417 +trunk)
  • mto: This revision was merged to the branch mainline in revision 3418.
  • Revision ID: v.ladeuil+lp@free.fr-20080508212206-kwlteu651izgs5we
merge bzr.dev to fix conflicts in NEWS

Show diffs side-by-side

added added

removed removed

Lines of Context:
111
111
        deprecated_method,
112
112
        deprecated_function,
113
113
        DEPRECATED_PARAMETER,
114
 
        zero_eight,
115
 
        zero_eleven,
116
 
        zero_thirteen,
117
114
        )
118
115
 
119
116
 
123
120
ERROR_PATH_NOT_FOUND = 3    # WindowsError errno code, equivalent to ENOENT
124
121
 
125
122
 
126
 
@deprecated_function(zero_thirteen)
127
 
def gen_file_id(name):
128
 
    """Return new file id for the basename 'name'.
129
 
 
130
 
    Use bzrlib.generate_ids.gen_file_id() instead
131
 
    """
132
 
    return generate_ids.gen_file_id(name)
133
 
 
134
 
 
135
 
@deprecated_function(zero_thirteen)
136
 
def gen_root_id():
137
 
    """Return a new tree-root file id.
138
 
 
139
 
    This has been deprecated in favor of bzrlib.generate_ids.gen_root_id()
140
 
    """
141
 
    return generate_ids.gen_root_id()
142
 
 
143
 
 
144
123
class TreeEntry(object):
145
124
    """An entry that implements the minimum interface used by commands.
146
125
 
222
201
        if not _internal:
223
202
            raise errors.BzrError("Please use bzrdir.open_workingtree or "
224
203
                "WorkingTree.open() to obtain a WorkingTree.")
225
 
        assert isinstance(basedir, basestring), \
226
 
            "base directory %r is not a string" % basedir
227
204
        basedir = safe_unicode(basedir)
228
205
        mutter("opening working tree %r", basedir)
229
206
        if deprecated_passed(branch):
237
214
            self._control_files = self.branch.control_files
238
215
        else:
239
216
            # assume all other formats have their own control files.
240
 
            assert isinstance(_control_files, LockableFiles), \
241
 
                    "_control_files must be a LockableFiles, not %r" \
242
 
                    % _control_files
243
217
            self._control_files = _control_files
244
218
        # update the whole cache up front and write to disk if anything changed;
245
219
        # in the future we might want to do this more selectively
318
292
            False then the inventory is the same as that on disk and any
319
293
            serialisation would be unneeded overhead.
320
294
        """
321
 
        assert inv.root is not None
322
295
        self._inventory = inv
323
296
        self._inventory_is_modified = dirty
324
297
 
434
407
    def _cleanup(self):
435
408
        self._flush_ignore_list_cache()
436
409
 
437
 
    @staticmethod
438
 
    @deprecated_method(zero_eight)
439
 
    def create(branch, directory):
440
 
        """Create a workingtree for branch at directory.
441
 
 
442
 
        If existing_directory already exists it must have a .bzr directory.
443
 
        If it does not exist, it will be created.
444
 
 
445
 
        This returns a new WorkingTree object for the new checkout.
446
 
 
447
 
        TODO FIXME RBC 20060124 when we have checkout formats in place this
448
 
        should accept an optional revisionid to checkout [and reject this if
449
 
        checking out into the same dir as a pre-checkout-aware branch format.]
450
 
 
451
 
        XXX: When BzrDir is present, these should be created through that 
452
 
        interface instead.
453
 
        """
454
 
        warnings.warn('delete WorkingTree.create', stacklevel=3)
455
 
        transport = get_transport(directory)
456
 
        if branch.bzrdir.root_transport.base == transport.base:
457
 
            # same dir 
458
 
            return branch.bzrdir.create_workingtree()
459
 
        # different directory, 
460
 
        # create a branch reference
461
 
        # and now a working tree.
462
 
        raise NotImplementedError
463
 
 
464
 
    @staticmethod
465
 
    @deprecated_method(zero_eight)
466
 
    def create_standalone(directory):
467
 
        """Create a checkout and a branch and a repo at directory.
468
 
 
469
 
        Directory must exist and be empty.
470
 
 
471
 
        please use BzrDir.create_standalone_workingtree
472
 
        """
473
 
        return bzrdir.BzrDir.create_standalone_workingtree(directory)
474
 
 
475
410
    def relpath(self, path):
476
411
        """Return the local path portion from a given path.
477
412
        
671
606
        # function - they should be part of lock_write and unlock.
672
607
        inv = self.inventory
673
608
        for f, file_id, kind in zip(files, ids, kinds):
674
 
            assert kind is not None
675
609
            if file_id is None:
676
610
                inv.add_path(f, kind=kind)
677
611
            else:
772
706
        else:
773
707
            return (kind, None, None, None)
774
708
 
775
 
    @deprecated_method(zero_eleven)
776
 
    @needs_read_lock
777
 
    def pending_merges(self):
778
 
        """Return a list of pending merges.
779
 
 
780
 
        These are revisions that have been merged into the working
781
 
        directory but not yet committed.
782
 
 
783
 
        As of 0.11 this is deprecated. Please see WorkingTree.get_parent_ids()
784
 
        instead - which is available on all tree objects.
785
 
        """
786
 
        return self.get_parent_ids()[1:]
787
 
 
788
709
    def _check_parents_for_ghosts(self, revision_ids, allow_leftmost_as_ghost):
789
710
        """Common ghost checking functionality from set_parent_*.
790
711
 
1276
1197
                                       DeprecationWarning)
1277
1198
 
1278
1199
        # check destination directory
1279
 
        assert not isinstance(from_paths, basestring)
 
1200
        if isinstance(from_paths, basestring):
 
1201
            raise ValueError()
1280
1202
        inv = self.inventory
1281
1203
        to_abs = self.abspath(to_dir)
1282
1204
        if not isdir(to_abs):
1546
1468
            # - RBC 20060907
1547
1469
            self._write_inventory(self._inventory)
1548
1470
    
1549
 
    @deprecated_method(zero_eight)
1550
 
    def iter_conflicts(self):
1551
 
        """List all files in the tree that have text or content conflicts.
1552
 
        DEPRECATED.  Use conflicts instead."""
1553
 
        return self._iter_conflicts()
1554
 
 
1555
1471
    def _iter_conflicts(self):
1556
1472
        conflicted = set()
1557
1473
        for info in self.list_files():
1827
1743
 
1828
1744
    def _write_basis_inventory(self, xml):
1829
1745
        """Write the basis inventory XML to the basis-inventory file"""
1830
 
        assert isinstance(xml, str), 'serialised xml must be bytestring.'
1831
1746
        path = self._basis_inventory_name()
1832
1747
        sio = StringIO(xml)
1833
1748
        self._control_files.put(path, sio)
1951
1866
                            # ... but not ignored
1952
1867
                            has_changed_files = True
1953
1868
                            break
1954
 
                    elif content_change and (kind[1] != None):
 
1869
                    elif content_change and (kind[1] is not None):
1955
1870
                        # Versioned and changed, but not deleted
1956
1871
                        has_changed_files = True
1957
1872
                        break
2097
2012
        """Set the root id for this tree."""
2098
2013
        # for compatability 
2099
2014
        if file_id is None:
2100
 
            symbol_versioning.warn(symbol_versioning.zero_twelve
2101
 
                % 'WorkingTree.set_root_id with fileid=None',
2102
 
                DeprecationWarning,
2103
 
                stacklevel=3)
2104
 
            file_id = ROOT_ID
2105
 
        else:
2106
 
            file_id = osutils.safe_file_id(file_id)
 
2015
            raise ValueError(
 
2016
                'WorkingTree.set_root_id with fileid=None')
 
2017
        file_id = osutils.safe_file_id(file_id)
2107
2018
        self._set_root_id(file_id)
2108
2019
 
2109
2020
    def _set_root_id(self, file_id):
2651
2562
            return path[:-len(suffix)]
2652
2563
 
2653
2564
 
2654
 
@deprecated_function(zero_eight)
2655
 
def is_control_file(filename):
2656
 
    """See WorkingTree.is_control_filename(filename)."""
2657
 
    ## FIXME: better check
2658
 
    filename = normpath(filename)
2659
 
    while filename != '':
2660
 
        head, tail = os.path.split(filename)
2661
 
        ## mutter('check %r for control file' % ((head, tail),))
2662
 
        if tail == '.bzr':
2663
 
            return True
2664
 
        if filename == head:
2665
 
            break
2666
 
        filename = head
2667
 
    return False
2668
 
 
2669
 
 
2670
2565
class WorkingTreeFormat(object):
2671
2566
    """An encapsulation of the initialization and open routines for a format.
2672
2567
 
2746
2641
 
2747
2642
    @classmethod
2748
2643
    def unregister_format(klass, format):
2749
 
        assert klass._formats[format.get_format_string()] is format
2750
2644
        del klass._formats[format.get_format_string()]
2751
2645
 
2752
2646