~abentley/bzrtools/bzrtools.dev

« back to all changes in this revision

Viewing changes to zap.py

  • Committer: Aaron Bentley
  • Date: 2006-12-12 16:50:31 UTC
  • Revision ID: abentley@panoramicfeedback.com-20061212165031-51w8gjy1eps1vnw0
update NEWS

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
from shutil import rmtree
2
2
 
3
 
from bzrlib import (
4
 
    bzrdir,
5
 
    revision as _mod_revision,
6
 
    )
7
3
from bzrlib.branch import Branch
8
4
from bzrlib.errors import NoWorkingTree, NotLocalUrl, NotBranchError
9
5
from bzrlib.workingtree import WorkingTree
10
6
 
11
 
from errors import (NotCheckout, UncommittedCheckout, ParentMissingRevisions,
 
7
from errors import (NotCheckout, UncommittedCheckout, ParentMissingRevisions, 
12
8
                    NoParent)
13
9
 
14
10
 
15
11
def zap(path, remove_branch=False):
16
12
    try:
17
 
        wt = bzrdir.BzrDir.open(path).open_workingtree(path,
18
 
                                                       recommend_upgrade=False)
 
13
        wt = WorkingTree.open(path)
19
14
    except (NoWorkingTree, NotBranchError):
20
15
        raise NotCheckout(path)
21
16
    tree_base = wt.bzrdir.transport.base
31
26
        if parent_loc is None:
32
27
            raise NoParent()
33
28
        parent = Branch.open(parent_loc)
34
 
        last_revision = _mod_revision.ensure_null(parent.last_revision())
35
 
        p_ancestry = parent.repository.get_ancestry(last_revision)
36
 
        if (last_revision != _mod_revision.NULL_REVISION and
37
 
            branch.last_revision() not in p_ancestry):
 
29
        p_ancestry = parent.repository.get_ancestry(parent.last_revision())
 
30
        if branch.last_revision() not in p_ancestry:
38
31
            raise ParentMissingRevisions(branch.get_parent())
39
32
    rmtree(path)
40
33
    if remove_branch:
48
41
def test_suite():
49
42
    import os
50
43
    from unittest import makeSuite
51
 
 
 
44
    
52
45
    from bzrlib.bzrdir import BzrDir, BzrDirMetaFormat1
53
46
    from bzrlib.branch import BranchReferenceFormat
54
47
    from bzrlib.tests import TestCaseInTempDir