~abentley/bzrtools/bzrtools.dev

« back to all changes in this revision

Viewing changes to shelf.py

  • Committer: Michael Ellerman
  • Date: 2006-03-14 08:50:40 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-20060314085040-31beef00eeae7e32
Support for 0.7 format diffs when shelving, and better error handling
in general when running patch at shelve time.

Show diffs side-by-side

added added

removed removed

Lines of Context:
215
215
        os.fsync(patch.fileno())
216
216
        patch.close()
217
217
 
218
 
        self._run_patch(to_shelve, reverse=True)
 
218
        try:
 
219
            self._run_patch(to_shelve, reverse=True, dry_run=True)
 
220
            self._run_patch(to_shelve, reverse=True)
 
221
        except PatchFailed:
 
222
            try:
 
223
                self._run_patch(to_shelve, reverse=True, strip=0, dry_run=True)
 
224
                self._run_patch(to_shelve, reverse=True, strip=0)
 
225
            except PatchFailed:
 
226
                raise CommandError("Failed removing shelved changes from the"
 
227
                    "working tree!")
219
228
 
220
229
    def _run_patch(self, patches, strip=1, reverse=False, dry_run=False):
221
230
        args = ['patch', '-d', self.base, '-s', '-p%d' % strip, '-f']