~abentley/bzrtools/bzrtools.dev

« back to all changes in this revision

Viewing changes to hunk_selector.py

  • Committer: Michael Ellerman
  • Date: 2005-11-29 01:41:52 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-20051129014152-f5ede8888bcebc48
HunkSelector was broken if you did a "done" followed by "status/invert" etc.
Fixup to make pychecker happy.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#!/usr/bin/python
2
2
 
3
3
from userinteractor import UserInteractor, UserOption
4
 
import copy
5
4
 
6
5
class HunkSelector:
7
6
    strings = {}
117
116
        return False
118
117
 
119
118
    def select(self):
120
 
        if self.total_hunks == 0 or not self.interactor.interact():
121
 
            # False from interact means they chose to quit
122
 
            return ([], [])
123
 
 
124
 
        # Go through each patch and collect all selected/unselected hunks
 
119
        if self.total_hunks == 0:
 
120
            return []
 
121
 
 
122
        if not self.interactor.interact():
 
123
            # False from interact means they quit
 
124
            return []
 
125
 
125
126
        for patch in self.patches:
126
 
            patch.selected = []
127
 
            patch.unselected = []
 
127
            tmp = []
128
128
            for hunk in patch.hunks:
129
129
                if hunk.selected:
130
 
                    patch.selected.append(hunk)
131
 
                else:
132
 
                    patch.unselected.append(hunk)
133
 
 
134
 
        # Now build two lists, one of selected patches the other unselected
135
 
        selected_patches = []
136
 
        unselected_patches = []
137
 
 
 
130
                    tmp.append(hunk)
 
131
            patch.hunks = tmp
 
132
 
 
133
        tmp = []
138
134
        for patch in self.patches:
139
 
            if len(patch.selected):
140
 
                tmp = copy.copy(patch)
141
 
                tmp.hunks = tmp.selected
142
 
                del tmp.selected
143
 
                del tmp.unselected
144
 
                selected_patches.append(tmp)
145
 
 
146
 
            if len(patch.unselected):
147
 
                tmp = copy.copy(patch)
148
 
                tmp.hunks = tmp.unselected
149
 
                del tmp.selected
150
 
                del tmp.unselected
151
 
                unselected_patches.append(tmp)
152
 
 
153
 
        return (selected_patches, unselected_patches)
 
135
            if len(patch.hunks):
 
136
                tmp.append(patch)
 
137
        self.patches = tmp
 
138
 
 
139
        return self.patches
154
140
 
155
141
class ShelveHunkSelector(HunkSelector):
156
142
    def __init__(self, patches):