From e0bac079a4745c590e6fd8158996ab805a9265ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eray=20=C3=96zkural?= Date: Mon, 12 Jun 2006 16:09:08 +0000 Subject: [PATCH] * workaround: add an option called --ignore-file-conflicts. use responsibly. :P * an --at option for add-repo for the position of repo to be inserted in the list of repos. (we already got it in the API, this is just CLI) --- pisi/atomicoperations.py | 8 ++++++-- pisi/cli/commands.py | 13 ++++++++++--- pisi/repodb.py | 9 ++++----- 3 files changed, 20 insertions(+), 10 deletions(-) diff --git a/pisi/atomicoperations.py b/pisi/atomicoperations.py index 83dab24b..08d4abd3 100644 --- a/pisi/atomicoperations.py +++ b/pisi/atomicoperations.py @@ -163,8 +163,12 @@ class Install(AtomicOperation): if file_conflicts: file_conflicts_str = "" for (pkg, existing_file) in file_conflicts: - file_conflicts_str += _("%s from %s package") % (existing_file.path, pkg) - raise Error(_('File conflicts:\n%s') % file_conflicts_str) + file_conflicts_str += _("%s from %s package") % (existing_file.path, pkg) + msg = _('File conflicts:\n%s') % file_conflicts_str + if ctx.get_option('ignore_file_conflicts'): + ctx.ui.warning(msg) + else: + raise Error(msg) def check_reinstall(self): "check reinstall, confirm action, and schedule reinstall" diff --git a/pisi/cli/commands.py b/pisi/cli/commands.py index 805e1899..22aabb65 100644 --- a/pisi/cli/commands.py +++ b/pisi/cli/commands.py @@ -521,6 +521,8 @@ expanded to package names. default=False, help=_("Bypass ldconfig phase")) p.add_option("", "--reinstall", action="store_true", default=False, help=_("Reinstall already installed packages")) + p.add_option("", "--ignore-file-conflicts", action="store_true", + default=False, help=_("Ignore file conflicts")) buildno_opts(self) def run(self): @@ -915,8 +917,8 @@ If no repository is given, all repositories are updated. name = ("update-repo", "ur") def options(self): - self.parser.add_option("-f", "--force", action="store_true", - default=False, + self.parser.add_option("-f", "--force", action="store", + default=0, help=_("update database in any case")) def run(self): @@ -951,6 +953,11 @@ NB: We support only local files (e.g., /a/b/c) and http:// URIs at the moment name = ("add-repo", "ar") + def options(self): + self.parser.add_option("", "--at", action="store", + type="int", default=False, + help=_("add repository at given position (0 is first)")) + def run(self): if len(self.args)==2 or len(self.args)==0: @@ -961,7 +968,7 @@ NB: We support only local files (e.g., /a/b/c) and http:// URIs at the moment else: name = 'pardus-1-test' indexuri = 'http://paketler.pardus.org.tr/pardus-1-test/pisi-index.xml.bz2' - pisi.api.add_repo(name, indexuri) + pisi.api.add_repo(name, indexuri, ctx.get_option('at')) if ctx.ui.confirm(_('Update PISI database for repository %s?') % name): pisi.api.update_repo(name) self.finalize() diff --git a/pisi/repodb.py b/pisi/repodb.py index 70492b26..96c7788e 100644 --- a/pisi/repodb.py +++ b/pisi/repodb.py @@ -82,13 +82,12 @@ class RepoDB(object): raise Error(_('Repository %s already exists') % name) self.d.put("repo-" + name, repo_info, txn) order = self.d.get("order", txn) - if at: + if at == None: + order.append(name) + else: if at<0 or at>len(order): raise Error(_("Cannot add repository at position %s" % at)) - order.insert(name, at) - else: - order.append(name) - + order.insert(at, name) self.d.put("order", order, txn) self.d.txn_proc(proc, txn)