#
#
# patch "README.encapsulation"
# from [81555580c9b40db3faef6b87b7b8f22db72497ed]
# to [d63c17db209a20f78658c05b8603b3442e1e9f44]
#
# patch "app_state.cc"
# from [ffe7d555550ba0029a88e3e0fcfdfe99c1a8720b]
# to [78ac6b932a119c05d7d33a0d1011d12757823d9e]
#
# patch "database.cc"
# from [b3ff574bbebad8a628f87459e9de14acba9a294c]
# to [47aae9a254bc67828dceb1bc9be193d3f5532af8]
#
# patch "database.hh"
# from [2513527037de44588eefe36d85a59a5d6295304f]
# to [92d2d29ac6ed71da95852b9eeea7603311596456]
#
# patch "project.cc"
# from [c470df10a4d213a27b64ec1caf26bf2703a025e7]
# to [27d36f643bcc35d6e03931302452f5fdab8725d6]
#
# patch "project.hh"
# from [5da24a7e4b1f31ec1e36a351aab0047123aebc2b]
# to [2540b2bb2780590d3f23f31daf6ecc145b8f8f07]
#
============================================================
--- README.encapsulation 81555580c9b40db3faef6b87b7b8f22db72497ed
+++ README.encapsulation d63c17db209a20f78658c05b8603b3442e1e9f44
@@ -109,9 +109,7 @@ netsync.cc:
app.db...
app.opts.keys_to_push()
app.keys.key_pair_exists()
- app.keys.ensure_in_database()
-
- run_netsync_protocol():
+ app.keys.ensure_in_database()_netsync_protocol():
app.opts.bind_stdio
@@ -119,15 +117,7 @@ keys.cc:
Only a unit test left, which uses app_state. This should be cleaned
up as soon as we remove the hackish hooks in the key_store.
-project.cc:
- project_t:
- app.db...
- app.opts.date
- app.opts.author
-
-
-
cmd_diff_log.cc:
CMD(diff:
@@ -148,7 +138,3 @@ cmd_diff_log.cc:
needs: complete()
-
-
-next candidates for app_state removal:
- project.cc: struct project_t
============================================================
--- app_state.cc ffe7d555550ba0029a88e3e0fcfdfe99c1a8720b
+++ app_state.cc 78ac6b932a119c05d7d33a0d1011d12757823d9e
@@ -40,7 +40,7 @@ app_state::app_state()
// search_root(current_root_path()),
// diff_format(unified_diff),
branch_is_sticky(false),
- project(*this)
+ project(db)
{
db.set_app(this);
lua.set_app(this);
============================================================
--- database.cc b3ff574bbebad8a628f87459e9de14acba9a294c
+++ database.cc 47aae9a254bc67828dceb1bc9be193d3f5532af8
@@ -27,6 +27,7 @@
#include "cert.hh"
#include "cleanup.hh"
#include "constants.hh"
+#include "dates.hh"
#include "database.hh"
#include "hash_map.hh"
#include "keys.hh"
@@ -3446,6 +3447,22 @@ database::must_drop_attr(string const &
__app->opts.attrs_to_drop.end());
}
+utf8 const &
+database::get_opt_author()
+{
+ return __app->opts.author;
+}
+
+date_t const
+database::get_opt_date_or_cur_date()
+{
+ if (__app->opts.date_given)
+ return __app->opts.date;
+ else
+ return date_t::now();
+}
+
+
// transaction guards
transaction_guard::transaction_guard(database & d, bool exclusive,
============================================================
--- database.hh 2513527037de44588eefe36d85a59a5d6295304f
+++ database.hh 92d2d29ac6ed71da95852b9eeea7603311596456
@@ -77,6 +77,7 @@ class rev_height;
struct revision_t;
struct query;
class rev_height;
+struct date_t;
class database
{
@@ -601,6 +602,9 @@ public:
std::string & author);
bool must_drop_attr(std::string const & key);
+ utf8 const & get_opt_author();
+ date_t const get_opt_date_or_cur_date();
+
key_store & get_key_store();
};
============================================================
--- project.cc c470df10a4d213a27b64ec1caf26bf2703a025e7
+++ project.cc 27d36f643bcc35d6e03931302452f5fdab8725d6
@@ -1,10 +1,10 @@
// 2007 Timothy Brownawell
// GNU GPL V2 or later
#include
-#include "app_state.hh"
#include "cert.hh"
+#include "database.hh"
#include "project.hh"
#include "revision.hh"
#include "transforms.hh"
@@ -13,8 +13,8 @@ using std::vector;
using std::set;
using std::vector;
-project_t::project_t(app_state & app)
- : app(app)
+project_t::project_t(database & db)
+ : db(db)
{}
void
@@ -23,7 +23,7 @@ project_t::get_branch_list(std::set got;
- indicator = app.db.get_branches(got);
+ indicator = db.get_branches(got);
branches.clear();
for (std::vector::iterator i = got.begin();
i != got.end(); ++i)
@@ -40,7 +40,7 @@ project_t::get_branch_list(globish const
std::set & names)
{
std::vector got;
- app.db.get_branches(glob(), got);
+ db.get_branches(glob(), got);
names.clear();
for (std::vector::iterator i = got.begin();
i != got.end(); ++i)
@@ -83,12 +83,12 @@ project_t::get_branch_heads(branch_name
encode_base64(cert_value(name()), branch_encoded);
outdated_indicator stamp;
- branch.first = app.db.get_revisions_with_cert(cert_name(branch_cert_name),
+ branch.first = db.get_revisions_with_cert(cert_name(branch_cert_name),
branch_encoded,
branch.second);
- not_in_branch p(app.db, branch_encoded);
- erase_ancestors_and_failures(branch.second, p, app.db);
+ not_in_branch p(db, branch_encoded);
+ erase_ancestors_and_failures(branch.second, p, db);
L(FL("found heads of branch %s (%s heads)")
% name % branch.second.size());
}
@@ -103,11 +103,11 @@ project_t::revision_is_in_branch(revisio
encode_base64(cert_value(branch()), branch_encoded);
vector > certs;
- app.db.get_revision_certs(id, branch_cert_name, branch_encoded, certs);
+ db.get_revision_certs(id, branch_cert_name, branch_encoded, certs);
int num = certs.size();
- erase_bogus_certs(certs, app.db);
+ erase_bogus_certs(certs, db);
L(FL("found %d (%d valid) %s branch certs on revision %s")
% num
@@ -122,7 +122,7 @@ project_t::put_revision_in_branch(revisi
project_t::put_revision_in_branch(revision_id const & id,
branch_name const & branch)
{
- cert_revision_in_branch(id, branch, app.db);
+ cert_revision_in_branch(id, branch, db);
}
@@ -130,14 +130,14 @@ project_t::get_revision_cert_hashes(revi
project_t::get_revision_cert_hashes(revision_id const & rid,
std::vector > & hashes)
{
- return app.db.get_revision_certs(rid, hashes);
+ return db.get_revision_certs(rid, hashes);
}
outdated_indicator
project_t::get_revision_certs(revision_id const & id,
std::vector > & certs)
{
- return app.db.get_revision_certs(id, certs);
+ return db.get_revision_certs(id, certs);
}
outdated_indicator
@@ -145,8 +145,8 @@ project_t::get_revision_certs_by_name(re
cert_name const & name,
std::vector > & certs)
{
- outdated_indicator i = app.db.get_revision_certs(id, name, certs);
- erase_bogus_certs(certs, app.db);
+ outdated_indicator i = db.get_revision_certs(id, name, certs);
+ erase_bogus_certs(certs, db);
return i;
}
@@ -174,7 +174,7 @@ project_t::get_branch_certs(branch_name
base64 branch_encoded;
encode_base64(cert_value(branch()), branch_encoded);
- return app.db.get_revision_certs(branch_cert_name, branch_encoded, certs);
+ return db.get_revision_certs(branch_cert_name, branch_encoded, certs);
}
tag_t::tag_t(revision_id const & ident,
@@ -205,8 +205,8 @@ project_t::get_tags(set & tags)
project_t::get_tags(set & tags)
{
std::vector > certs;
- outdated_indicator i = app.db.get_revision_certs(tag_cert_name, certs);
- erase_bogus_certs(certs, app.db);
+ outdated_indicator i = db.get_revision_certs(tag_cert_name, certs);
+ erase_bogus_certs(certs, db);
tags.clear();
for (std::vector >::const_iterator i = certs.begin();
i != certs.end(); ++i)
@@ -222,7 +222,7 @@ project_t::put_tag(revision_id const & i
project_t::put_tag(revision_id const & id,
string const & name)
{
- cert_revision_tag(id, name, app.db);
+ cert_revision_tag(id, name, db);
}
@@ -233,13 +233,13 @@ project_t::put_standard_certs(revision_i
date_t const & time,
utf8 const & author)
{
- cert_revision_in_branch(id, branch, app.db);
- cert_revision_changelog(id, changelog, app.db);
- cert_revision_date_time(id, time, app.db);
+ cert_revision_in_branch(id, branch, db);
+ cert_revision_changelog(id, changelog, db);
+ cert_revision_date_time(id, time, db);
if (!author().empty())
- cert_revision_author(id, author(), app.db);
+ cert_revision_author(id, author(), db);
else
- cert_revision_author_default(id, app.db);
+ cert_revision_author_default(id, db);
}
void
@@ -250,15 +250,15 @@ project_t::put_standard_certs_from_optio
put_standard_certs(id,
branch,
changelog,
- app.opts.date_given ? app.opts.date : date_t::now(),
- app.opts.author);
+ db.get_opt_date_or_cur_date(),
+ db.get_opt_author());
}
void
project_t::put_cert(revision_id const & id,
cert_name const & name,
cert_value const & value)
{
- put_simple_revision_cert(id, name, value, app.db);
+ put_simple_revision_cert(id, name, value, db);
}
============================================================
--- project.hh 5da24a7e4b1f31ec1e36a351aab0047123aebc2b
+++ project.hh 2540b2bb2780590d3f23f31daf6ecc145b8f8f07
@@ -12,7 +12,7 @@
#include "outdated_indicator.hh"
#include "vocab.hh"
-class app_state;
+class database;
class tag_t
{
@@ -26,13 +26,13 @@ class project_t
class project_t
{
- app_state & app;
+ database & db;
std::map > > branch_heads;
std::set branches;
outdated_indicator indicator;
public:
- project_t(app_state & app);
+ project_t(database & db);
void get_branch_list(std::set & names);
void get_branch_list(globish const & glob, std::set & names);