~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/workingtree_4.py

  • Committer: Jelmer Vernooij
  • Date: 2009-04-06 02:54:14 UTC
  • mfrom: (4253 +trunk)
  • mto: This revision was merged to the branch mainline in revision 4255.
  • Revision ID: jelmer@samba.org-20090406025414-65tpjwcmjp5wa5oj
Merge bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1337
1337
 
1338
1338
    This differs from WorkingTree4 by:
1339
1339
     - Supporting content filtering.
 
1340
 
 
1341
    This is new in bzr 1.11.
 
1342
    """
 
1343
 
 
1344
 
 
1345
class WorkingTree6(DirStateWorkingTree):
 
1346
    """This is the Format 6 working tree.
 
1347
 
 
1348
    This differs from WorkingTree5 by:
1340
1349
     - Supporting a current view that may mask the set of files in a tree
1341
1350
       impacted by most user operations.
1342
1351
 
1343
 
    This is new in bzr 1.11.
 
1352
    This is new in bzr 1.14.
1344
1353
    """
1345
1354
 
1346
1355
    def _make_views(self):
1457
1466
                           _control_files=control_files)
1458
1467
 
1459
1468
    def __get_matchingbzrdir(self):
 
1469
        return self._get_matchingbzrdir()
 
1470
 
 
1471
    def _get_matchingbzrdir(self):
 
1472
        """Overrideable method to get a bzrdir for testing."""
1460
1473
        # please test against something that will let us do tree references
1461
1474
        return bzrdir.format_registry.make_bzrdir(
1462
1475
            'dirstate-with-subtree')
1490
1503
 
1491
1504
 
1492
1505
class WorkingTreeFormat5(DirStateWorkingTreeFormat):
1493
 
    """WorkingTree format supporting views.
 
1506
    """WorkingTree format supporting content filtering.
1494
1507
    """
1495
1508
 
1496
1509
    upgrade_recommended = False
1505
1518
        """See WorkingTreeFormat.get_format_description()."""
1506
1519
        return "Working tree format 5"
1507
1520
 
 
1521
    def supports_content_filtering(self):
 
1522
        return True
 
1523
 
 
1524
 
 
1525
class WorkingTreeFormat6(DirStateWorkingTreeFormat):
 
1526
    """WorkingTree format supporting views.
 
1527
    """
 
1528
 
 
1529
    upgrade_recommended = False
 
1530
 
 
1531
    _tree_class = WorkingTree6
 
1532
 
 
1533
    def get_format_string(self):
 
1534
        """See WorkingTreeFormat.get_format_string()."""
 
1535
        return "Bazaar Working Tree Format 6 (bzr 1.14)\n"
 
1536
 
 
1537
    def get_format_description(self):
 
1538
        """See WorkingTreeFormat.get_format_description()."""
 
1539
        return "Working tree format 6"
 
1540
 
1508
1541
    def _init_custom_control_files(self, wt):
1509
1542
        """Subclasses with custom control files should override this method."""
1510
1543
        wt._transport.put_bytes('views', '', mode=wt.bzrdir._get_file_mode())
1739
1772
        if entry[1][parent_index][0] != 'l':
1740
1773
            return None
1741
1774
        else:
1742
 
            # At present, none of the tree implementations supports non-ascii
1743
 
            # symlink targets. So we will just assume that the dirstate path is
1744
 
            # correct.
1745
 
            return entry[1][parent_index][1]
 
1775
            target = entry[1][parent_index][1]
 
1776
            target = target.decode('utf8')
 
1777
            return target
1746
1778
 
1747
1779
    def get_revision_id(self):
1748
1780
        """Return the revision id for this tree."""
2106
2138
        # tree during upgrade.
2107
2139
        tree._control_files.lock_write()
2108
2140
        try:
 
2141
            self.update_format(tree)
 
2142
        finally:
 
2143
            tree._control_files.unlock()
 
2144
 
 
2145
    def update_format(self, tree):
 
2146
        """Change the format marker."""
 
2147
        tree._transport.put_bytes('format',
 
2148
            self.target_format.get_format_string(),
 
2149
            mode=tree.bzrdir._get_file_mode())
 
2150
 
 
2151
 
 
2152
class Converter4or5to6(object):
 
2153
    """Perform an in-place upgrade of format 4 or 5 to format 6 trees."""
 
2154
 
 
2155
    def __init__(self):
 
2156
        self.target_format = WorkingTreeFormat6()
 
2157
 
 
2158
    def convert(self, tree):
 
2159
        # lock the control files not the tree, so that we don't get tree
 
2160
        # on-unlock behaviours, and so that no-one else diddles with the
 
2161
        # tree during upgrade.
 
2162
        tree._control_files.lock_write()
 
2163
        try:
2109
2164
            self.init_custom_control_files(tree)
2110
2165
            self.update_format(tree)
2111
2166
        finally: