3
class PatchSource(object):
10
def can_live_update(self):
14
raise NotImplementedError()
17
return patches.parse_patches(self.readlines())
19
class FilePatchSource(PatchSource):
20
def __init__(self, filename):
21
self.filename = filename
22
PatchSource.__init__(self)
25
f = open(self.filename, 'r')
28
class BzrPatchSource(PatchSource):
29
def __init__(self, revision=None, file_list=None):
30
from bzrlib.bzrdir import BzrDir
32
self.file_list = file_list
33
if file_list is not None and len(file_list) > 0:
34
location = file_list[0]
38
self.bzrdir = BzrDir.open_containing(location)[0]
39
self.base = self.bzrdir.open_branch().base
41
self.revision = revision
43
PatchSource.__init__(self)
45
def can_live_update(self):
50
from StringIO import StringIO
51
from bzrlib.diff import diff_cmd_helper
53
# FIXME diff_cmd_helper() should take an output parameter
57
diff_cmd_helper(self.bzrdir.open_workingtree(), self.file_list,
58
external_diff_options=None, old_revision_spec=self.revision)