~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/uncommit.py

  • Committer: Robert Collins
  • Date: 2007-07-04 08:08:13 UTC
  • mfrom: (2572 +trunk)
  • mto: This revision was merged to the branch mainline in revision 2587.
  • Revision ID: robertc@robertcollins.net-20070704080813-wzebx0r88fvwj5rq
Merge bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
16
 
17
 
"""Remove the last revision from the history of the current branch.
18
 
"""
 
17
"""Remove the last revision from the history of the current branch."""
 
18
 
 
19
# TODO: make the guts of this methods on tree, branch.
19
20
 
20
21
import os
21
22
 
 
23
from bzrlib.branch import Branch
22
24
from bzrlib.errors import BoundBranchOutOfDate
23
25
 
24
26
 
51
53
            raise BoundBranchOutOfDate(branch, master)
52
54
        if revno is None:
53
55
            revno = len(rh)
 
56
        old_revno, old_tip = branch.last_revision_info()
 
57
        new_revno = revno -1
54
58
 
55
59
        files_to_remove = []
56
60
        for r in range(revno-1, len(rh)):
57
61
            rev_id = rh.pop()
 
62
            # NB: performance would be better using the revision graph rather
 
63
            # than the whole revision.
58
64
            rev = branch.repository.get_revision(rev_id)
59
65
            # When we finish popping off the pending merges, we want
60
66
            # them to stay in the order that they used to be.
70
76
            if master is not None:
71
77
                master.set_revision_history(rh)
72
78
            branch.set_revision_history(rh)
 
79
            new_tip = branch.last_revision()
 
80
            if master is None:
 
81
                hook_local = None
 
82
                hook_master = branch
 
83
            else:
 
84
                hook_local = branch
 
85
                hook_master = master
 
86
            for hook in Branch.hooks['post_uncommit']:
 
87
                hook(hook_local, hook_master, old_revno, old_tip, new_revno,
 
88
                    new_tip)
73
89
            if tree is not None:
74
 
                branch_tip = branch.last_revision()
75
 
                if branch_tip is not None:
76
 
                    parents = [branch.last_revision()]
 
90
                if new_tip is not None:
 
91
                    parents = [new_tip]
77
92
                else:
78
93
                    parents = []
79
94
                parents.extend(reversed(pending_merges))