~abentley/bzrtools/bzrtools.dev

« back to all changes in this revision

Viewing changes to shelf.py

  • Committer: Michael Ellerman
  • Date: 2006-03-12 01:05:46 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-20060312010546-466c32126f9475e1
Backup the patch when we unshelve. Suggested by Christian Reis.

Show diffs side-by-side

added added

removed removed

Lines of Context:
158
158
            raise CommandError("Your shelved patch no " \
159
159
                    "longer applies cleanly to the working tree!")
160
160
 
161
 
        if len(to_remain) == 0:
162
 
            os.remove(patch_name)
163
 
        else:
 
161
        # Backup the shelved patch
 
162
        os.rename(patch_name, '%s~' % patch_name)
 
163
 
 
164
        if len(to_remain) > 0:
164
165
            f = open(patch_name, 'w')
165
166
            for hunk in to_remain:
166
167
                f.write(str(hunk))