~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to shelf_ui.py

  • Committer: Aaron Bentley
  • Date: 2008-10-10 23:35:39 UTC
  • mto: This revision was merged to the branch mainline in revision 3823.
  • Revision ID: aaron@aaronbentley.com-20081010233539-a7co7t13oj7p0grk
Reduce API friction.

Show diffs side-by-side

added added

removed removed

Lines of Context:
126
126
        else:
127
127
            return False
128
128
 
129
 
    def get_patched_text(self, file_id, patch):
130
 
        target_lines = self.target_tree.get_file_lines(file_id)
131
 
        patch_lines = osutils.split_lines(str(patch))
132
 
        return ''.join(patches.iter_patched(target_lines, patch_lines))
133
 
 
134
129
    def handle_modify_text(self, creator, file_id):
135
 
        shelved_hunks = 0
136
130
        parsed = self.get_parsed_patch(file_id)
137
 
        selected_hunks = []
138
 
        final_patch = copy.copy(parsed)
139
 
        final_patch.hunks = []
 
131
        final_hunks = []
140
132
        if not self.auto:
141
133
            offset = 0
142
134
            for hunk in parsed.hunks:
143
135
                self.diff_writer.write(str(hunk))
144
136
                if not self.prompt_bool('Shelve?'):
145
137
                    hunk.mod_pos += offset
146
 
                    final_patch.hunks.append(hunk)
 
138
                    final_hunks.append(hunk)
147
139
                else:
148
140
                    offset -= (hunk.mod_range - hunk.orig_range)
149
 
        patched_text = self.get_patched_text(file_id, final_patch)
150
 
        creator.shelve_text(file_id, patched_text)
151
 
        return len(parsed.hunks) - len(final_patch.hunks)
 
141
        target_lines = self.target_tree.get_file_lines(file_id)
 
142
        patched = patches.iter_patched_from_hunks(target_lines, final_hunks)
 
143
        creator.shelve_text(file_id, list(patched))
 
144
        return len(parsed.hunks) - len(final_hunks)
152
145
 
153
146
 
154
147
class Unshelver(object):