~abentley/bzrtools/bzrtools.dev

« back to all changes in this revision

Viewing changes to zap.py

  • Committer: Aaron Bentley
  • Date: 2007-08-16 03:30:21 UTC
  • mto: This revision was merged to the branch mainline in revision 576.
  • Revision ID: aaron.bentley@utoronto.ca-20070816033021-e9k6t6rj25ndlhrk
Allow zap --force to delete modified checkouts

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):
 
15
def zap(path, remove_branch=False, allow_modified=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
 
    delta = wt.changes_from(wt.basis_tree(), want_unchanged=False)
27
 
    if delta.has_changed():
28
 
        raise UncommittedCheckout()
 
26
    if not allow_modified:
 
27
        delta = wt.changes_from(wt.basis_tree(), want_unchanged=False)
 
28
        if delta.has_changed():
 
29
            raise UncommittedCheckout()
29
30
    if remove_branch:
30
31
        parent_loc = branch.get_parent()
31
32
        if parent_loc is None:
101
102
            checkout.commit('commit changes to branch')
102
103
            zap('checkout')
103
104
 
 
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
 
104
112
    return makeSuite(TestZap)