1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
|
# quilt.py -- Quilt patch handling
# Copyright (C) 2019 Jelmer Vernooij <jelmer@jelmer.uk>
#
# Breezy is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# Breezy is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Breezy; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#
"""Quilt patch handling."""
import os
from ... import osutils
from . import wrapper
QuiltError = wrapper.QuiltError
class QuiltPatches(object):
"""Management object for a stack of quilt patches."""
def __init__(self, tree, patches_dir=None, series_file=None):
self.tree = tree
if patches_dir is None:
if tree.has_filename('.pc/.quilt_patches'):
patches_dir = tree.get_file_text('.pc/.quilt_patches').decode(
osutils._fs_enc).rstrip('\n')
else:
patches_dir = wrapper.DEFAULT_PATCHES_DIR
self.patches_dir = patches_dir
if series_file is None:
if tree.has_filename('.pc/.quilt_series'):
series_file = tree.get_file_text('.pc/.quilt_series').decode(
osutils._fs_enc).rstrip('\n')
else:
series_file = wrapper.DEFAULT_SERIES_FILE
self.series_file = series_file
self.series_path = os.path.join(self.patches_dir, self.series_file)
@classmethod
def find(cls, tree):
if tree.has_filename('.pc/.quilt_patches'):
return cls(tree)
for name in ['patches', 'debian/patches']:
if tree.has_filename(name):
return cls(tree, name)
return None
def upgrade(self):
return wrapper.quilt_upgrade(self.tree.basedir)
def series(self):
return wrapper.quilt_series(self.tree, self.series_path)
def applied(self):
return wrapper.quilt_applied(self.tree)
def unapplied(self):
return wrapper.quilt_unapplied(
self.tree.basedir, self.patches_dir, self.series_file)
def pop_all(self, quiet=None, force=False, refresh=False):
return wrapper.quilt_pop_all(
self.tree.basedir, patches_dir=self.patches_dir,
series_file=self.series_file, quiet=quiet, force=force,
refresh=refresh)
def push_all(self, quiet=None, force=None, refresh=None):
return wrapper.quilt_push_all(
self.tree.basedir, patches_dir=self.patches_dir,
series_file=self.series_file, quiet=quiet, force=force,
refresh=refresh)
def push(self, patch, quiet=None, force=None, refresh=None):
return wrapper.quilt_push(
self.tree.basedir, patch, patches_dir=self.patches_dir,
series_file=self.series_file, quiet=quiet, force=force,
refresh=refresh)
def pop(self, patch, quiet=None):
return wrapper.quilt_pop(
self.tree.basedir, patch, patches_dir=self.patches_dir,
series_file=self.series_file, quiet=quiet)
def delete(self, patch, remove=False):
return wrapper.quilt_delete(
self.tree.basedir, patch, patches_dir=self.patches_dir,
series_file=self.series_file, remove=remove)
|