~abentley/bzrtools/bzrtools.dev

« back to all changes in this revision

Viewing changes to shelf.py

  • Committer: Michael Ellerman
  • Date: 2006-03-11 13:09:06 UTC
  • mto: (325.1.2 bzrtools) (0.3.1 shelf-dev)
  • mto: This revision was merged to the branch mainline in revision 334.
  • Revision ID: michael@ellerman.id.au-20060311130906-387167043c79797b
When unshelving, try to patch with --dry-run first, if that fails bail out.
This should prevent the working tree getting half of the shelved patch, but
not the rest, which seems cleaner.

Show diffs side-by-side

added added

removed removed

Lines of Context:
152
152
        self.log('Reapplying shelved patches "%s"\n' % message)
153
153
 
154
154
        try:
 
155
            self._run_patch(to_unshelve, dry_run=True)
155
156
            self._run_patch(to_unshelve)
156
157
        except CommandError:
157
158
            raise CommandError("Your shelved patch no " \
203
204
        self._run_patch(to_shelve, reverse=True)
204
205
        self.__show_status(patch_source)
205
206
 
206
 
    def _run_patch(self, patches, reverse=False):
 
207
    def _run_patch(self, patches, reverse=False, dry_run=False):
207
208
        args = ['patch', '-d', self.base, '-s', '-p1', '-f']
208
209
        if reverse:
209
210
            args.append('-R')
 
211
        if dry_run:
 
212
            args.append('--dry-run')
210
213
 
211
214
        process = subprocess.Popen(args, stdin=subprocess.PIPE)
212
215
        for patch in patches: