diff options
-rw-r--r-- | gbp/deb/pristinetar.py | 44 | ||||
-rw-r--r-- | gbp/pkg/pristinetar.py | 59 | ||||
-rw-r--r-- | tests/test_PristineTar.py | 2 |
3 files changed, 59 insertions, 46 deletions
diff --git a/gbp/deb/pristinetar.py b/gbp/deb/pristinetar.py index d7ce75b0..b3cf2373 100644 --- a/gbp/deb/pristinetar.py +++ b/gbp/deb/pristinetar.py @@ -16,8 +16,50 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA """Handle checkin and checkout of archives from the pristine-tar branch""" +from gbp.pkg import compressor_opts from gbp.pkg.pristinetar import PristineTar +from gbp.deb import DebianPkgPolicy class DebianPristineTar(PristineTar): """The pristine-tar branch in a Debian git repository""" - pass + def has_commit(self, package, version, comp_type=None): + """ + Do we have a pristine-tar commit for package I{package} at version + {version} with compression type I{comp_type}? + + @param package: the package to look for + @type package: C{str} + @param version: the upstream version to look for + @type version: C{str} + @param comp_type: the compression type + @type comp_type: C{str} + """ + if not comp_type: + ext = '\w\+' + else: + ext = compressor_opts[comp_type][1] + + name_regexp = '%s_%s\.orig\.tar\.%s' % (package, version, ext) + + return super(DebianPristineTar, self).has_commit(name_regexp) + + def checkout(self, package, version, comp_type, output_dir): + """ + Checkout the orig tarball for package I{package} of I{version} and + compression type I{comp_type} to I{output_dir} + + @param package: the package to generate the orig tarball for + @type package: C{str} + @param version: the version to check generate the orig tarball for + @type version: C{str} + @param comp_type: the compression type of the tarball + @type comp_type: C{str} + @param output_dir: the directory to put the tarball into + @type output_dir: C{str} + """ + name = DebianPkgPolicy.build_tarball_name(package, + version, + comp_type, + output_dir) + super(DebianPristineTar, self).checkout(name) + diff --git a/gbp/pkg/pristinetar.py b/gbp/pkg/pristinetar.py index a2f191fd..08c52d9e 100644 --- a/gbp/pkg/pristinetar.py +++ b/gbp/pkg/pristinetar.py @@ -16,11 +16,9 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA """Handle checkin and checkout of archives from the pristine-tar branch""" -import os, re +import os import gbp.log from gbp.command_wrappers import Command -from gbp.pkg import compressor_opts -from gbp.deb import DebianPkgPolicy class PristineTar(Command): """The pristine-tar branch in a git repository""" @@ -31,41 +29,28 @@ class PristineTar(Command): self.repo = repo super(PristineTar, self).__init__(self.cmd, cwd=repo.path) - def has_commit(self, package, version, comp_type=None): + def has_commit(self, archive_regexp): """ Do we have a pristine-tar commit for package I{package} at version {version} with compression type I{comp_type}? - @param package: the package to look for - @type package: C{str} - @param version: the upstream version to look for - @type version: C{str} - @param comp_type: the compression type - @type comp_type: C{str} + @param archive_regexp: archive name to look for (regexp wildcards allowed) + @type archive_regexp: C{str} """ - return True if self.get_commit(package, version, comp_type) else False + return True if self.get_commit(archive_regexp) else False - def get_commit(self, package, version, comp_type=None): + def get_commit(self, archive_regexp): """ Get the pristine-tar commit of package I{package} in version I{version} and compression type I{comp_type} - @param package: the package to look for - @type package: C{str} - @param version: the version to look for - @param comp_type: the compression type - @type comp_type: C{str} + @param archive_regexp: archive name to look for (regexp wildcards allowed) + @type archive_regexp: C{str} """ if not self.repo.has_pristine_tar_branch(): return None - if not comp_type: - ext = '\w\+' - else: - ext = compressor_opts[comp_type][1] - - regex = ('pristine-tar .* %s_%s\.orig\.tar\.%s' % - (package, version, ext)) + regex = ('pristine-tar .* %s' % archive_regexp) commits = self.repo.grep_log(regex, self.branch) if commits: commit = commits[-1] @@ -73,29 +58,15 @@ class PristineTar(Command): return commit return None - def _checkout(self, archive): - self.run_error = 'Couldn\'t checkout "%s"' % os.path.basename(archive) - self.__call__(['checkout', archive]) - - def checkout(self, package, version, comp_type, output_dir): + def checkout(self, archive): """ - Checkout the orig tarball for package I{package} of I{version} and - compression type I{comp_type} to I{output_dir} + Checkout an orig archive from pristine-tar branch - @param package: the package to generate the orig tarball for - @type package: C{str} - @param version: the version to check generate the orig tarball for - @type version: C{str} - @param comp_type: the compression type of the tarball - @type comp_type: C{str} - @param output_dir: the directory to put the tarball into - @type output_dir: C{str} + @param archive: the name of the orig archive + @type archive: C{str} """ - name = DebianPkgPolicy.build_tarball_name(package, - version, - comp_type, - output_dir) - self._checkout(name) + self.run_error = 'Couldn\'t checkout "%s"' % os.path.basename(archive) + self.__call__(['checkout', archive]) def commit(self, archive, upstream): """ diff --git a/tests/test_PristineTar.py b/tests/test_PristineTar.py index 8a645246..f1c6411e 100644 --- a/tests/test_PristineTar.py +++ b/tests/test_PristineTar.py @@ -104,7 +104,7 @@ def test_pristine_has_commit(): >>> repo.pristine_tar.has_commit('upstream', '1.0') True >>> branch = repo.rev_parse('pristine-tar') - >>> commit = repo.pristine_tar.get_commit('upstream', '1.0') + >>> commit = repo.pristine_tar.get_commit('upstream_1.0.orig.tar.gz') >>> branch == commit True """ |