~abentley/bzrtools/bzrtools.dev

« back to all changes in this revision

Viewing changes to patch.py

  • Committer: Aaron Bentley
  • Date: 2008-02-13 04:35:59 UTC
  • Revision ID: aaron@aaronbentley.com-20080213043559-rk1rlfx4nb9pfe1l
Handle missing patch, fix tabs

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005 Aaron Bentley
 
1
# Copyright (C) 2005, 2008 Aaron Bentley, 2006 Michael Ellerman
2
2
# <aaron.bentley@utoronto.ca>
3
3
#
4
4
#    This program is free software; you can redistribute it and/or modify
35
35
 
36
36
 
37
37
def run_patch(directory, patches, strip=0, reverse=False, dry_run=False,
38
 
              quiet=False):
39
 
    args = ['patch', '-d', directory, '-s', '-p%d' % strip, '-f']
 
38
              quiet=False, _patch_cmd='patch'):
 
39
    args = [_patch_cmd, '-d', directory, '-s', '-p%d' % strip, '-f']
40
40
    if quiet:
41
41
        args.append('--quiet')
42
42
 
57
57
    try:
58
58
        process = subprocess.Popen(args, stdin=subprocess.PIPE,
59
59
                                   stdout=subprocess.PIPE, stderr=stderr)
 
60
    except OSError, e:
 
61
        raise PatchInvokeError(e)
 
62
    try:
60
63
        for patch in patches:
61
64
            process.stdin.write(str(patch))
62
65
        process.stdin.close()