~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/uncommit.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2008-03-20 18:06:14 UTC
  • mfrom: (3280.4.5 uncommit_local)
  • Revision ID: pqm@pqm.ubuntu.com-20080320180614-grrzhydka050ap3a
(jam) Add --local to bzr uncommit, bug #93412

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
 
21
21
import os
22
22
 
23
 
from bzrlib import revision as _mod_revision
 
23
from bzrlib import (
 
24
    errors,
 
25
    revision as _mod_revision,
 
26
    )
24
27
from bzrlib.branch import Branch
25
28
from bzrlib.errors import BoundBranchOutOfDate
26
29
 
27
30
 
28
 
def uncommit(branch, dry_run=False, verbose=False, revno=None, tree=None):
 
31
def uncommit(branch, dry_run=False, verbose=False, revno=None, tree=None,
 
32
             local=False):
29
33
    """Remove the last revision from the supplied branch.
30
34
 
31
35
    :param dry_run: Don't actually change anything
45
49
        if tree is not None:
46
50
            pending_merges = tree.get_parent_ids()[1:]
47
51
 
48
 
        master = branch.get_master_branch()
49
 
        if master is not None:
50
 
            master.lock_write()
51
 
            unlockable.append(master)
 
52
        if local:
 
53
            master = None
 
54
            if branch.get_bound_location() is None:
 
55
                raise errors.LocalRequiresBoundBranch()
 
56
        else:
 
57
            master = branch.get_master_branch()
 
58
            if master is not None:
 
59
                master.lock_write()
 
60
                unlockable.append(master)
52
61
        rh = branch.revision_history()
53
62
        if master is not None and rh[-1] != master.last_revision():
54
63
            raise BoundBranchOutOfDate(branch, master)