~abentley/bzrtools/bzrtools.dev

« back to all changes in this revision

Viewing changes to zap.py

  • Committer: Aaron Bentley
  • Date: 2006-06-22 14:40:39 UTC
  • Revision ID: abentley@panoramicfeedback.com-20060622144039-41202b799cb151c8
Add check whether branch has unique revisions

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
from shutil import rmtree
2
2
 
 
3
from bzrlib.branch import Branch
3
4
from bzrlib.errors import NoWorkingTree, NotLocalUrl, NotBranchError
4
5
from bzrlib.delta import compare_trees
5
6
from bzrlib.workingtree import WorkingTree
6
7
 
7
 
from errors import NotCheckout, UncommittedCheckout
 
8
from errors import NotCheckout, UncommittedCheckout, ParentMissingRevisions
8
9
 
9
10
 
10
11
def zap(path, remove_branch=False):
20
21
    delta = compare_trees(wt.basis_tree(), wt, want_unchanged=False)
21
22
    if delta.has_changed():
22
23
        raise UncommittedCheckout()
 
24
    if remove_branch:
 
25
        parent = Branch.open(branch.get_parent())
 
26
        p_ancestry = parent.repository.get_ancestry(parent.last_revision())
 
27
        if branch.last_revision() not in p_ancestry:
 
28
            raise ParentMissingRevisions(branch.get_parent())
23
29
    rmtree(path)
24
30
    if remove_branch:
25
31
        t = branch.bzrdir.transport