/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: 2006-06-18 18:56:23 UTC
  • mfrom: (1790 +trunk)
  • mto: (1711.7.2 win32)
  • mto: This revision was merged to the branch mainline in revision 1796.
  • Revision ID: john@arbash-meinel.com-20060618185623-854bdd0fbc4f230f
[merge] bzr.dev 1790

Show diffs side-by-side

added added

removed removed

Lines of Context:
149
149
 
150
150
 
151
151
class TreeEntry(object):
152
 
    """An entry that implements the minium interface used by commands.
 
152
    """An entry that implements the minimum interface used by commands.
153
153
 
154
154
    This needs further inspection, it may be better to have 
155
155
    InventoryEntries without ids - though that seems wrong. For now,
455
455
    def get_file_byname(self, filename):
456
456
        return file(self.abspath(filename), 'rb')
457
457
 
 
458
    def get_parent_ids(self):
 
459
        """See Tree.get_parent_ids.
 
460
        
 
461
        This implementation reads the pending merges list and last_revision
 
462
        value and uses that to decide what the parents list should be.
 
463
        """
 
464
        last_rev = self.last_revision()
 
465
        if last_rev is None:
 
466
            parents = []
 
467
        else:
 
468
            parents = [last_rev]
 
469
        other_parents = self.pending_merges()
 
470
        return parents + other_parents
 
471
 
458
472
    def get_root_id(self):
459
473
        """Return the id of this trees root"""
460
474
        inv = self.read_working_inventory()
509
523
        # but with branch a kwarg now, passing in args as is results in the
510
524
        #message being used for the branch
511
525
        args = (DEPRECATED_PARAMETER, message, ) + args
512
 
        Commit().commit(working_tree=self, revprops=revprops, *args, **kwargs)
 
526
        committed_id = Commit().commit( working_tree=self, revprops=revprops,
 
527
            *args, **kwargs)
513
528
        self._set_inventory(self.read_working_inventory())
 
529
        return committed_id
514
530
 
515
531
    def id2abspath(self, file_id):
516
532
        return self.abspath(self.id2path(file_id))
552
568
            if not path:
553
569
                path = self._inventory.id2path(file_id)
554
570
            mode = os.lstat(self.abspath(path)).st_mode
555
 
            return bool(stat.S_ISREG(mode) and stat.S_IEXEC&mode)
 
571
            return bool(stat.S_ISREG(mode) and stat.S_IEXEC & mode)
556
572
 
557
573
    @needs_write_lock
558
574
    def add(self, files, ids=None):
1218
1234
                    new_revision, xml)
1219
1235
                inv.revision_id = new_revision
1220
1236
                xml = bzrlib.xml5.serializer_v5.write_inventory_to_string(inv)
1221
 
 
 
1237
            assert isinstance(xml, str), 'serialised xml must be bytestring.'
1222
1238
            path = self._basis_inventory_name()
1223
 
            self._control_files.put_utf8(path, xml)
 
1239
            sio = StringIO(xml)
 
1240
            self._control_files.put(path, sio)
1224
1241
        except WeaveRevisionNotPresent:
1225
1242
            pass
1226
1243
 
1227
1244
    def read_basis_inventory(self):
1228
1245
        """Read the cached basis inventory."""
1229
1246
        path = self._basis_inventory_name()
1230
 
        return self._control_files.get_utf8(path).read()
 
1247
        return self._control_files.get(path).read()
1231
1248
        
1232
1249
    @needs_read_lock
1233
1250
    def read_working_inventory(self):
1348
1365
        # of a nasty hack; probably it's better to have a transaction object,
1349
1366
        # which can do some finalization when it's either successfully or
1350
1367
        # unsuccessfully completed.  (Denys's original patch did that.)
1351
 
        # RBC 20060206 hookinhg into transaction will couple lock and transaction
1352
 
        # wrongly. Hookinh into unllock on the control files object is fine though.
 
1368
        # RBC 20060206 hooking into transaction will couple lock and transaction
 
1369
        # wrongly. Hooking into unlock on the control files object is fine though.
1353
1370
        
1354
1371
        # TODO: split this per format so there is no ugly if block
1355
1372
        if self._hashcache.needs_write and (
1401
1418
                                      this_tree=self)
1402
1419
                self.set_last_revision(self.branch.last_revision())
1403
1420
            if old_tip and old_tip != self.last_revision():
1404
 
                # our last revision was not the prior branch last reivison
 
1421
                # our last revision was not the prior branch last revision
1405
1422
                # and we have converted that last revision to a pending merge.
1406
1423
                # base is somewhere between the branch tip now
1407
1424
                # and the now pending merge
1443
1460
            try:
1444
1461
                if file_kind(self.abspath(conflicted)) != "file":
1445
1462
                    text = False
1446
 
            except OSError, e:
1447
 
                if e.errno == errno.ENOENT:
1448
 
                    text = False
1449
 
                else:
1450
 
                    raise
 
1463
            except errors.NoSuchFile:
 
1464
                text = False
1451
1465
            if text is True:
1452
1466
                for suffix in ('.THIS', '.OTHER'):
1453
1467
                    try:
1454
1468
                        kind = file_kind(self.abspath(conflicted+suffix))
1455
 
                    except OSError, e:
1456
 
                        if e.errno == errno.ENOENT:
 
1469
                        if kind != "file":
1457
1470
                            text = False
1458
 
                            break
1459
 
                        else:
1460
 
                            raise
1461
 
                    if kind != "file":
 
1471
                    except errors.NoSuchFile:
1462
1472
                        text = False
 
1473
                    if text == False:
1463
1474
                        break
1464
1475
            ctype = {True: 'text conflict', False: 'contents conflict'}[text]
1465
1476
            conflicts.append(Conflict.factory(ctype, path=conflicted,
1723
1734
    def initialize(self, a_bzrdir, revision_id=None):
1724
1735
        """See WorkingTreeFormat.initialize().
1725
1736
        
1726
 
        revision_id allows creating a working tree at a differnet
 
1737
        revision_id allows creating a working tree at a different
1727
1738
        revision than the branch is at.
1728
1739
        """
1729
1740
        if not isinstance(a_bzrdir.transport, LocalTransport):