/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/uncommit.py

  • Committer: Andrew Bennetts
  • Date: 2009-10-21 11:13:40 UTC
  • mto: This revision was merged to the branch mainline in revision 4762.
  • Revision ID: andrew.bennetts@canonical.com-20091021111340-w7x4d5yf83qwjncc
Add test that WSGI glue allows request handlers to access paths above that request's. backing transport, so long as it is within the WSGI app's backing transport.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
"""Remove the last revision from the history of the current branch."""
18
18
 
19
 
from __future__ import absolute_import
20
 
 
21
19
# TODO: make the guts of this methods on tree, branch.
22
20
 
23
 
from . import (
 
21
import os
 
22
 
 
23
from bzrlib import (
24
24
    errors,
25
25
    revision as _mod_revision,
26
26
    )
27
 
from .branch import Branch
28
 
from .errors import BoundBranchOutOfDate
29
 
 
30
 
 
31
 
def remove_tags(branch, graph, old_tip, parents):
32
 
    """Remove tags on revisions between old_tip and new_tip.
33
 
 
34
 
    :param branch: Branch to remove tags from
35
 
    :param graph: Graph object for branch repository
36
 
    :param old_tip: Old branch tip
37
 
    :param parents: New parents
38
 
    :return: Names of the removed tags
39
 
    """
40
 
    reverse_tags = branch.tags.get_reverse_tag_dict()
41
 
    ancestors = graph.find_unique_ancestors(old_tip, parents)
42
 
    removed_tags = []
43
 
    for revid, tags in reverse_tags.items():
44
 
        if not revid in ancestors:
45
 
            continue
46
 
        for tag in tags:
47
 
            branch.tags.delete_tag(tag)
48
 
            removed_tags.append(tag)
49
 
    return removed_tags
 
27
from bzrlib.branch import Branch
 
28
from bzrlib.errors import BoundBranchOutOfDate
50
29
 
51
30
 
52
31
def uncommit(branch, dry_run=False, verbose=False, revno=None, tree=None,
53
 
             local=False, keep_tags=False):
 
32
             local=False):
54
33
    """Remove the last revision from the supplied branch.
55
34
 
56
35
    :param dry_run: Don't actually change anything
59
38
    :param local: If this branch is bound, only remove the revisions from the
60
39
        local branch. If this branch is not bound, it is an error to pass
61
40
        local=True.
62
 
    :param keep_tags: Whether to keep tags pointing at the removed revisions
63
 
        around.
64
41
    """
65
42
    unlockable = []
66
43
    try:
91
68
            revno = old_revno
92
69
        new_revno = revno - 1
93
70
 
 
71
        revid_iterator = branch.repository.iter_reverse_revision_history(
 
72
                            old_tip)
94
73
        cur_revno = old_revno
95
74
        new_revision_id = old_tip
96
75
        graph = branch.repository.get_graph()
97
 
        for rev_id in graph.iter_lefthand_ancestry(old_tip):
 
76
        for rev_id in revid_iterator:
98
77
            if cur_revno == new_revno:
99
78
                new_revision_id = rev_id
100
79
                break
101
80
            if verbose:
102
 
                print('Removing revno %d: %s' % (cur_revno, rev_id))
 
81
                print 'Removing revno %d: %s' % (cur_revno, rev_id)
103
82
            cur_revno -= 1
104
83
            parents = graph.get_parent_map([rev_id]).get(rev_id, None)
105
84
            if not parents:
130
109
                    hook_new_tip = None
131
110
                hook(hook_local, hook_master, old_revno, old_tip, new_revno,
132
111
                     hook_new_tip)
133
 
            if not _mod_revision.is_null(new_revision_id):
134
 
                parents = [new_revision_id]
135
 
            else:
136
 
                parents = []
137
112
            if tree is not None:
 
113
                if not _mod_revision.is_null(new_revision_id):
 
114
                    parents = [new_revision_id]
 
115
                else:
 
116
                    parents = []
138
117
                parents.extend(reversed(pending_merges))
139
118
                tree.set_parent_ids(parents)
140
 
            if branch.supports_tags() and not keep_tags:
141
 
                remove_tags(branch, graph, old_tip, parents)
142
119
    finally:
143
120
        for item in reversed(unlockable):
144
121
            item.unlock()