/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/changeset.py

  • Committer: Aaron Bentley
  • Date: 2005-10-13 17:39:52 UTC
  • mto: (1185.25.1)
  • mto: This revision was merged to the branch mainline in revision 1460.
  • Revision ID: abentley@panoramicfeedback.com-20051013173952-224b00aa1f32b7fe
Removed readonly_path from changeset generation

Show diffs side-by-side

added added

removed removed

Lines of Context:
1375
1375
        if cs_entry is None:
1376
1376
            return None
1377
1377
 
1378
 
        full_path_a = self.tree_a.readonly_path(id)
1379
 
        full_path_b = self.tree_b.readonly_path(id)
1380
 
        stat_a = self.lstat(full_path_a)
1381
 
        stat_b = self.lstat(full_path_b)
1382
 
 
1383
1378
        cs_entry.metadata_change = self.make_exec_flag_change(id)
1384
1379
 
1385
1380
        if id in self.tree_a and id in self.tree_b:
1388
1383
            if None not in (a_sha1, b_sha1) and a_sha1 == b_sha1:
1389
1384
                return cs_entry
1390
1385
 
1391
 
        cs_entry.contents_change = self.make_contents_change(full_path_a,
1392
 
                                                             stat_a, 
1393
 
                                                             full_path_b, 
1394
 
                                                             stat_b)
 
1386
        cs_entry.contents_change = self.make_contents_change(id)
1395
1387
        return cs_entry
1396
1388
 
1397
1389
    def make_exec_flag_change(self, file_id):
1406
1398
            return None
1407
1399
        return ChangeExecFlag(exec_flag_a, exec_flag_b)
1408
1400
 
1409
 
    def make_contents_change(self, full_path_a, stat_a, full_path_b, stat_b):
1410
 
        if stat_a is None and stat_b is None:
1411
 
            return None
1412
 
        if None not in (stat_a, stat_b) and stat.S_ISDIR(stat_a.st_mode) and\
1413
 
            stat.S_ISDIR(stat_b.st_mode):
1414
 
            return None
1415
 
        if None not in (stat_a, stat_b) and stat.S_ISREG(stat_a.st_mode) and\
1416
 
            stat.S_ISREG(stat_b.st_mode):
1417
 
            if stat_a.st_ino == stat_b.st_ino and \
1418
 
                stat_a.st_dev == stat_b.st_dev:
1419
 
                return None
 
1401
    def make_contents_change(self, file_id):
 
1402
        kind_a = kind_b = None
 
1403
        if file_id in self.tree_a:
 
1404
            kind_a = self.tree_a.kind(file_id)
 
1405
        if file_id in self.tree_b:
 
1406
            kind_b = self.tree_b.kind(file_id)
1420
1407
 
1421
 
        a_contents = self.get_contents(stat_a, full_path_a)
1422
 
        b_contents = self.get_contents(stat_b, full_path_b)
 
1408
        a_contents = self.get_contents(self.tree_a, file_id, kind_a)
 
1409
        b_contents = self.get_contents(self.tree_b, file_id, kind_b)
1423
1410
        if a_contents == b_contents:
1424
1411
            return None
1425
1412
        return ReplaceContents(a_contents, b_contents)
1426
1413
 
1427
 
    def get_contents(self, stat_result, full_path):
1428
 
        if stat_result is None:
 
1414
    def get_contents(self, tree, file_id, kind):
 
1415
        if kind is None:
1429
1416
            return None
1430
 
        elif stat.S_ISREG(stat_result.st_mode):
1431
 
            return FileCreate(file(full_path, "rb").read())
1432
 
        elif stat.S_ISDIR(stat_result.st_mode):
 
1417
        elif kind == "file":
 
1418
            return FileCreate(tree.get_file(file_id).read())
 
1419
        elif kind in ("directory", "root_directory"):
1433
1420
            return dir_create
1434
 
        elif stat.S_ISLNK(stat_result.st_mode):
1435
 
            return SymlinkCreate(os.readlink(full_path))
 
1421
        elif kind == "symlink":
 
1422
            return SymlinkCreate(tree.get_symlink_target(file_id))
1436
1423
        else:
1437
1424
            raise UnsupportedFiletype(full_path, stat_result)
1438
1425
 
1439
 
    def lstat(self, full_path):
1440
 
        stat_result = None
1441
 
        if full_path is not None:
1442
 
            try:
1443
 
                stat_result = os.lstat(full_path)
1444
 
            except OSError, e:
1445
 
                if e.errno != errno.ENOENT:
1446
 
                    raise
1447
 
        return stat_result
1448
 
 
1449
1426
 
1450
1427
def full_path(entry, tree):
1451
1428
    return os.path.join(tree.root, entry.path)