1
# quilt.py -- Quilt patch handling
2
# Copyright (C) 2019 Jelmer Vernooij <jelmer@jelmer.uk>
4
# Breezy is free software; you can redistribute it and/or modify
5
# it under the terms of the GNU General Public License as published by
6
# the Free Software Foundation; either version 2 of the License, or
7
# (at your option) any later version.
9
# Breezy is distributed in the hope that it will be useful,
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
# GNU General Public License for more details.
14
# You should have received a copy of the GNU General Public License
15
# along with Breezy; if not, write to the Free Software
16
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19
"""Quilt patch handling."""
21
from __future__ import absolute_import
25
from ... import osutils
28
QuiltError = wrapper.QuiltError
30
DEFAULT_PATCHES_DIR = 'patches'
33
class QuiltPatches(object):
34
"""Management object for a stack of quilt patches."""
36
def __init__(self, tree, patches_dir=None, series_file=None):
38
if patches_dir is None:
39
if tree.has_filename('.pc/.quilt_patches'):
40
patches_dir = tree.get_file_text('.pc/.quilt_patches').decode(
43
patches_dir = DEFAULT_PATCHES_DIR
44
self.patches_dir = patches_dir
45
if series_file is None:
46
series_file = os.path.join(patches_dir, 'series')
47
self.series_file = series_file
51
if tree.has_filename('.pc/.quilt_patches'):
53
for name in ['patches', 'debian/patches']:
54
if tree.has_filename(name):
55
return cls(tree, name)
59
return wrapper.quilt_upgrade(self.tree.basedir)
62
return wrapper.quilt_series(self.tree, self.series_file)
65
return wrapper.quilt_applied(self.tree)
68
return wrapper.quilt_unapplied(
69
self.tree.basedir, self.patches_dir, self.series_file)
71
def pop_all(self, quiet=None, force=False, refresh=False):
72
return wrapper.quilt_pop_all(
73
self.tree.basedir, patches_dir=self.patches_dir,
74
series_file=self.series_file, quiet=quiet, force=force,
77
def push_all(self, quiet=None, force=None, refresh=None):
78
return wrapper.quilt_push_all(
79
self.tree.basedir, patches_dir=self.patches_dir,
80
series_file=self.series_file, quiet=quiet, force=force,
83
def push(self, patch, quiet=None):
84
return wrapper.quilt_push(
85
self.tree.basedir, patch, patches_dir=self.patches_dir,
86
series_file=self.series_file, quiet=quiet)
88
def pop(self, patch, quiet=None):
89
return wrapper.quilt_pop(
90
self.tree.basedir, patch, patches_dir=self.patches_dir,
91
series_file=self.series_file, quiet=quiet)