/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
7321.2.1 by Jelmer Vernooij
Bundle the quilt plugin.
1
#    quilt.py -- Quilt patch handling
2
#    Copyright (C) 2019 Jelmer Vernooij <jelmer@jelmer.uk>
3
#
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.
8
#
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.
13
#
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
17
#
18
19
"""Quilt patch handling."""
20
21
from __future__ import absolute_import
22
23
import os
24
25
from ... import osutils
26
from . import wrapper
27
28
QuiltError = wrapper.QuiltError
29
30
31
class QuiltPatches(object):
32
    """Management object for a stack of quilt patches."""
33
34
    def __init__(self, tree, patches_dir=None, series_file=None):
35
        self.tree = tree
36
        if patches_dir is None:
37
            if tree.has_filename('.pc/.quilt_patches'):
38
                patches_dir = tree.get_file_text('.pc/.quilt_patches').decode(
7321.2.8 by Jelmer Vernooij
Strip newlines.
39
                    osutils._fs_enc).rstrip('\n')
7321.2.1 by Jelmer Vernooij
Bundle the quilt plugin.
40
            else:
7321.2.9 by Jelmer Vernooij
Don't use paths in series environment variable.
41
                patches_dir = wrapper.DEFAULT_PATCHES_DIR
7321.2.1 by Jelmer Vernooij
Bundle the quilt plugin.
42
        self.patches_dir = patches_dir
43
        if series_file is None:
7321.2.9 by Jelmer Vernooij
Don't use paths in series environment variable.
44
            if tree.has_filename('.pc/.quilt_series'):
45
                series_file = tree.get_file_text('.pc/.quilt_series').decode(
46
                    osutils._fs_enc).rstrip('\n')
47
            else:
48
                series_file = wrapper.DEFAULT_SERIES_FILE
7321.2.1 by Jelmer Vernooij
Bundle the quilt plugin.
49
        self.series_file = series_file
7321.2.9 by Jelmer Vernooij
Don't use paths in series environment variable.
50
        self.series_path = os.path.join(self.patches_dir, self.series_file)
7321.2.1 by Jelmer Vernooij
Bundle the quilt plugin.
51
52
    @classmethod
53
    def find(cls, tree):
54
        if tree.has_filename('.pc/.quilt_patches'):
55
            return cls(tree)
56
        for name in ['patches', 'debian/patches']:
57
            if tree.has_filename(name):
58
                return cls(tree, name)
59
        return None
60
61
    def upgrade(self):
62
        return wrapper.quilt_upgrade(self.tree.basedir)
63
64
    def series(self):
7321.2.9 by Jelmer Vernooij
Don't use paths in series environment variable.
65
        return wrapper.quilt_series(self.tree, self.series_path)
7321.2.1 by Jelmer Vernooij
Bundle the quilt plugin.
66
67
    def applied(self):
68
        return wrapper.quilt_applied(self.tree)
69
70
    def unapplied(self):
71
        return wrapper.quilt_unapplied(
72
            self.tree.basedir, self.patches_dir, self.series_file)
73
74
    def pop_all(self, quiet=None, force=False, refresh=False):
75
        return wrapper.quilt_pop_all(
76
            self.tree.basedir, patches_dir=self.patches_dir,
77
            series_file=self.series_file, quiet=quiet, force=force,
78
            refresh=refresh)
79
80
    def push_all(self, quiet=None, force=None, refresh=None):
81
        return wrapper.quilt_push_all(
82
            self.tree.basedir, patches_dir=self.patches_dir,
83
            series_file=self.series_file, quiet=quiet, force=force,
84
            refresh=refresh)
85
7381.1.1 by Jelmer Vernooij
Add quilt_delete.
86
    def push(self, patch, quiet=None, force=None, refresh=None):
7321.2.1 by Jelmer Vernooij
Bundle the quilt plugin.
87
        return wrapper.quilt_push(
88
            self.tree.basedir, patch, patches_dir=self.patches_dir,
7381.1.1 by Jelmer Vernooij
Add quilt_delete.
89
            series_file=self.series_file, quiet=quiet, force=force,
90
            refresh=refresh)
7321.2.1 by Jelmer Vernooij
Bundle the quilt plugin.
91
92
    def pop(self, patch, quiet=None):
93
        return wrapper.quilt_pop(
94
            self.tree.basedir, patch, patches_dir=self.patches_dir,
95
            series_file=self.series_file, quiet=quiet)
7381.1.1 by Jelmer Vernooij
Add quilt_delete.
96
97
    def delete(self, patch, remove=False):
98
        return wrapper.quilt_delete(
99
            self.tree.basedir, patch, patches_dir=self.patches_dir,
100
            series_file=self.series_file, remove=remove)