~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/uncommit.py

  • Committer: Alexander Belchenko
  • Date: 2012-03-29 08:34:13 UTC
  • mto: (6015.44.14 2.4)
  • mto: This revision was merged to the branch mainline in revision 6513.
  • Revision ID: bialix@ukr.net-20120329083413-d4bqqdtfn2yrxp4f
change st_dev, st_ino, st_uid, st_gid from int members to properties.

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
21
from bzrlib import (
28
26
from bzrlib.errors import BoundBranchOutOfDate
29
27
 
30
28
 
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.iteritems():
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
50
 
 
51
 
 
52
29
def uncommit(branch, dry_run=False, verbose=False, revno=None, tree=None,
53
 
             local=False, keep_tags=False):
 
30
             local=False):
54
31
    """Remove the last revision from the supplied branch.
55
32
 
56
33
    :param dry_run: Don't actually change anything
59
36
    :param local: If this branch is bound, only remove the revisions from the
60
37
        local branch. If this branch is not bound, it is an error to pass
61
38
        local=True.
62
 
    :param keep_tags: Whether to keep tags pointing at the removed revisions
63
 
        around.
64
39
    """
65
40
    unlockable = []
66
41
    try:
130
105
                    hook_new_tip = None
131
106
                hook(hook_local, hook_master, old_revno, old_tip, new_revno,
132
107
                     hook_new_tip)
133
 
            if not _mod_revision.is_null(new_revision_id):
134
 
                parents = [new_revision_id]
135
 
            else:
136
 
                parents = []
137
108
            if tree is not None:
 
109
                if not _mod_revision.is_null(new_revision_id):
 
110
                    parents = [new_revision_id]
 
111
                else:
 
112
                    parents = []
138
113
                parents.extend(reversed(pending_merges))
139
114
                tree.set_parent_ids(parents)
140
 
            if branch.supports_tags() and not keep_tags:
141
 
                remove_tags(branch, graph, old_tip, parents)
142
115
    finally:
143
116
        for item in reversed(unlockable):
144
117
            item.unlock()