~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/shelf.py

  • Committer: John Arbash Meinel
  • Date: 2009-07-30 23:54:26 UTC
  • mto: This revision was merged to the branch mainline in revision 4580.
  • Revision ID: john@arbash-meinel.com-20090730235426-o8h73swbh7seqaf7
Update the breakin support to support CTRL-BREAK on Windows.

The signal handling code is very similar, but the testing code got a bit clumsy.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2008, 2009, 2010 Canonical Ltd
 
1
# Copyright (C) 2008 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
18
18
import errno
19
19
import re
20
20
 
21
 
from bzrlib.lazy_import import lazy_import
22
 
lazy_import(globals(), """
23
21
from bzrlib import (
24
22
    bencode,
25
23
    errors,
26
24
    merge,
27
25
    merge3,
 
26
    osutils,
28
27
    pack,
29
28
    transform,
 
29
    ui,
 
30
    workingtree,
30
31
)
31
 
""")
32
32
 
33
33
 
34
34
class ShelfCreator(object):
37
37
    def __init__(self, work_tree, target_tree, file_list=None):
38
38
        """Constructor.
39
39
 
40
 
        :param work_tree: The working tree to apply changes to. This is not
41
 
            required to be locked - a tree_write lock will be taken out.
 
40
        :param work_tree: The working tree to apply changes to
42
41
        :param target_tree: The tree to make the working tree more similar to.
43
 
            This is not required to be locked - a read_lock will be taken out.
44
42
        :param file_list: The files to make more similar to the target.
45
43
        """
46
44
        self.work_tree = work_tree
65
63
        """Iterable of tuples describing shelvable changes.
66
64
 
67
65
        As well as generating the tuples, this updates several members.
68
 
        Tuples may be::
69
 
 
 
66
        Tuples may be:
70
67
           ('add file', file_id, work_kind, work_path)
71
68
           ('delete file', file_id, target_kind, target_path)
72
69
           ('rename', file_id, target_path, work_path)
76
73
        """
77
74
        for (file_id, paths, changed, versioned, parents, names, kind,
78
75
             executable) in self.iter_changes:
79
 
            # don't shelve add of tree root.  Working tree should never
80
 
            # lack roots, and bzr misbehaves when they do.
81
 
            # FIXME ADHB (2009-08-09): should still shelve adds of tree roots
82
 
            # when a tree root was deleted / renamed.
83
 
            if kind[0] is None and names[1] == '':
84
 
                continue
85
 
            # Also don't shelve deletion of tree root.
86
 
            if kind[1] is None and names[0] == '':
87
 
                continue
88
76
            if kind[0] is None or versioned[0] == False:
89
77
                self.creation[file_id] = (kind[1], names[1], parents[1],
90
78
                                          versioned)
116
104
            self.shelve_deletion(change[1])
117
105
        elif change[0] == 'add file':
118
106
            self.shelve_creation(change[1])
119
 
        elif change[0] in ('change kind', 'modify text'):
 
107
        elif change[0] == 'change kind':
120
108
            self.shelve_content_change(change[1])
121
109
        elif change[0] == 'modify target':
122
110
            self.shelve_modify_target(change[1])
123
111
        else:
124
112
            raise ValueError('Unknown change kind: "%s"' % change[0])
125
113
 
126
 
    def shelve_all(self):
127
 
        """Shelve all changes."""
128
 
        for change in self.iter_shelvable():
129
 
            self.shelve_change(change)
130
 
 
131
114
    def shelve_rename(self, file_id):
132
115
        """Shelve a file rename.
133
116