aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-11-28 23:23:44 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-11-28 23:23:44 +0000
commitc00db47d970a6a351a6eadfe892216a48100cc48 (patch)
tree7e07465f8a68e5b15723bfc619abc61f9851647c
parent0c43939dfbe7eed502ae9fda607fc620ed8c7320 (diff)
downloadpaludis-c00db47d970a6a351a6eadfe892216a48100cc48.tar.gz
paludis-c00db47d970a6a351a6eadfe892216a48100cc48.tar.xz
Be smarter in what we consider to be an scm version
-rw-r--r--paludis/dep_list/dep_list.cc18
-rw-r--r--paludis/version_spec.cc23
-rw-r--r--paludis/version_spec.hh2
-rw-r--r--paludis/version_spec_TEST.cc8
4 files changed, 46 insertions, 5 deletions
diff --git a/paludis/dep_list/dep_list.cc b/paludis/dep_list/dep_list.cc
index e4c30d1..43db2b9 100644
--- a/paludis/dep_list/dep_list.cc
+++ b/paludis/dep_list/dep_list.cc
@@ -807,6 +807,21 @@ DepList::add_already_installed_package(const PackageDatabaseEntry & p, DepTag::C
add_postdeps(metadata->deps.post_depend(), _imp->opts.installed_deps_post, "post");
}
+namespace
+{
+ bool is_scm(const QualifiedPackageName & n)
+ {
+ std::string pkg(stringify(n.package));
+ if (pkg.length() < 5)
+ return false;
+ if (0 == pkg.compare(pkg.length() - 4, 4, "-cvs"))
+ return true;
+ if (0 == pkg.compare(pkg.length() - 4, 4, "-svn"))
+ return true;
+ return false;
+ }
+}
+
bool
DepList::prefer_installed_over_uninstalled(const PackageDatabaseEntry & installed,
const PackageDatabaseEntry & uninstalled)
@@ -838,7 +853,8 @@ DepList::prefer_installed_over_uninstalled(const PackageDatabaseEntry & installe
return true;
if (dl_reinstall_scm_never != _imp->opts.reinstall_scm)
- if (installed.version.is_scm() && uninstalled.version == installed.version)
+ if (uninstalled.version == installed.version &&
+ (installed.version.is_scm() || is_scm(installed.name)))
{
static time_t current_time(time(0)); /* static to avoid weirdness */
time_t installed_time(_imp->env->package_database()->fetch_repository(installed.repository
diff --git a/paludis/version_spec.cc b/paludis/version_spec.cc
index 1971b79..8e5a498 100644
--- a/paludis/version_spec.cc
+++ b/paludis/version_spec.cc
@@ -397,9 +397,26 @@ paludis::operator<< (std::ostream & s, const VersionSpec & v)
bool
VersionSpec::is_scm() const
{
- std::vector<Part>::const_iterator r(std::find_if(_imp->parts.begin(),
- _imp->parts.end(), IsPart<scm>()));
+ std::vector<Part>::const_iterator r;
+
+ if (_imp->parts.empty())
+ return false;
+
+ /* are we an obvious scm version? */
+ r = std::find_if(_imp->parts.begin(), _imp->parts.end(), IsPart<scm>());
+ if (r != _imp->parts.end())
+ return true;
+
+ /* are we a -r9999? */
+ r = std::find_if(_imp->parts.begin(), _imp->parts.end(), IsPart<revision>());
+ if (r != _imp->parts.end())
+ if (r->value == 9999)
+ return true;
+
+ /* is our version without revisions exactly 9999? */
+ if (remove_revision() == VersionSpec("9999"))
+ return true;
- return r != _imp->parts.end();
+ return false;
}
diff --git a/paludis/version_spec.hh b/paludis/version_spec.hh
index 5772997..91e673f 100644
--- a/paludis/version_spec.hh
+++ b/paludis/version_spec.hh
@@ -116,7 +116,7 @@ namespace paludis
std::string revision_only() const;
/**
- * Are we an -scm package?
+ * Are we an -scm package, or something pretending to be one?
*/
bool is_scm() const;
diff --git a/paludis/version_spec_TEST.cc b/paludis/version_spec_TEST.cc
index 789fa9c..d464c8a 100644
--- a/paludis/version_spec_TEST.cc
+++ b/paludis/version_spec_TEST.cc
@@ -196,6 +196,14 @@ namespace test_cases
{
TEST_CHECK(! VersionSpec("1.2").is_scm());
TEST_CHECK(VersionSpec("1.2-scm-r99").is_scm());
+
+ TEST_CHECK(! VersionSpec("1.2-r9998").is_scm());
+ TEST_CHECK(VersionSpec("1.2-r9999").is_scm());
+
+ TEST_CHECK(! VersionSpec("9998").is_scm());
+ TEST_CHECK(! VersionSpec("9999_alpha2").is_scm());
+ TEST_CHECK(VersionSpec("9999").is_scm());
+ TEST_CHECK(VersionSpec("9999-r4").is_scm());
}
} test_version_is_scm;