~abentley/bzrtools/bzrtools.dev

« back to all changes in this revision

Viewing changes to patch.py

  • Committer: Aaron Bentley
  • Date: 2007-11-23 15:13:59 UTC
  • Revision ID: abentley@panoramicfeedback.com-20071123151359-yrjc6ta2fkbtu9ht
Remove switch (now in bzr itself)

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
import sys
18
18
from subprocess import Popen, PIPE
19
19
 
20
 
from bzrlib import urlutils
21
 
from bzrlib.transport import get_transport
22
20
from bzrlib.workingtree import WorkingTree
23
21
import bzrlib.add
24
22
 
25
 
def patch(tree, location, strip):
 
23
from bzrlib.plugins.bzrtools.bzrtools import open_from_url
 
24
 
 
25
def patch(tree, location, strip, quiet=False):
26
26
    """Apply a patch to a branch, using patch(1).  URLs may be used."""
27
27
    my_file = None
28
28
    if location is None:
29
29
        my_file = sys.stdin
30
30
    else:
31
 
        location = urlutils.normalize_url(location)
32
 
        dirname, basename = urlutils.split(location)
33
 
        my_file = get_transport(dirname).get(basename)
 
31
        my_file = open_from_url(location)
34
32
    cmd = ['patch', '--directory', tree.basedir, '--strip', str(strip)]
 
33
    if quiet:
 
34
        cmd.append('--quiet')
35
35
    r = 0
36
36
    child_proc = Popen(cmd, stdin=PIPE)
37
37
    for line in my_file: