aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2021-09-23 20:51:45 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2021-09-24 11:27:09 +0300
commitfa002aac4c3cb75722d973d199a73231062b890c (patch)
treeb09d44844bae7528d63689dfaf7e46d4b668733c
parent3f86fb3b73731f680bcffda83e4dddb6914eb13a (diff)
Make database ordering consistent across runs
-rw-r--r--bpkg/database.cxx8
-rw-r--r--bpkg/database.hxx7
-rw-r--r--bpkg/package.cxx7
-rw-r--r--bpkg/package.hxx8
-rw-r--r--bpkg/types.hxx10
-rw-r--r--tests/pkg-build.testscript2
6 files changed, 29 insertions, 13 deletions
diff --git a/bpkg/database.cxx b/bpkg/database.cxx
index 451ade3..aec3459 100644
--- a/bpkg/database.cxx
+++ b/bpkg/database.cxx
@@ -1074,4 +1074,12 @@ namespace bpkg
{
return *this == main_database ();
}
+
+ // compare_lazy_ptr
+ //
+ bool compare_lazy_ptr::
+ less (const odb::database& x, const odb::database& y) const
+ {
+ return static_cast<const database&> (x) < static_cast<const database&> (y);
+ }
}
diff --git a/bpkg/database.hxx b/bpkg/database.hxx
index 889f8a0..c9ef590 100644
--- a/bpkg/database.hxx
+++ b/bpkg/database.hxx
@@ -518,10 +518,11 @@ namespace bpkg
inline bool
operator< (const database& x, const database& y)
{
- // Note that if we ever need the ordering to be consistent across runs,
- // then we can compare the config paths or uuids.
+ // Note that we used to compare the database addresses here (as for the
+ // equality operator) until we needed the database ordering to be
+ // consistent across runs (to support --rebuild-checksum, etc).
//
- return &x < &y;
+ return x.config < y.config;
}
inline ostream&
diff --git a/bpkg/package.cxx b/bpkg/package.cxx
index 894051a..9a8068c 100644
--- a/bpkg/package.cxx
+++ b/bpkg/package.cxx
@@ -60,6 +60,13 @@ namespace bpkg
return !s.empty () ? name.string () + ' ' + s : name.string ();
}
+ bool config_package::
+ operator< (const config_package& v) const
+ {
+ int r (name.compare (v.name));
+ return r != 0 ? (r < 0) : (db < v.db);
+ }
+
// available_package
//
const version* available_package::
diff --git a/bpkg/package.hxx b/bpkg/package.hxx
index 13efcd4..9a42f62 100644
--- a/bpkg/package.hxx
+++ b/bpkg/package.hxx
@@ -1370,13 +1370,7 @@ namespace bpkg
}
bool
- operator< (const config_package& v) const
- {
- // See operator==(database, database).
- //
- int r (name.compare (v.name));
- return r != 0 ? (r < 0) : (&db < &v.db);
- }
+ operator< (const config_package&) const;
std::string
string () const;
diff --git a/bpkg/types.hxx b/bpkg/types.hxx
index d8ffa79..8f6d9df 100644
--- a/bpkg/types.hxx
+++ b/bpkg/types.hxx
@@ -180,9 +180,15 @@ namespace bpkg
//
return x.object_id () != y.object_id ()
? (x.object_id () < y.object_id ())
- : (&static_cast<typename P::base_type> (x).database () <
- &static_cast<typename P::base_type> (y).database ());
+ : less (static_cast<typename P::base_type> (x).database (),
+ static_cast<typename P::base_type> (y).database ());
}
+
+ private:
+ // Defined in database.cxx.
+ //
+ bool
+ less (const odb::database&, const odb::database&) const;
};
// Compare two lazy pointers via the pointed-to object ids.
diff --git a/tests/pkg-build.testscript b/tests/pkg-build.testscript
index 13f63c8..4da7747 100644
--- a/tests/pkg-build.testscript
+++ b/tests/pkg-build.testscript
@@ -6225,7 +6225,7 @@ else
y
EOI
% new libbaz/1.0.0 \[cfg.\] \(required by foo \[cfg.\]\)%
- % new libbuild2-bar/1.0.0 \[cfg3.\] \(required by (foo \[cfg2.\], foo \[cfg.\]\)|foo \[cfg.\], foo \[cfg2.\]\))%
+ % new libbuild2-bar/1.0.0 \[cfg3.\] \(required by foo \[cfg.\], foo \[cfg2.\]\)%
% new foo/1.0.0 \[cfg.\]%
% new libbaz/1.0.0 \[cfg2.\] \(required by foo \[cfg2.\]\)%
% new foo/1.0.0 \[cfg2.\]%