~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/uncommit.py

  • Committer: Alexander Belchenko
  • Date: 2006-07-31 16:12:57 UTC
  • mto: (1711.2.111 jam-integration)
  • mto: This revision was merged to the branch mainline in revision 1906.
  • Revision ID: bialix@ukr.net-20060731161257-91a231523255332c
new official bzr.ico

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
"""
19
19
 
20
20
import os
21
 
 
22
21
from bzrlib.errors import BoundBranchOutOfDate
23
22
 
 
23
def test_remove(filename):
 
24
    if os.path.exists(filename):
 
25
        os.remove(filename)
 
26
    else:
 
27
        print '* file does not exist: %r' % filename
 
28
 
24
29
 
25
30
def uncommit(branch, dry_run=False, verbose=False, revno=None, tree=None):
26
31
    """Remove the last revision from the supplied branch.
39
44
        unlockable.append(branch)
40
45
 
41
46
        pending_merges = []
42
 
        if tree is not None:
43
 
            pending_merges = tree.get_parent_ids()[1:]
44
47
 
45
48
        master = branch.get_master_branch()
46
49
        if master is not None:
64
67
            if verbose:
65
68
                print 'Removing revno %d: %s' % (len(rh)+1, rev_id)
66
69
 
 
70
 
67
71
        # Committing before we start removing files, because
68
72
        # once we have removed at least one, all the rest are invalid.
69
73
        if not dry_run:
71
75
                master.set_revision_history(rh)
72
76
            branch.set_revision_history(rh)
73
77
            if tree is not None:
74
 
                branch_tip = branch.last_revision()
75
 
                if branch_tip is not None:
76
 
                    parents = [branch.last_revision()]
77
 
                else:
78
 
                    parents = []
79
 
                parents.extend(reversed(pending_merges))
80
 
                tree.set_parent_ids(parents)
 
78
                tree.set_last_revision(branch.last_revision())
 
79
                pending_merges.reverse()
 
80
                tree.set_pending_merges(pending_merges)
81
81
    finally:
82
82
        for item in reversed(unlockable):
83
83
            item.unlock()