Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rely on doona for quilt support\ #209

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/pythonpackage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ jobs:
if: "matrix.os == 'ubuntu-latest'"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m p install --upgrade pip
pip install -U pip setuptools
pip install -U pip coverage codecov flake8 testtools paramiko fastimport configobj cython testscenarios six docutils $TEST_REQUIRE sphinx sphinx_epytext launchpadlib patiencediff pyinotify git+https://github.com/dulwich/dulwich
pip install -U pip coverage codecov flake8 testtools paramiko fastimport configobj cython doona testscenarios six docutils $TEST_REQUIRE sphinx sphinx_epytext launchpadlib patiencediff pyinotify git+https://github.com/dulwich/dulwich
- name: Build docs
run: |
make docs PYTHON=python
Expand Down
15 changes: 13 additions & 2 deletions breezy/plugins/quilt/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,12 @@ def start_commit_check_quilt(tree):
config = tree.get_config_stack()
policy = config.get('quilt.commit_policy')
from .merge import start_commit_quilt_patches
from .wrapper import QuiltNotInstalled
try:
from doona.wrapper import QuiltNotInstalled
except ModuleNotFoundError:
trace.warning(
'doona not installed; not touching patches')
return
try:
start_commit_quilt_patches(tree, policy)
except QuiltNotInstalled:
Expand All @@ -127,12 +132,18 @@ def post_build_tree_quilt(tree):
if policy is None:
return
from .merge import post_process_quilt_patches
from .wrapper import QuiltNotInstalled
try:
from doona.wrapper import QuiltNotInstalled
except ModuleNotFoundError:
trace.warning(
'doona not installed; not touching patches')
return
try:
post_process_quilt_patches(tree, [], policy)
except QuiltNotInstalled:
trace.warning(
'quilt not installed; not touching patches')
return


from ...hooks import install_lazy_named_hook
Expand Down
47 changes: 43 additions & 4 deletions breezy/plugins/quilt/quilt.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,14 @@

"""Quilt patch handling."""

import errno
import os

from ... import osutils
from . import wrapper
from ... import errors, osutils
try:
from doona import wrapper
except ModuleNotFoundError as e:
raise errors.DependencyNotPresent('doona', e)

QuiltError = wrapper.QuiltError

Expand Down Expand Up @@ -60,10 +64,10 @@ def upgrade(self):
return wrapper.quilt_upgrade(self.tree.basedir)

def series(self):
return wrapper.quilt_series(self.tree, self.series_path)
return quilt_series(self.tree, self.series_path)

def applied(self):
return wrapper.quilt_applied(self.tree)
return quilt_applied(self.tree)

def unapplied(self):
return wrapper.quilt_unapplied(
Expand Down Expand Up @@ -96,3 +100,38 @@ 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)


def quilt_series(tree, series_path):
"""Find the list of patches.

:param tree: Tree to read from
"""
try:
return [patch.rstrip(b"\n").decode(osutils._fs_enc) for patch in
tree.get_file_lines(series_path)
if patch.strip() != b""]
except (IOError, OSError) as e:
if e.errno == errno.ENOENT:
# File has already been removed
return []
raise
except errors.NoSuchFile:
return []


def quilt_applied(tree):
"""Find the list of applied quilt patches.

"""
try:
return [patch.rstrip(b"\n").decode(osutils._fs_enc)
for patch in tree.get_file_lines(".pc/applied-patches")
if patch.strip() != b""]
except errors.NoSuchFile:
return []
except (IOError, OSError) as e:
if e.errno == errno.ENOENT:
# File has already been removed
return []
raise
1 change: 0 additions & 1 deletion breezy/plugins/quilt/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
def load_tests(loader, basic_tests, pattern):
testmod_names = [
'test_merge',
'test_wrapper',
]
basic_tests.addTest(loader.loadTestsFromModuleNames(
["%s.%s" % (__name__, i) for i in testmod_names]))
Expand Down
16 changes: 10 additions & 6 deletions breezy/plugins/quilt/tests/test_merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,17 @@
)
from ....merge import Merger
from ....mutabletree import MutableTree
from ....tests.features import ExecutableFeature, ModuleAvailableFeature

from .. import (
pre_merge_quilt,
start_commit_check_quilt,
post_build_tree_quilt,
post_merge_quilt_cleanup,
)
from ..quilt import QuiltPatches
from ..merge import tree_unapply_patches

from .test_wrapper import quilt_feature
quilt_feature = ExecutableFeature('quilt')
doona_feature = ModuleAvailableFeature('doona')

from ....tests import (
TestCaseWithTransport,
Expand All @@ -54,20 +54,23 @@


def quilt_push_all(tree):
from ..quilt import QuiltPatches
QuiltPatches(tree, 'debian/patches').push_all()


class TestTreeUnapplyPatches(TestCaseWithTransport):

_test_needs_features = [quilt_feature]
_test_needs_features = [doona_feature, quilt_feature]

def test_no_patches(self):
from ..merge import tree_unapply_patches
tree = self.make_branch_and_tree('.')
new_tree, target_dir = tree_unapply_patches(tree)
self.assertIs(tree, new_tree)
self.assertIs(None, target_dir)

def test_unapply(self):
from ..merge import tree_unapply_patches
orig_tree = self.make_branch_and_tree('source')
self.build_tree(["source/debian/", "source/debian/patches/"])
self.build_tree_contents([
Expand All @@ -83,6 +86,7 @@ def test_unapply(self):
self.assertPathExists(tree.abspath("debian/patches/series"))

def test_unapply_nothing_applied(self):
from ..merge import tree_unapply_patches
orig_tree = self.make_branch_and_tree('source')
self.build_tree(["source/debian/", "source/debian/patches/"])
self.build_tree_contents([
Expand All @@ -96,7 +100,7 @@ def test_unapply_nothing_applied(self):

class TestMergeHook(TestCaseWithTransport):

_test_needs_features = [quilt_feature]
_test_needs_features = [doona_feature, quilt_feature]

def enable_hooks(self):
Merger.hooks.install_named_hook(
Expand Down Expand Up @@ -292,7 +296,7 @@ def test_disabled_hook(self):

class StartCommitMergeHookTests(TestCaseWithTransport):

_test_needs_features = [quilt_feature]
_test_needs_features = [doona_feature, quilt_feature]

def enable_hooks(self):
MutableTree.hooks.install_named_hook(
Expand Down
121 changes: 0 additions & 121 deletions breezy/plugins/quilt/tests/test_wrapper.py

This file was deleted.

Loading