~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/workingtree.py

  • Committer: John Arbash Meinel
  • Date: 2006-02-21 16:43:22 UTC
  • mfrom: (1560 +trunk)
  • mto: This revision was merged to the branch mainline in revision 1562.
  • Revision ID: john@arbash-meinel.com-20060221164322-b007aa882582a66e
[merge] bzr.dev, cleanup conflicts, fixup http tests for new TestCase layout.

Show diffs side-by-side

added added

removed removed

Lines of Context:
226
226
        assert isinstance(basedir, basestring), \
227
227
            "base directory %r is not a string" % basedir
228
228
        basedir = safe_unicode(basedir)
229
 
        mutter("openeing working tree %r", basedir)
 
229
        mutter("opening working tree %r", basedir)
230
230
        if deprecated_passed(branch):
231
231
            if not _internal:
232
232
                warn("WorkingTree(..., branch=XXX) is deprecated as of bzr 0.8."
279
279
        self._inventory = inv
280
280
        self.path2id = self._inventory.path2id
281
281
 
 
282
    def is_control_filename(self, filename):
 
283
        """True if filename is the name of a control file in this tree.
 
284
        
 
285
        This is true IF and ONLY IF the filename is part of the meta data
 
286
        that bzr controls in this tree. I.E. a random .bzr directory placed
 
287
        on disk will not be a control file for this tree.
 
288
        """
 
289
        try:
 
290
            self.bzrdir.transport.relpath(self.abspath(filename))
 
291
            return True
 
292
        except errors.PathNotChild:
 
293
            return False
 
294
 
282
295
    @staticmethod
283
296
    def open(path=None, _unsupported=False):
284
297
        """Open an existing working tree at path.
519
532
 
520
533
        inv = self.read_working_inventory()
521
534
        for f,file_id in zip(files, ids):
522
 
            if is_control_file(f):
 
535
            if self.is_control_filename(f):
523
536
                raise BzrError("cannot add control file %s" % quotefn(f))
524
537
 
525
538
            fp = splitpath(f)
614
627
                ## TODO: If we find a subdirectory with its own .bzr
615
628
                ## directory, then that is a separate tree and we
616
629
                ## should exclude it.
617
 
                if bzrlib.BZRDIR == f:
 
630
 
 
631
                # the bzrdir for this tree
 
632
                if self.bzrdir.transport.base.endswith(f + '/'):
618
633
                    continue
619
634
 
620
635
                # path within tree
1126
1141
        
1127
1142
        # TODO: split this per format so there is no ugly if block
1128
1143
        if self._hashcache.needs_write and (
 
1144
            # dedicated lock files
1129
1145
            self._control_files._lock_count==1 or 
 
1146
            # shared lock files
1130
1147
            (self._control_files is self.branch.control_files and 
1131
 
             self._control_files._lock_count==2)):
 
1148
             self._control_files._lock_count==3)):
1132
1149
            self._hashcache.write()
1133
1150
        # reverse order of locking.
1134
1151
        result = self._control_files.unlock()
1204
1221
        if path.endswith(suffix):
1205
1222
            return path[:-len(suffix)]
1206
1223
 
 
1224
@deprecated_function(zero_eight)
1207
1225
def is_control_file(filename):
 
1226
    """See WorkingTree.is_control_filename(filename)."""
1208
1227
    ## FIXME: better check
1209
1228
    filename = normpath(filename)
1210
1229
    while filename != '':
1211
1230
        head, tail = os.path.split(filename)
1212
1231
        ## mutter('check %r for control file' % ((head, tail),))
1213
 
        if tail == bzrlib.BZRDIR:
 
1232
        if tail == '.bzr':
1214
1233
            return True
1215
1234
        if filename == head:
1216
1235
            break
1403
1422
                           _format=self,
1404
1423
                           _bzrdir=a_bzrdir)
1405
1424
 
 
1425
    def __str__(self):
 
1426
        return self.get_format_string()
 
1427
 
1406
1428
 
1407
1429
# formats which have no format string are not discoverable
1408
1430
# and not independently creatable, so are not registered.