~abentley/bzrtools/bzrtools.dev

« back to all changes in this revision

Viewing changes to zap.py

  • Committer: Aaron Bentley
  • Date: 2007-07-26 15:52:55 UTC
  • Revision ID: abentley@panoramicfeedback.com-20070726155255-cawzo84zpzoulzbr
Allow importing directly from a URL

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
                    NoParent)
13
13
 
14
14
 
15
 
def zap(path, remove_branch=False, allow_modified=False):
 
15
def zap(path, remove_branch=False):
16
16
    try:
17
17
        wt = bzrdir.BzrDir.open(path).open_workingtree(path,
18
18
                                                       recommend_upgrade=False)
23
23
    branch_base = branch.bzrdir.transport.base
24
24
    if tree_base == branch_base:
25
25
        raise NotCheckout(path)
26
 
    if not allow_modified:
27
 
        delta = wt.changes_from(wt.basis_tree(), want_unchanged=False)
28
 
        if delta.has_changed():
29
 
            raise UncommittedCheckout()
 
26
    delta = wt.changes_from(wt.basis_tree(), want_unchanged=False)
 
27
    if delta.has_changed():
 
28
        raise UncommittedCheckout()
30
29
    if remove_branch:
31
30
        parent_loc = branch.get_parent()
32
31
        if parent_loc is None:
102
101
            checkout.commit('commit changes to branch')
103
102
            zap('checkout')
104
103
 
105
 
        def test_allow_modified(self):
106
 
            checkout = self.make_checkout()
107
 
            os.mkdir('checkout/foo')
108
 
            checkout.add('foo')
109
 
            self.assertRaises(UncommittedCheckout, zap, 'checkout')
110
 
            zap('checkout', allow_modified=True)
111
 
 
112
104
    return makeSuite(TestZap)