~abentley/bzrtools/bzrtools.dev

« back to all changes in this revision

Viewing changes to shelf.py

  • Committer: Aaron Bentley
  • Date: 2006-07-11 18:53:52 UTC
  • mfrom: (0.3.5 my_shelf)
  • Revision ID: abentley@panoramicfeedback.com-20060711185352-562216f86dac6f7f
Merge shelf colorizing

Show diffs side-by-side

added added

removed removed

Lines of Context:
7
7
from errors import CommandError, PatchFailed
8
8
from hunk_selector import ShelveHunkSelector, UnshelveHunkSelector
9
9
from patchsource import PatchSource, FilePatchSource
 
10
from bzrlib.osutils import rename
10
11
 
11
12
class Shelf(object):
12
13
    MESSAGE_PREFIX = "# Shelved patch: "
56
57
 
57
58
    def delete(self, patch):
58
59
        path = self.__path_from_user(patch)
59
 
        os.rename(path, '%s~' % path)
 
60
        rename(path, '%s~' % path)
60
61
 
61
62
    def display(self, patch=None):
62
63
        if patch is None:
180
181
                    "longer applies cleanly to the working tree!")
181
182
 
182
183
        # Backup the shelved patch
183
 
        os.rename(patch_path, '%s~' % patch_path)
 
184
        rename(patch_path, '%s~' % patch_path)
184
185
 
185
186
        if len(to_remain) > 0:
186
187
            f = open(patch_path, 'w')
234
235
 
235
236
    def _run_patch(self, patches, strip=0, reverse=False, dry_run=False):
236
237
        args = ['patch', '-d', self.base, '-s', '-p%d' % strip, '-f']
 
238
 
 
239
        if sys.platform == "win32":
 
240
            args.append('--binary')
 
241
 
237
242
        if reverse:
238
243
            args.append('-R')
239
244
        if dry_run:
310
315
            new_file.close()
311
316
            self.log('Copied %s to %s/%s\n' % (os.path.basename(patch),
312
317
                self.name, os.path.basename(new_path)))
313
 
            os.rename(patch, patch + '~')
 
318
            rename(patch, patch + '~')