From 895c499653459aa19ac3a3652e605338fb676949 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fatih=20A=C5=9F=C4=B1c=C4=B1?= Date: Tue, 22 Jun 2010 07:44:13 +0000 Subject: [PATCH] cli/delta: Allow passing multiple old packages Usages: delta oldpackage1 oldpackage2 ... newpackage delta -t newpackage oldpackage1 oldpackage2 ... --- pisi/cli/delta.py | 39 ++++++++++++++++++++++++--------------- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/pisi/cli/delta.py b/pisi/cli/delta.py index f3fbd971..eb329d22 100644 --- a/pisi/cli/delta.py +++ b/pisi/cli/delta.py @@ -21,14 +21,14 @@ import pisi.cli.command as command import pisi.context as ctx -usage = _("""Creates delta PiSi packages +usage = _("""Creates delta packages -Usage: delta oldpackage newpackage +Usages: delta oldpackage1 oldpackage2 ... newpackage + delta -t newpackage oldpackage1 oldpackage2 ... Delta command finds the changed files between the given -packages by comparing the sha1sum of the files and creates -a delta pisi package with the changed files between two -releases. +packages by comparing the sha1sum of files and creates +a delta package with the changed files. """) @@ -48,10 +48,16 @@ class Delta(command.Command): self.parser.add_option_group(group) def add_options(self, group): + group.add_option("-t", "--newest-package", + action="store", + default=None, + help=_("Use arg as the new package and treat " + "other arguments as old packages.")) + group.add_option("-O", "--output-dir", action="store", default=None, - help=_("Output directory for produced packages")) + help=_("Output directory for produced packages.")) group.add_option("-F", "--package-format", action="store", @@ -60,8 +66,6 @@ class Delta(command.Command): "supported formats.")) def run(self): - from pisi.operations.delta import create_delta_package - self.init(database=False, write=False) if self.options.package_format == "help": @@ -73,9 +77,16 @@ class Delta(command.Command): ctx.ui.info(" %s" % format) return - if len(self.args) != 2: - self.help() - return + new_package = ctx.get_option("newest_package") + if new_package: + old_packages = self.args + else: + if len(self.args) < 2: + self.help() + return + + new_package = self.args[-1] + old_packages = self.args[:-1] if ctx.get_option('output_dir'): ctx.ui.info(_('Output directory: %s') @@ -84,7 +95,5 @@ class Delta(command.Command): ctx.ui.info(_('Outputting packages in the working directory.')) ctx.config.options.output_dir = '.' - oldpackage = self.args[0] - newpackage = self.args[1] - - create_delta_package(oldpackage, newpackage) + from pisi.operations.delta import create_delta_packages + create_delta_packages(old_packages, new_package)