~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/workingtree_4.py

Merge pt1 hooks branch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2007-2010 Canonical Ltd
 
1
# Copyright (C) 2007-2011 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
1293
1293
            self._inventory = inv
1294
1294
        self.flush()
1295
1295
 
 
1296
    @needs_tree_write_lock
 
1297
    def reset_state(self, revision_ids=None):
 
1298
        """Reset the state of the working tree.
 
1299
 
 
1300
        This does a hard-reset to a last-known-good state. This is a way to
 
1301
        fix if something got corrupted (like the .bzr/checkout/dirstate file)
 
1302
        """
 
1303
        if revision_ids is None:
 
1304
            revision_ids = self.get_parent_ids()
 
1305
        if not revision_ids:
 
1306
            base_tree = self.branch.repository.revision_tree(
 
1307
                _mod_revision.NULL_REVISION)
 
1308
            trees = []
 
1309
        else:
 
1310
            trees = zip(revision_ids,
 
1311
                        self.branch.repository.revision_trees(revision_ids))
 
1312
            base_tree = trees[0][1]
 
1313
        state = self.current_dirstate()
 
1314
        # We don't support ghosts yet
 
1315
        state.set_state_from_scratch(base_tree.inventory, trees, [])
 
1316
 
1296
1317
 
1297
1318
class ContentFilterAwareSHA1Provider(dirstate.SHA1Provider):
1298
1319
 
1385
1406
 
1386
1407
class DirStateWorkingTreeFormat(WorkingTreeFormat3):
1387
1408
 
 
1409
    missing_parent_conflicts = True
 
1410
 
1388
1411
    def initialize(self, a_bzrdir, revision_id=None, from_branch=None,
1389
1412
                   accelerator_tree=None, hardlink=False):
1390
1413
        """See WorkingTreeFormat.initialize().