~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_shelf.py

  • Committer: Matt Nordhoff
  • Date: 2009-04-04 02:50:01 UTC
  • mfrom: (4253 +trunk)
  • mto: This revision was merged to the branch mainline in revision 4256.
  • Revision ID: mnordhoff@mattnordhoff.com-20090404025001-z1403k0tatmc8l91
Merge bzr.dev, fixing conflicts.

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
#
13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
 
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
17
import os
18
18
 
19
 
from bzrlib import errors, pack, shelf, tests, transform
 
19
from bzrlib import errors, pack, shelf, tests, transform, workingtree
20
20
 
21
21
 
22
22
EMPTY_SHELF = ("Bazaar pack format 1 (introduced in 0.18)\n"
140
140
        limbo_name = creator.shelf_transform._limbo_name(s_trans_id)
141
141
        self.assertEqual('bar', os.readlink(limbo_name))
142
142
 
 
143
    def test_shelve_symlink_target_change(self):
 
144
        self.requireFeature(tests.SymlinkFeature)
 
145
        tree = self.make_branch_and_tree('.')
 
146
        tree.lock_write()
 
147
        self.addCleanup(tree.unlock)
 
148
        os.symlink('bar', 'foo')
 
149
        tree.add('foo', 'foo-id')
 
150
        tree.commit("commit symlink")
 
151
        os.unlink("foo")
 
152
        os.symlink('baz', 'foo')
 
153
        creator = shelf.ShelfCreator(tree, tree.basis_tree())
 
154
        self.addCleanup(creator.finalize)
 
155
        self.assertEqual([('modify target', 'foo-id', 'foo', 'bar', 'baz')],
 
156
                         list(creator.iter_shelvable()))
 
157
        creator.shelve_modify_target('foo-id')
 
158
        creator.transform()
 
159
        self.assertEqual('bar', os.readlink('foo'))
 
160
        s_trans_id = creator.shelf_transform.trans_id_file_id('foo-id')
 
161
        limbo_name = creator.shelf_transform._limbo_name(s_trans_id)
 
162
        self.assertEqual('baz', os.readlink(limbo_name))
 
163
 
143
164
    def test_shelve_creation_no_contents(self):
144
165
        tree = self.make_branch_and_tree('.')
145
166
        tree.lock_write()
268
289
        records.next()
269
290
        tt.deserialize(records)
270
291
 
 
292
    def test_shelve_unversioned(self):
 
293
        tree = self.make_branch_and_tree('tree')
 
294
        self.assertRaises(errors.PathsNotVersionedError,
 
295
                          shelf.ShelfCreator, tree, tree.basis_tree(), ['foo'])
 
296
        # We should be able to lock/unlock the tree if ShelfCreator cleaned
 
297
        # after itself.
 
298
        wt = workingtree.WorkingTree.open('tree')
 
299
        wt.lock_tree_write()
 
300
        wt.unlock()
 
301
        # And a second tentative should raise the same error (no
 
302
        # limbo/pending_deletion leftovers).
 
303
        self.assertRaises(errors.PathsNotVersionedError,
 
304
                          shelf.ShelfCreator, tree, tree.basis_tree(), ['foo'])
 
305
 
271
306
 
272
307
class TestUnshelver(tests.TestCaseWithTransport):
273
308