ref: refs/heads/master
commit df7c96318044a45e2c856b6860448deb6554b73f
Author: Klaus Kämpf
Date: Mon Jun 22 17:57:51 2009 +0200
Drop 'explain', replace with 'ruleinfo'
---
bindings/decision.i | 12 +---------
bindings/ruby/tests/decisions.rb | 13 +++++++---
bindings/ruby/tests/ruleinfo.rb | 47 ++++++++++++++++++++++++++++++++++++++
bindings/ruleinfo.i | 26 ++++++++++----------
4 files changed, 70 insertions(+), 28 deletions(-)
diff --git a/bindings/decision.i b/bindings/decision.i
index 8124aeb..a743df7 100644
--- a/bindings/decision.i
+++ b/bindings/decision.i
@@ -62,15 +62,6 @@ typedef struct _Decision {} Decision;
*/
XSolvable *solvable()
{ return xsolvable_new( $self->solver->pool, $self->solvable ); }
- /*
- * The rule which lead to the decision
- * might be +nil+
- */
- Rule *rule()
- { if ($self->rule > $self->solver->rules)
- return $self->rule;
- return NULL;
- }
#if defined(SWIGRUBY)
VALUE
@@ -90,7 +81,7 @@ typedef struct _Decision {} Decision;
* decision.explain -> Ruleinfo
*
*/
- __type explain()
+ __type ruleinfo()
{
Swig_Type result = Swig_Null;
Solver *solver = $self->solver;
@@ -101,4 +92,3 @@ typedef struct _Decision {} Decision;
return result;
}
}
-
diff --git a/bindings/ruby/tests/decisions.rb b/bindings/ruby/tests/decisions.rb
index 4aec778..40d6339 100644
--- a/bindings/ruby/tests/decisions.rb
+++ b/bindings/ruby/tests/decisions.rb
@@ -26,6 +26,7 @@ require 'pathname'
# test Decisions
require 'test/unit'
require 'satsolver'
+require 'ruleinfo'
class DecisionTest < Test::Unit::TestCase
def test_decision
@@ -39,6 +40,10 @@ class DecisionTest < Test::Unit::TestCase
solv = installed.create_solvable( 'C', '2.0-0' )
solv.requires << Satsolver::Relation.new( pool, "D", Satsolver::REL_EQ, "3.0-0" )
installed.create_solvable( 'D', '3.0-0' )
+
+ # installed: A-0.0-0, B-1.0-0, C-2.0-0, D-3.0-0
+ # C-2.0-0 requires D-3.0-0
+
repo = pool.create_repo( 'test' )
assert repo
@@ -71,13 +76,13 @@ class DecisionTest < Test::Unit::TestCase
i += 1
case d.op
when Satsolver::DECISION_INSTALL
- puts "#{i}: Install #{d.solvable} #{d.rule}"
+ puts "#{i}: Install #{d.solvable} #{d.ruleinfo}"
when Satsolver::DECISION_REMOVE
- puts "#{i}: Remove #{d.solvable} #{d.rule}"
+ puts "#{i}: Remove #{d.solvable} #{d.ruleinfo}"
when Satsolver::DECISION_OBSOLETE
- puts "#{i}: Obsolete #{d.solvable} #{d.rule}"
+ puts "#{i}: Obsolete #{d.solvable} #{d.ruleinfo}"
when Satsolver::DECISION_UPDATE
- puts "#{i}: Update #{d.solvable} #{d.rule}"
+ puts "#{i}: Update #{d.solvable} #{d.ruleinfo}"
else
puts "#{i}: Decision op #{d.op}"
end
diff --git a/bindings/ruby/tests/ruleinfo.rb b/bindings/ruby/tests/ruleinfo.rb
new file mode 100644
index 0000000..df15012
--- /dev/null
+++ b/bindings/ruby/tests/ruleinfo.rb
@@ -0,0 +1,47 @@
+#
+# Ruleinfo support functions
+#
+module Satsolver
+ class Ruleinfo
+ def to_s
+ case command
+ when SOLVER_RULE_DISTUPGRADE:
+ "%s does not belong to a distupgrade repository" % source
+ when SOLVER_RULE_INFARCH:
+ "%s has inferior architecture" % source
+ when SOLVER_RULE_UPDATE:
+ "problem with installed package %s" % source
+ when SOLVER_RULE_JOB:
+ "conflicting requests"
+ when SOLVER_RULE_JOB_NOTHING_PROVIDES_DEP:
+ "nothing provides requested %s" % relation
+ when SOLVER_RULE_RPM:
+ "some dependency problem"
+ when SOLVER_RULE_RPM_NOT_INSTALLABLE:
+ "package %s is not installable" % source
+ when SOLVER_RULE_RPM_NOTHING_PROVIDES_DEP:
+ "nothing provides %s needed by %s" % [ relation, source ]
+ when SOLVER_RULE_RPM_SAME_NAME:
+ "cannot install both %s and %s" % [ source, target ]
+ when SOLVER_RULE_RPM_PACKAGE_CONFLICT:
+ "package %s conflicts with %s provided by %s" % [ source, relation, target ]
+ when SOLVER_RULE_RPM_PACKAGE_OBSOLETES:
+ "package %s obsoletes %s provided by %s" % [ source, relation, target ]
+ when SOLVER_RULE_RPM_IMPLICIT_OBSOLETES:
+ "package %s implicitely obsoletes %s provided by %s" % [ source, relation, target ]
+ when SOLVER_RULE_RPM_PACKAGE_REQUIRES:
+ "package %s requires %s, but none of the providers can be installed" % [ source, relation ]
+ when SOLVER_RULE_RPM_SELF_CONFLICT:
+ "package %s conflicts with %s provided by itself" % [ source, relation ]
+ when SOLVER_RULE_UNKNOWN:
+ "unknown rule"
+ when SOLVER_RULE_FEATURE:
+ "feature rule"
+ when SOLVER_RULE_LEARNT:
+ "learnt rule"
+ else
+ "***BAD RULE [%d]***" % command
+ end
+ end
+ end
+end
diff --git a/bindings/ruleinfo.i b/bindings/ruleinfo.i
index dbde610..bc2faf0 100644
--- a/bindings/ruleinfo.i
+++ b/bindings/ruleinfo.i
@@ -17,18 +17,18 @@ typedef struct _Ruleinfo {} Ruleinfo;
%extend Ruleinfo {
%constant int SOLVER_RULE_RPM = SOLVER_RULE_RPM;
- %constant int SOLVER_RULE_RPM_NOT_INSTALLABLE = SOLVER_RULE_RPM_NOT_INSTALLABLE,
- %constant int SOLVER_RULE_RPM_NOTHING_PROVIDES_DEP = SOLVER_RULE_RPM_NOTHING_PROVIDES_DEP,
- %constant int SOLVER_RULE_RPM_PACKAGE_REQUIRES = SOLVER_RULE_RPM_PACKAGE_REQUIRES,
- %constant int SOLVER_RULE_RPM_SELF_CONFLICT = SOLVER_RULE_RPM_SELF_CONFLICT,
- %constant int SOLVER_RULE_RPM_PACKAGE_CONFLICT = SOLVER_RULE_RPM_PACKAGE_CONFLICT,
- %constant int SOLVER_RULE_RPM_SAME_NAME = SOLVER_RULE_RPM_SAME_NAME,
- %constant int SOLVER_RULE_RPM_PACKAGE_OBSOLETES = SOLVER_RULE_RPM_PACKAGE_OBSOLETES,
- %constant int SOLVER_RULE_RPM_IMPLICIT_OBSOLETES = SOLVER_RULE_RPM_IMPLICIT_OBSOLETES,
- %constant int SOLVER_RULE_UPDATE = SOLVER_RULE_UPDATE = 0x200,
- %constant int SOLVER_RULE_FEATURE = SOLVER_RULE_FEATURE = 0x300,
- %constant int SOLVER_RULE_JOB = SOLVER_RULE_JOB = 0x400,
- %constant int SOLVER_RULE_JOB_NOTHING_PROVIDES_DEP = SOLVER_RULE_JOB_NOTHING_PROVIDES_DEP,
+ %constant int SOLVER_RULE_RPM_NOT_INSTALLABLE = SOLVER_RULE_RPM_NOT_INSTALLABLE;
+ %constant int SOLVER_RULE_RPM_NOTHING_PROVIDES_DEP = SOLVER_RULE_RPM_NOTHING_PROVIDES_DEP;
+ %constant int SOLVER_RULE_RPM_PACKAGE_REQUIRES = SOLVER_RULE_RPM_PACKAGE_REQUIRES;
+ %constant int SOLVER_RULE_RPM_SELF_CONFLICT = SOLVER_RULE_RPM_SELF_CONFLICT;
+ %constant int SOLVER_RULE_RPM_PACKAGE_CONFLICT = SOLVER_RULE_RPM_PACKAGE_CONFLICT;
+ %constant int SOLVER_RULE_RPM_SAME_NAME = SOLVER_RULE_RPM_SAME_NAME;
+ %constant int SOLVER_RULE_RPM_PACKAGE_OBSOLETES = SOLVER_RULE_RPM_PACKAGE_OBSOLETES;
+ %constant int SOLVER_RULE_RPM_IMPLICIT_OBSOLETES = SOLVER_RULE_RPM_IMPLICIT_OBSOLETES;
+ %constant int SOLVER_RULE_UPDATE = SOLVER_RULE_UPDATE;
+ %constant int SOLVER_RULE_FEATURE = SOLVER_RULE_FEATURE;
+ %constant int SOLVER_RULE_JOB = SOLVER_RULE_JOB;
+ %constant int SOLVER_RULE_JOB_NOTHING_PROVIDES_DEP = SOLVER_RULE_JOB_NOTHING_PROVIDES_DEP;
%constant int SOLVER_RULE_DISTUPGRADE = SOLVER_RULE_DISTUPGRADE;
%constant int SOLVER_RULE_INFARCH = SOLVER_RULE_INFARCH;
%constant int SOLVER_RULE_LEARNT = SOLVER_RULE_LEARNT;
@@ -44,5 +44,5 @@ typedef struct _Ruleinfo {} Ruleinfo;
Relation *relation()
{ return ruleinfo_relation($self); }
-
+
}
--
To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org
For additional commands, e-mail: zypp-commit+help@opensuse.org