~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/branch.py

  • Committer: Aaron Bentley
  • Date: 2007-02-14 15:09:06 UTC
  • mto: This revision was merged to the branch mainline in revision 2290.
  • Revision ID: abentley@panoramicfeedback.com-20070214150906-lqdoxdz1y9zpq4ut
Fix cache updating

Show diffs side-by-side

added added

removed removed

Lines of Context:
1252
1252
        rev_history.extend(revision_ids)
1253
1253
        self.set_revision_history(rev_history)
1254
1254
 
 
1255
    def _write_revision_history(self, history):
 
1256
        """Factored out of set_revision_history.
 
1257
 
 
1258
        This performs the actual writing to disk.
 
1259
        It is intended to be called by BzrBranch5.set_revision_history."""
 
1260
        self.control_files.put_utf8(
 
1261
            'revision-history', '\n'.join(history))
 
1262
 
1255
1263
    @needs_write_lock
1256
1264
    def set_revision_history(self, rev_history):
1257
1265
        """See Branch.set_revision_history."""
1258
 
        self.control_files.put_utf8(
1259
 
            'revision-history', '\n'.join(rev_history))
 
1266
        self._write_revision_history(rev_history)
1260
1267
        transaction = self.get_transaction()
1261
1268
        history = transaction.map.find_revision_history()
1262
1269
        if history is not None:
1690
1697
            revision_id = None
1691
1698
        return revision_id
1692
1699
 
1693
 
    @needs_write_lock
1694
 
    def set_last_revision(self, revision_id):
1695
 
        if self._get_append_revisions_only():
1696
 
            self._check_history_violation(revision_id)
 
1700
    def _write_last_revision(self, revision_id):
 
1701
        """Simply write out the revision id, with no checks.
 
1702
 
 
1703
        Use set_last_revision to perform this safely.
 
1704
 
 
1705
        Does not update the revision_history cache.
 
1706
        Intended to be called by set_last_revision and write_revision_history.
 
1707
        """
1697
1708
        if revision_id is None:
1698
1709
            revision_id = 'null:'
1699
1710
        self.control_files.put_utf8('last-revision', revision_id + '\n')
1700
1711
 
 
1712
    @needs_write_lock
 
1713
    def set_last_revision(self, revision_id):
 
1714
        if self._get_append_revisions_only():
 
1715
            self._check_history_violation(revision_id)
 
1716
        self._write_last_revision(revision_id)
 
1717
        transaction = self.get_transaction()
 
1718
        cached_history = transaction.map.find_revision_history()
 
1719
        if cached_history is not None:
 
1720
            transaction.map.remove_object(cached_history)
 
1721
 
1701
1722
    def _check_history_violation(self, revision_id):
1702
1723
        last_revision = self.last_revision()
1703
1724
        if last_revision is None:
1727
1748
        history.reverse()
1728
1749
        return history
1729
1750
 
1730
 
    @needs_write_lock
1731
 
    def set_revision_history(self, history):
1732
 
        """Set the last_revision, not revision history"""
 
1751
    def _write_revision_history(self, history):
 
1752
        """Factored out of set_revision_history.
 
1753
 
 
1754
        This performs the actual writing to disk, with format-specific checks.
 
1755
        It is intended to be called by BzrBranch5.set_revision_history.
 
1756
        """
1733
1757
        if len(history) == 0:
1734
 
            self.set_last_revision('null:')
 
1758
            last_revision = 'null:'
1735
1759
        else:
1736
1760
            if history != self._lefthand_history(history[-1]):
1737
1761
                raise errors.NotLefthandHistory(history)
1738
 
            self.set_last_revision(history[-1])
1739
 
        for hook in Branch.hooks['set_rh']:
1740
 
            hook(self, history)
 
1762
            last_revision = history[-1]
 
1763
        if self._get_append_revisions_only():
 
1764
            self._check_history_violation(last_revision)
 
1765
        self._write_last_revision(last_revision)
1741
1766
 
1742
1767
    @needs_write_lock
1743
1768
    def append_revision(self, *revision_ids):