aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-01-03 19:22:31 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-01-03 19:22:31 +0000
commitb0da142e273ecc954dcca7c61ffd912d88a2cb78 (patch)
tree9762058b396b5a03fbfa36f99e31b3eaeb66f98c
parent02ca2ea159013ca58732e6687914b08e2452bf4d (diff)
downloadpaludis-b0da142e273ecc954dcca7c61ffd912d88a2cb78.tar.gz
paludis-b0da142e273ecc954dcca7c61ffd912d88a2cb78.tar.xz
Versions can include -rx.y, -rx.y.z etc. (in the right place this time...)
-rw-r--r--NEWS3
-rw-r--r--paludis/version_spec.cc44
-rw-r--r--paludis/version_spec_TEST.cc22
3 files changed, 56 insertions, 13 deletions
diff --git a/NEWS b/NEWS
index b4fd3ba..cb16e89 100644
--- a/NEWS
+++ b/NEWS
@@ -4,6 +4,9 @@ News for Paludis
This file lists the major changes between versions. For a more detailed list
of every change, see the ChangeLog.
+0.14.1:
+ * Versions can include -rx.y, -rx.y.z etc.
+
0.14.0:
* The merge and unmerge utilities are now called with an explicit path.
diff --git a/paludis/version_spec.cc b/paludis/version_spec.cc
index 586d718..1a53c67 100644
--- a/paludis/version_spec.cc
+++ b/paludis/version_spec.cc
@@ -21,6 +21,7 @@
#include <paludis/util/compare.hh>
#include <paludis/util/exception.hh>
#include <paludis/util/stringify.hh>
+#include <paludis/util/iterator.hh>
#include <paludis/version_spec.hh>
#include <vector>
#include <limits>
@@ -242,16 +243,27 @@ VersionSpec::VersionSpec(const std::string & text) :
if (0 == text.compare(p, 2, "-r"))
{
p += 2;
- unsigned long x = 0;
- while (p < text.length())
+ do
{
- if (text.at(p) < '0' || text.at(p) > '9')
+ unsigned long x = 0;
+ while (p < text.length())
+ {
+ if (text.at(p) < '0' || text.at(p) > '9')
+ break;
+ x *= 10;
+ x += text.at(p) - '0';
+ ++p;
+ }
+ _imp->parts.push_back(Part(revision, x));
+
+ if (p >= text.length())
break;
- x *= 10;
- x += text.at(p) - '0';
- ++p;
+ if (text.at(p) != '.')
+ break;
+ else
+ ++p;
}
- _imp->parts.push_back(Part(revision, x));
+ while (true);
}
/* trailing stuff? */
@@ -406,7 +418,7 @@ VersionSpec::remove_revision() const
std::string::size_type p;
if (std::string::npos != ((p = result._imp->text.rfind("-r"))))
- if (std::string::npos == result._imp->text.find_first_not_of("0123456789", p + 2))
+ if (std::string::npos == result._imp->text.find_first_not_of("0123456789.", p + 2))
result._imp->text.erase(p);
return result;
@@ -418,7 +430,21 @@ VersionSpec::revision_only() const
std::vector<Part>::const_iterator r(std::find_if(_imp->parts.begin(),
_imp->parts.end(), IsPart<revision>()));
if (r != _imp->parts.end())
- return "r" + stringify(r->value);
+ {
+ std::string result;
+ do
+ {
+ if (! result.empty())
+ result.append(".");
+ else
+ result = "r";
+
+ result.append(stringify(r->value));
+ r = std::find_if(next(r), _imp->parts.end(), IsPart<revision>());
+ } while (r != _imp->parts.end());
+
+ return result;
+ }
else
return "r0";
}
diff --git a/paludis/version_spec_TEST.cc b/paludis/version_spec_TEST.cc
index 0ee9299..488bc50 100644
--- a/paludis/version_spec_TEST.cc
+++ b/paludis/version_spec_TEST.cc
@@ -63,10 +63,11 @@ namespace test_cases
VersionSpec v17("1_alpha1-r1");
VersionSpec v18("1_beta1-r1");
VersionSpec v19("1_pre1-r1");
- VersionSpec v20("1_rc1-r1");
- VersionSpec v21("1_p1-r1");
- VersionSpec v22("1_alpha_p");
- VersionSpec v23("scm");
+ VersionSpec v20("1_pre1-r1.2");
+ VersionSpec v21("1_rc1-r1");
+ VersionSpec v22("1_p1-r1");
+ VersionSpec v23("1_alpha_p");
+ VersionSpec v24("scm");
TEST_CHECK(true);
}
@@ -148,8 +149,10 @@ namespace test_cases
{
TEST_CHECK(VersionSpec("1.2").tilde_compare(VersionSpec("1.2")));
TEST_CHECK(VersionSpec("1.2").tilde_compare(VersionSpec("1.2-r1")));
+ TEST_CHECK(VersionSpec("1.2").tilde_compare(VersionSpec("1.2-r1.2.3")));
TEST_CHECK(! VersionSpec("1.2").tilde_compare(VersionSpec("1.3")));
TEST_CHECK(VersionSpec("1.2-r1").tilde_compare(VersionSpec("1.2-r2")));
+ TEST_CHECK(VersionSpec("1.2-r1").tilde_compare(VersionSpec("1.2-r2.3")));
}
} test_version_spec_tilde_compare;
@@ -183,6 +186,12 @@ namespace test_cases
TEST_CHECK_STRINGIFY_EQUAL(VersionSpec("1.2").remove_revision(), "1.2");
TEST_CHECK_STRINGIFY_EQUAL(VersionSpec("1.2-r").remove_revision(), "1.2");
TEST_CHECK_STRINGIFY_EQUAL(VersionSpec("1.2-r99").remove_revision(), "1.2");
+ TEST_CHECK_STRINGIFY_EQUAL(VersionSpec("1.2-r3.4").remove_revision(), "1.2");
+
+ TEST_CHECK_EQUAL(VersionSpec("1.2").remove_revision(), VersionSpec("1.2"));
+ TEST_CHECK_EQUAL(VersionSpec("1.2-r").remove_revision(), VersionSpec("1.2"));
+ TEST_CHECK_EQUAL(VersionSpec("1.2-r99").remove_revision(), VersionSpec("1.2"));
+ TEST_CHECK_EQUAL(VersionSpec("1.2-r3.4").remove_revision(), VersionSpec("1.2"));
}
} test_version_remove_revision;
@@ -217,6 +226,7 @@ namespace test_cases
TEST_CHECK_STRINGIFY_EQUAL(VersionSpec("1.2").revision_only(), "r0");
TEST_CHECK_STRINGIFY_EQUAL(VersionSpec("1.2-r").revision_only(), "r0");
TEST_CHECK_STRINGIFY_EQUAL(VersionSpec("1.2-r99").revision_only(), "r99");
+ TEST_CHECK_STRINGIFY_EQUAL(VersionSpec("1.2-r3.4").revision_only(), "r3.4");
}
} test_version_revision_only;
@@ -283,6 +293,9 @@ namespace test_cases
v.push_back(VersionSpec("1_alpha"));
v.push_back(VersionSpec("1_alpha10"));
v.push_back(VersionSpec("1_alpha10-r1"));
+ v.push_back(VersionSpec("1_alpha10-r1.0"));
+ v.push_back(VersionSpec("1_alpha10-r1.1"));
+ v.push_back(VersionSpec("1_alpha10-r2"));
v.push_back(VersionSpec("1_alpha10_p1"));
v.push_back(VersionSpec("1_alpha10_p1-r1"));
v.push_back(VersionSpec("1_alpha11"));
@@ -337,6 +350,7 @@ namespace test_cases
v.push_back(VersionSpec("2_alpha"));
v.push_back(VersionSpec("scm"));
v.push_back(VersionSpec("scm-r3"));
+ v.push_back(VersionSpec("scm-r3.4"));
std::vector<VersionSpec>::iterator v1(v.begin()), v_end(v.end());
for ( ; v1 != v_end ; ++v1)