~abentley/bzrtools/bzrtools.dev

« back to all changes in this revision

Viewing changes to hunk_selector.py

  • Committer: Michael Ellerman
  • Date: 2005-11-28 08:53:15 UTC
  • mto: (0.3.1 shelf-dev) (325.1.2 bzrtools)
  • mto: This revision was merged to the branch mainline in revision 334.
  • Revision ID: michael@ellerman.id.au-20051128085315-a955739cb6304e9b
Ask "shelve this change" instead of "keep this change", which is hopefully
more intuitive. Change the wording of some prompts for clarity.

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
class HunkSelector:
6
6
    def __init__(self, patches):
7
7
        self.standard_options = [
8
 
            UserOption('n', self.shelve, 'shelve this change for the moment.',
9
 
                default=True),
10
 
            UserOption('y', self.keep, 'keep this change in your tree.'),
 
8
            UserOption('y', self.shelve, 'shelve this change.', default=True),
 
9
            UserOption('n', self.keep, 'keep this change in your tree.'),
11
10
            UserOption('d', UserInteractor.FINISH, 'done, skip to the end.'),
12
11
            UserOption('i', self.invert,
13
 
                'invert the current selection of all hunks.'),
14
 
            UserOption('s', self.status, 'show status of hunks.'),
 
12
                'invert the current selection status of all hunks.'),
 
13
            UserOption('s', self.status, 'show selection status of all hunks.'),
15
14
            UserOption('q', UserInteractor.QUIT, 'quit')
16
15
        ]
17
16
 
18
17
        self.end_options = [
19
18
            UserOption('y', UserInteractor.FINISH,
20
 
                'proceed to shelve selected changes.', default=True),
 
19
                'shelve selected changes.', default=True),
21
20
            UserOption('r', UserInteractor.RESTART,
22
21
                'restart the hunk selection loop.'),
23
 
            UserOption('s', self.status, 'show status of hunks.'),
 
22
            UserOption('s', self.status, 'show selection status of all hunks.'),
24
23
            UserOption('i', self.invert,
25
 
                'invert the current selection of all hunks.'),
 
24
                'invert the current selection status of all hunks.'),
26
25
            UserOption('q', UserInteractor.QUIT, 'quit')
27
26
        ]
28
27
 
31
30
 
32
31
        self.last_printed = -1
33
32
        self.interactor = UserInteractor()
34
 
        self.interactor.set_prompt('Keep this change? (%(count)d of %(total)d)')
35
33
        self.interactor.set_item_callback(self.hunk_callback)
36
34
        self.interactor.set_start_callback(self.start_callback)
37
35
        self.interactor.set_end_callback(self.end_callback)
47
45
 
48
46
    # Called at the start of the main loop
49
47
    def start_callback(self):
 
48
        self.interactor.set_prompt('Shelve this change? ' \
 
49
            '(%(count)d of %(total)d)')
50
50
        self.interactor.set_options(self.standard_options)
51
51
 
52
52
    # Called at the end of the item loop, return False to indicate that the
53
53
    # interaction isn't finished and the confirmation prompt should be displayed
54
54
    def end_callback(self):
55
55
        self.status()
56
 
        self.interactor.set_prompt("Shelve these changes, or restart?")
 
56
        self.interactor.set_prompt("Shelve these changes?")
57
57
        self.interactor.set_options(self.end_options)
58
58
        return False
59
59
 
64
64
            self.last_printed = count
65
65
 
66
66
        if hunk.selected:
 
67
            self.interactor.get_option('y').default = True
 
68
            self.interactor.get_option('n').default = False
 
69
        else:
 
70
            self.interactor.get_option('y').default = False
67
71
            self.interactor.get_option('n').default = True
68
 
            self.interactor.get_option('y').default = False
69
 
        else:
70
 
            self.interactor.get_option('n').default = False
71
 
            self.interactor.get_option('y').default = True
72
72
 
73
73
    # The user chooses to shelve a hunk
74
74
    def shelve(self, hunk):