# HG changeset patch # User Bjoern Ricks # Date 1289323247 0 # Node ID e5b66539f89366868f7fdc098189997af457a40f # Parent 1f04bd88fca353eec2b3d4ea43060f83e261824d new variable to set choose the scm for sources and debian dirs svn_url and git_url are now deprecated in favour of url and scm_type added a tag detector for git in kde enterprise packager diff -r 1f04bd88fca3 -r e5b66539f893 recipes/kde/enterprise/generic.py --- a/recipes/kde/enterprise/generic.py Tue Nov 09 15:26:20 2010 +0000 +++ b/recipes/kde/enterprise/generic.py Tue Nov 09 17:20:47 2010 +0000 @@ -14,6 +14,7 @@ import treepkg.packager import treepkg.subversion as subversion +import treepkg.git as git class SourcePackager(treepkg.packager.SourcePackager): @@ -59,20 +60,39 @@ extra_config_desc = [("tags_url", str, ""), ("tags_pattern", str, ""), ("tags_subdir", str, ""), - ("tags_rules_subdir", str, "")] + ("tags_scm_type", str, scm_type), + ("tags_rules_url", str, None), + ("tags_rules_pattern", str, None), + ("tags_rules_subdir", str, ""), + ("tags_rules_scm_type", str, rules_scm_type)] def __init__(self, *args, **kw): tags_url = kw.pop("tags_url") tags_pattern = kw.pop("tags_pattern") tags_subdir = kw.pop("tags_subdir") + tags_rules_url = kw.pop("tags_rules_url") + tags_rules_pattern = kw.pop("tags_rules_pattern", tags_pattern) tags_rules_subdir = kw.pop("tags_rules_subdir") super(PackageTrack, self).__init__(*args, **kw) - self.tag_detector = subversion.TagDetector(tags_url, tags_pattern, + if tags_scm_type == "git": + self.tag_detector = git.TagDetector(tags_url, tags_pattern) + elif tags_scm_type == "svn": + self.tag_detector = subversion.TagDetector(tags_url, tags_pattern, tags_subdir) - self.tag_rules_detector = subversion.TagDetector(tags_url, tags_pattern, - tags_rules_subdir) + else: + raise packager.PackageError("Unknown scm type \"%s\" for tag" \ + " sources set" % tags_scm_type) + if tags_rules_scm_type == "git": + self.tag_rules_detector = git.TagDetector(tags_rules_url, + tags_rules_pattern) + elif tags_rules_scm_type == "svn": + self.tag_rules_detector = subversion.TagDetector(tags_rules_url, + tags_rules_pattern, tags_rules_subdir) + else: + raise packager.PackageError("Unknown scm type \"%s\" for tag" \ + " rules set" % tags_rules_scm_type) self.found_tag_rules = False - if tags_rules_subdir: + if tags_rules_url: self.found_tag_rules = True def packager_for_new_revision(self): diff -r 1f04bd88fca3 -r e5b66539f893 test/test_info.py --- a/test/test_info.py Tue Nov 09 15:26:20 2010 +0000 +++ b/test/test_info.py Tue Nov 09 17:20:47 2010 +0000 @@ -37,7 +37,7 @@ [pkg_simple] pkg_basename: simple1 -svn_url: svn://example.com/%(name)s/trunk +url: svn://example.com/%(name)s/trunk base_dir: %(tracks_dir)s/%(name)s packager_class: treepkginfo_test.%(name)s handle_dependencies: True diff -r 1f04bd88fca3 -r e5b66539f893 test/test_listpackages.py --- a/test/test_listpackages.py Tue Nov 09 15:26:20 2010 +0000 +++ b/test/test_listpackages.py Tue Nov 09 17:20:47 2010 +0000 @@ -75,12 +75,12 @@ instructions_file: [pkg_kdepim] -svn_url: svn://anonsvn.kde.org/home/kde/branches/kdepim/enterprise/kdepim +url: svn://anonsvn.kde.org/home/kde/branches/kdepim/enterprise/kdepim base_dir: %%(tracks_dir)s/kdepim packager_class: recipes.kde_enterprise_3_5.kdepim [pkg_kdepimlibs] -svn_url: svn://anonsvn.kde.org/home/kde/branches/kdepim/enterprise/kdepimlibs +url: svn://anonsvn.kde.org/home/kde/branches/kdepim/enterprise/kdepimlibs base_dir: %%(tracks_dir)s/kdepimlibs packager_class: recipes.kde_enterprise_3_5.kdepim """ diff -r 1f04bd88fca3 -r e5b66539f893 test/test_notifications.py --- a/test/test_notifications.py Tue Nov 09 15:26:20 2010 +0000 +++ b/test/test_notifications.py Tue Nov 09 17:20:47 2010 +0000 @@ -32,7 +32,7 @@ instructions_file: [pkg_kdepim] -svn_url: svn://anonsvn.kde.org/home/kde/branches/kdepim/enterprise/kdepim +url: svn://anonsvn.kde.org/home/kde/branches/kdepim/enterprise/kdepim base_dir: %%(tracks_dir)s/kdepim packager_class: recipes.kde_enterprise_3_5.kdepim """ diff -r 1f04bd88fca3 -r e5b66539f893 test/test_packager.py --- a/test/test_packager.py Tue Nov 09 15:26:20 2010 +0000 +++ b/test/test_packager.py Tue Nov 09 17:20:47 2010 +0000 @@ -112,7 +112,7 @@ rootcmd = os.path.join(os.path.dirname(__file__), os.pardir, "test", "mocksudopbuilder.py") track = PackageTrack(name="testpkg", base_dir=self.trackdir, - svn_url=self.svn_url, builderconfig="", + url=self.svn_url, builderconfig="", root_cmd=[sys.executable, rootcmd], deb_email="treepkg@example.com", deb_fullname="treepkg tester", @@ -593,7 +593,7 @@ def __init__(self, name, handle_dependencies, requires, provides): defaults = dict(base_dir="/home/builder/tracks/" + name, - svn_url="svn://example.com", + url="svn://example.com", root_cmd=["false"], builderconfig="/home/builder/pbuilderrc", deb_email="treepkg@example.com", deb_fullname="treepkg", diff -r 1f04bd88fca3 -r e5b66539f893 test/test_readconfig.py --- a/test/test_readconfig.py Tue Nov 09 15:26:20 2010 +0000 +++ b/test/test_readconfig.py Tue Nov 09 17:20:47 2010 +0000 @@ -38,7 +38,7 @@ [pkg_simple] pkg_basename: simple1 -svn_url: svn://example.com/%(name)s/trunk +url: svn://example.com/%(name)s/trunk base_dir: %(tracks_dir)s/%(name)s packager_class: readconfig_test.%(name)s handle_dependencies: True @@ -49,14 +49,14 @@ status_hook: echo simple hook [pkg_extraargs] -svn_url: svn://example.com/%(name)s/trunk +url: svn://example.com/%(name)s/trunk svn_subset: -N . subdir svn_externals: scripts admin base_dir: %(tracks_dir)s/%(name)s packager_class: readconfig_test.extraargs orig_tarball: %(base_dir)s/mytarball.tgz -rules_svn_url: file:///tmp/my-debian-repository +rules_url: file:///tmp/my-debian-repository deb_build_options: parallel=2 os: bar os status_hook: echo extra hook @@ -112,13 +112,12 @@ signing_key_id="", svn_externals=["scripts", "admin"], svn_subset=[(".", False), ("subdir", True)], - svn_url="svn://example.com/extraargs/trunk", - rules_svn_url="file:///tmp/my-debian-repository", + url="svn://example.com/extraargs/trunk", + rules_url="file:///tmp/my-debian-repository", version_template="%(revision)s", orig_tarball=("/home/builder/mill/" "tracks/extraargs/mytarball.tgz"), - git_url="", - git_branch="", + branch="", builder_cls="PBuilder", os="bar os", status_hook="echo extra hook"), @@ -129,7 +128,7 @@ deb_email="treepkg@example.com", deb_fullname="TreePKG", deb_build_options="", - rules_svn_url="", + rules_url="", pkg_revision_template="treepkg%(pkg_revision)s", handle_dependencies=True, packager_class="readconfig_test.simple", @@ -139,10 +138,9 @@ signing_key_id="abcd1234", svn_externals=[], svn_subset=[], - svn_url="svn://example.com/simple/trunk", + url="svn://example.com/simple/trunk", version_template="1.0.svn%(revision)s", - git_url="", - git_branch="", + branch="", builder_cls="PBuilder", os="foo os", status_hook="echo simple hook")]) diff -r 1f04bd88fca3 -r e5b66539f893 treepkg/packager.py --- a/treepkg/packager.py Tue Nov 09 15:26:20 2010 +0000 +++ b/treepkg/packager.py Tue Nov 09 17:20:47 2010 +0000 @@ -36,6 +36,11 @@ return property(get) + +class PackagerError(Exception): + + """Base class for Packager specific errors raised by TreePKG""" + class SourcePackager(object): pkg_basename = property(lambda self: self.track.pkg_basename) @@ -485,14 +490,15 @@ extra_config_desc = [] def __init__(self, name, base_dir, root_cmd, builderconfig, deb_email, - deb_fullname, svn_url="", packager_class="treepkg.packager", + deb_fullname, url="", packager_class="treepkg.packager", version_template="%(revision)s", builder_cls="PBuilder", pkg_revision_template="treepkg%(pkg_revision)s", handle_dependencies=False, signing_key_id="", do_build=True, - rules_svn_url=None, deb_build_options="", pkg_basename="", + rules_url=None, deb_build_options="", pkg_basename="", changelog_msg_template="Update to r%(revision)s", - svn_subset=(), svn_externals=(), git_branch="", git_url="", - os="", status_hook="", rules_git_url=None): + svn_subset=(), svn_externals=(), branch="", + scm_type="svn", rules_scm_type="svn", + os="", status_hook="", svn_url=None): self.name = name # Convert the builder_cls option to a class @@ -528,27 +534,47 @@ self.pkg_dir_regex = re.compile(r"(?P[0-9a-f]+)" r"-(?P[0-9a-f]+)$") self.status_hook = status_hook + + if svn_url: + url = svn_url + scm_type = "svn" + logging.warning("Track: %s options contain svn_url which is " \ + "deprecated. Please use url together with scm_type " \ + "svn instead." % name) + + # use local debian dir if rules url is not set + if not rules_url: + rules_scm_type = "local" + externals = svn_externals if not externals: externals = self.svn_external_subdirs - if svn_url: - repo = SvnRepository(svn_url, externals, subset=svn_subset) + if scm_type == "svn": + repo = SvnRepository(url, externals, subset=svn_subset) self.working_copy = SvnWorkingCopy(repo, self.checkout_dir, logger=logging) - elif git_url: - repo = GitRepository(git_url, branch=git_branch) + elif scm_type == "git": + repo = GitRepository(url, branch=branch) self.working_copy = GitWorkingCopy(repo, self.checkout_dir, logger=logging) - if rules_svn_url: - repo = SvnRepository(rules_svn_url) + else: + raise PackagerError("Unknown scm type \"%s\" for sources" % + scm_type) + + if rules_scm_type == "svn": + repo = SvnRepository(rules_url) self.rules_working_copy = SvnWorkingCopy(repo, self.debian_dir, logger=logging) - elif rules_git_url: - repo = GitRepository(rules_git_url) + elif rules_scm_type == "git": + repo = GitRepository(rules_url) self.rules_working_copy = GitWorkingCopy(repo, self.debian_dir, loggger=logging) + elif rules_scm_type == "local": + self.rules_working_copy = ManualWorkingCopy(self.debian_dir) + else: - self.rules_working_copy = ManualWorkingCopy(self.debian_dir) + raise PackagerError("Unknown scm type \"%s\" for rules" % + scm_type) checkout_dir = util.filenameproperty("checkout") debian_dir = util.filenameproperty("debian") diff -r 1f04bd88fca3 -r e5b66539f893 treepkg/readconfig.py --- a/treepkg/readconfig.py Tue Nov 09 15:26:20 2010 +0000 +++ b/treepkg/readconfig.py Tue Nov 09 17:20:47 2010 +0000 @@ -27,7 +27,7 @@ def convert_subversion_subset(raw): """Converts the string representation an svn subset into internal form The format in the config file is typically: - svn_url: svn://example.com/repository/trunk + url: svn://example.com/repository/trunk svn_subset: -N . subdir1 subdir2 @@ -66,10 +66,11 @@ packager_desc = [ "name", "base_dir", - ("svn_url", str,""), + ("url", str, ""), + ("svn_url", str, ""), ("svn_subset", convert_subversion_subset, ""), ("svn_externals", shlex.split, ""), - ("rules_svn_url", str, ""), ("packager_class", str, "treepkg.packager"), + ("rules_url", str, ""), ("packager_class", str, "treepkg.packager"), ("root_cmd", shlex.split, "sudo"), "builderconfig", "deb_email", "deb_fullname", ("deb_build_options", str, ""), ("version_template", str, "%(revision)s"), @@ -77,8 +78,7 @@ ("handle_dependencies", convert_bool), ("signing_key_id", str, ""), ("changelog_msg_template", str, "Update to revision %(revision)s"), - ("git_branch", str,""), - ("git_url", str,""), + ("branch", str,""), ("os", str, ""), ("builder_cls", str, "PBuilder"), ("status_hook", str, "") @@ -148,16 +148,11 @@ desc = packager_desc + module.PackageTrack.extra_config_desc packager_options = read_config_section(parser, section, desc, defaults=vars) - if not packager_options.get("svn_url") \ - and not packager_options.get('git_url'): + if not packager_options.get("url") and \ + not packager_options.get("svn_url"): print >>sys.stderr, "Missing repository URL in section %r" \ % (section) sys.exit(1) - elif packager_options.get("svn_url") \ - and packager_options.get('git_url'): - print >>sys.stderr, \ - "Warning: git_url in section %r will be ignored" \ - % (section) packagers.append(packager_options) # main config