~abentley/bzrtools/bzrtools.dev

« back to all changes in this revision

Viewing changes to patch.py

  • Committer: Aaron Bentley
  • Date: 2007-07-26 15:52:55 UTC
  • Revision ID: abentley@panoramicfeedback.com-20070726155255-cawzo84zpzoulzbr
Allow importing directly from a URL

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
 
 
23
from bzrlib.plugins.bzrtools.bzrtools import open_from_url
 
24
 
25
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)]
35
33
    if quiet:
36
34
        cmd.append('--quiet')