~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_workingtree.py

  • Committer: Aaron Bentley
  • Date: 2012-07-13 17:23:12 UTC
  • mto: This revision was merged to the branch mainline in revision 6540.
  • Revision ID: aaron@aaronbentley.com-20120713172312-0qsmwmef3pvmleoq
ImplementĀ WorkingTree.get_uncommitted_data

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
# You should have received a copy of the GNU General Public License
15
15
# along with this program; if not, write to the Free Software
16
16
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
17
from cStringIO import StringIO
17
18
 
18
19
from bzrlib import (
19
20
    bzrdir,
20
21
    conflicts,
21
22
    errors,
 
23
    shelf,
22
24
    symbol_versioning,
23
25
    transport,
24
26
    workingtree,
28
30
from bzrlib.lockdir import LockDir
29
31
from bzrlib.mutabletree import needs_tree_write_lock
30
32
from bzrlib.tests import TestCase, TestCaseWithTransport, TestSkipped
 
33
from bzrlib.transform import TransformPreview
31
34
from bzrlib.workingtree import (
32
35
    TreeEntry,
33
36
    TreeDirectory,
516
519
        tree.commit('get root in there')
517
520
        tree.store_uncommitted()
518
521
        self.assertFalse(tree.branch.has_stored_uncommitted())
 
522
 
 
523
    def test_get_uncommitted_data_none(self):
 
524
        tree = self.make_branch_and_tree('tree')
 
525
        base_tree, tt = tree.get_uncommitted_data()
 
526
        self.assertIs(None, base_tree)
 
527
        self.assertIs(None, tt)
 
528
 
 
529
    def test_get_uncommitted_data(self):
 
530
        tree = self.make_branch_and_tree('tree')
 
531
        tree.commit('add root')
 
532
        with TransformPreview(tree.basis_tree()) as tt:
 
533
            tt.new_directory('not_root', tt.root, 'not-root')
 
534
            s = StringIO()
 
535
            shelf.ShelfCreator._write_shelf(s, tt, tree.last_revision())
 
536
        s.seek(0)
 
537
        tree.branch._put_uncommitted(s)
 
538
        base_tree, tt = tree.get_uncommitted_data()
 
539
        self.addCleanup(tt.finalize)
 
540
        self.assertEqual('not-root', tt.get_preview_tree().path2id('not_root'))