~abentley/bzrtools/bzrtools.dev

« back to all changes in this revision

Viewing changes to patch.py

  • Committer: Michael Ellerman
  • Date: 2005-11-29 01:41:52 UTC
  • mto: (0.3.1 shelf-dev) (325.1.2 bzrtools)
  • mto: This revision was merged to the branch mainline in revision 334.
  • Revision ID: michael@ellerman.id.au-20051129014152-f5ede8888bcebc48
HunkSelector was broken if you did a "done" followed by "status/invert" etc.
Fixup to make pychecker happy.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
import sys
2
 
from subprocess import Popen, PIPE
3
 
def patch(branch, filename, strip):
4
 
    """Apply a patch to a branch, using patch(1)."""
5
 
    if filename is None:
6
 
        my_file = sys.stdin
7
 
    else:
8
 
        my_file = file(filename, 'rb')
9
 
    cmd = ['patch', '--directory', branch.base, '--strip', str(strip)]
10
 
    child_proc = Popen(cmd, stdin=PIPE)
11
 
    for line in my_file:
12
 
        child_proc.stdin.write(line)
13
 
    child_proc.stdin.close()
14
 
    return child_proc.wait()