~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/uncommit.py

  • Committer: John Arbash Meinel
  • Date: 2006-10-11 00:23:23 UTC
  • mfrom: (2070 +trunk)
  • mto: This revision was merged to the branch mainline in revision 2071.
  • Revision ID: john@arbash-meinel.com-20061011002323-82ba88c293d7caff
[merge] bzr.dev 2070

Show diffs side-by-side

added added

removed removed

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