~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/switch.py

  • Committer: Aaron Bentley
  • Date: 2012-07-18 18:30:48 UTC
  • mto: This revision was merged to the branch mainline in revision 6540.
  • Revision ID: aaron@aaronbentley.com-20120718183048-rr45kn62nh6m24vv
Restore uncommitted changes even if revisions are same.

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 
19
19
# Original author: David Allouche
20
20
 
21
 
from bzrlib import (
22
 
    errors,
23
 
    lock,
24
 
    merge,
25
 
    revision
26
 
    )
 
21
from bzrlib import errors, merge, revision
27
22
from bzrlib.branch import Branch
28
23
from bzrlib.i18n import gettext
29
24
from bzrlib.trace import note
45
40
    :param to_branch: branch that the checkout is to reference
46
41
    :param force: skip the check for local commits in a heavy checkout
47
42
    :param revision_id: revision ID to switch to.
48
 
    :param store_uncommitted: If True, store uncommitted changes in the
49
 
        branch.
50
43
    """
51
44
    _check_pending_merges(control_dir, force)
52
45
    try:
54
47
    except errors.NotBranchError:
55
48
        source_repository = to_branch.repository
56
49
    if store_uncommitted:
57
 
        with lock.write_locked(control_dir.open_workingtree()) as tree:
58
 
            tree.store_uncommitted()
 
50
        control_dir.open_workingtree().store_uncommitted()
59
51
    to_branch.lock_read()
60
52
    try:
61
53
        _set_branch_location(control_dir, to_branch, force)
168
160
 
169
161
    :param tree: the working tree
170
162
    :param source_repository: repository holding the revisions
171
 
    :param restore_uncommitted: restore any uncommitted changes in the branch.
172
163
    """
173
 
    if restore_uncommitted:
174
 
        tree.lock_write()
175
 
    else:
176
 
        tree.lock_tree_write()
 
164
    tree.lock_tree_write()
177
165
    try:
178
166
        to_branch = tree.branch
179
167
        if revision_id is None: