~abentley/bzrtools/bzrtools.dev

« back to all changes in this revision

Viewing changes to zap.py

  • Committer: Aaron Bentley
  • Date: 2007-07-12 20:55:33 UTC
  • mfrom: (553.1.1 bzrtools)
  • Revision ID: abentley@panoramicfeedback.com-20070712205533-ael98t8ly97zuba3
Merge option help fixes from vila

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