hi,
(the harddrive of my ibook just crashed)
here's a possible fix for this bug : i've added ticker::id to store the
unique identifier of each ticker. using N_() then _() would be another
solution, but i think it would be harmful to do so. That's why i stored
id and name seperately. ticker::id gets initialized with a
locale-independant string. As i've added ticker::id, i've turned the
tickers set from map<string, ticker*> to set<ticker*> which make more
sense. Notice that ticker::id and tickers as a set are only used for
sanity checks.
I was also able to spot new candidate for i18n as i changed ticker
constructor.
fine ?
#
# old_revision [4f7f638954c79c54460d04c3be111acad8b26dd3]
#
# patch "database.cc"
# from [83c0e4fe4b672da030bc50966c118ac0c2c98017]
# to [eca3bf665e2f89c8dc96d2180f3a5172017a74c7]
#
# patch "database_check.cc"
# from [c6145a7b639d6a67fd63c3816af36e67ada5144b]
# to [1f3a963d32b31f34d5e9c44db61a83275e0a103d]
#
# patch "netsync.cc"
# from [e1c2726ff08eb0cc2c7a40cb5b391517d4f2fa95]
# to [d62b20a42360e02d02e6bea04c64e93e7f54c080]
#
# patch "rcs_import.cc"
# from [e01d4dc824657c684430fdf98d0132a1298f10d3]
# to [7d0d9e0c77225acc87f117c4411e9b5f1866305a]
#
# patch "revision.cc"
# from [278be7ae9f1e835cf402808d651e5a1d1a49d72f]
# to [cb585924f450e19059a826f80a735a328ce06728]
#
# patch "ui.cc"
# from [77a48bddc373a115f5ec6cc0077afa17a2a762d0]
# to [615b532a26a8e38ba003f85dccb762b1b8b6024a]
#
# patch "ui.hh"
# from [d5866bba3cc59b130fb56ba40e0780801d4314f9]
# to [d82b0e08d8307292275cc8b382eb56802728f567]
#
============================================================
--- database.cc 83c0e4fe4b672da030bc50966c118ac0c2c98017
+++ database.cc eca3bf665e2f89c8dc96d2180f3a5172017a74c7
@@ -480,9 +480,9 @@
database::rehash()
{
transaction_guard guard(*this);
- ticker mcerts(_("mcerts"), "m", 1);
- ticker pubkeys(_("pubkeys"), "+", 1);
- ticker privkeys(_("privkeys"), "!", 1);
+ ticker mcerts("mcerts", _("mcerts"), "m", 1);
+ ticker pubkeys("pubkeys", _("pubkeys"), "+", 1);
+ ticker privkeys("privkeys", _("privkeys"), "!", 1);
{
// rehash all mcerts
============================================================
--- database_check.cc c6145a7b639d6a67fd63c3816af36e67ada5144b
+++ database_check.cc 1f3a963d32b31f34d5e9c44db61a83275e0a103d
@@ -108,7 +108,7 @@
app.db.get_file_ids(files);
L(F("checking %d files\n") % files.size());
- ticker ticks(_("files"), "f", files.size()/70+1);
+ ticker ticks("files", _("files"), "f", files.size()/70+1);
for (std::set<file_id>::const_iterator i = files.begin();
i != files.end(); ++i)
@@ -133,7 +133,7 @@
app.db.get_manifest_ids(manifests);
L(F("checking %d manifests\n") % manifests.size());
- ticker ticks(_("manifests"), "m", manifests.size()/70+1);
+ ticker ticks("manifests", _("manifests"), "m", manifests.size()/70+1);
for (std::set<manifest_id>::const_iterator i = manifests.begin();
i != manifests.end(); ++i)
@@ -189,7 +189,7 @@
app.db.get_revision_ids(revisions);
L(F("checking %d revisions\n") % revisions.size());
- ticker ticks(_("revisions"), "r", revisions.size()/70+1);
+ ticker ticks("revisions", _("revisions"), "r", revisions.size()/70+1);
for (std::set<revision_id>::const_iterator i = revisions.begin();
i != revisions.end(); ++i)
@@ -288,7 +288,7 @@
app.db.get_revision_ancestry(graph);
L(F("checking %d ancestry edges\n") % graph.size());
- ticker ticks(_("ancestry"), "a", graph.size()/70+1);
+ ticker ticks("ancestry", _("ancestry"), "a", graph.size()/70+1);
// checked revision has set of parents
// graph has revision and associated parents
@@ -321,7 +321,7 @@
L(F("checking %d public keys\n") % pubkeys.size());
- ticker ticks(_("keys"), "k", 1);
+ ticker ticks("keys", _("keys"), "k", 1);
for (std::vector<rsa_keypair_id>::const_iterator i = pubkeys.begin();
i != pubkeys.end(); ++i)
@@ -347,7 +347,7 @@
L(F("checking %d revision certs\n") % certs.size());
- ticker ticks(_("certs"), "c", certs.size()/70+1);
+ ticker ticks("certs", _("certs"), "c", certs.size()/70+1);
for (std::vector< revision<cert> >::const_iterator i = certs.begin();
i != certs.end(); ++i)
@@ -377,7 +377,7 @@
{
L(F("checking local history of %d revisions\n") % checked_revisions.size());
- ticker ticks(_("revisions"), "r", 1);
+ ticker ticks("revisions", _("revisions"), "r", 1);
for (std::map<revision_id, checked_revision>::iterator
i = checked_revisions.begin(); i != checked_revisions.end(); ++i)
============================================================
--- netsync.cc e1c2726ff08eb0cc2c7a40cb5b391517d4f2fa95
+++ netsync.cc d62b20a42360e02d02e6bea04c64e93e7f54c080
@@ -658,34 +658,34 @@
session::setup_client_tickers()
{
// xgettext: please use short message and try to avoid multibytes chars
- byte_in_ticker.reset(new ticker(N_("bytes in"), ">", 1024, true));
+ byte_in_ticker.reset(new ticker("bytes in", _("bytes in"), ">", 1024, true));
// xgettext: please use short message and try to avoid multibytes chars
- byte_out_ticker.reset(new ticker(N_("bytes out"), "<", 1024, true));
+ byte_out_ticker.reset(new ticker("bytes out", _("bytes out"), "<", 1024, true));
if (role == sink_role)
{
// xgettext: please use short message and try to avoid multibytes chars
- revision_checked_ticker.reset(new ticker(N_("revs written"), "w", 1));
+ revision_checked_ticker.reset(new ticker("revs written", _("revs written"), "w", 1));
// xgettext: please use short message and try to avoid multibytes chars
- cert_in_ticker.reset(new ticker(N_("certs in"), "c", 3));
+ cert_in_ticker.reset(new ticker("certs in", _("certs in"), "c", 3));
// xgettext: please use short message and try to avoid multibytes chars
- revision_in_ticker.reset(new ticker(N_("revs in"), "r", 1));
+ revision_in_ticker.reset(new ticker("revs in", _("revs in"), "r", 1));
}
else if (role == source_role)
{
// xgettext: please use short message and try to avoid multibytes chars
- cert_out_ticker.reset(new ticker(N_("certs out"), "C", 3));
+ cert_out_ticker.reset(new ticker("certs out", _("certs out"), "C", 3));
// xgettext: please use short message and try to avoid multibytes chars
- revision_out_ticker.reset(new ticker(N_("revs out"), "R", 1));
+ revision_out_ticker.reset(new ticker("revs out", _("revs out"), "R", 1));
}
else
{
I(role == source_and_sink_role);
// xgettext: please use short message and try to avoid multibytes chars
- revision_checked_ticker.reset(new ticker(N_("revs written"), "w", 1));
+ revision_checked_ticker.reset(new ticker("revs written", _("revs written"), "w", 1));
// xgettext: please use short message and try to avoid multibytes chars
- revision_in_ticker.reset(new ticker(N_("revs in"), "r", 1));
+ revision_in_ticker.reset(new ticker("revs in", _("revs in"), "r", 1));
// xgettext: please use short message and try to avoid multibytes chars
- revision_out_ticker.reset(new ticker(N_("revs out"), "R", 1));
+ revision_out_ticker.reset(new ticker("revs out", _("revs out"), "R", 1));
}
}
@@ -3685,11 +3685,11 @@
boost::shared_ptr<merkle_table> etab = make_root_node(*this, epoch_item);
// xgettext: please use short message and try to avoid multibytes chars
- ticker revisions_ticker(_("revisions"), "r", 64);
+ ticker revisions_ticker("revisions", _("revisions"), "r", 64);
// xgettext: please use short message and try to avoid multibytes chars
- ticker certs_ticker(_("certs"), "c", 256);
+ ticker certs_ticker("certs", _("certs"), "c", 256);
// xgettext: please use short message and try to avoid multibytes chars
- ticker keys_ticker(_("keys"), "k", 1);
+ ticker keys_ticker("keys", _("keys"), "k", 1);
set<revision_id> revision_ids;
set<rsa_keypair_id> inserted_keys;
============================================================
--- rcs_import.cc e01d4dc824657c684430fdf98d0132a1298f10d3
+++ rcs_import.cc 7d0d9e0c77225acc87f117c4411e9b5f1866305a
@@ -761,8 +761,8 @@
}
cvs_history::cvs_history() :
- n_versions("versions", "v", 1),
- n_tree_branches("branches", "b", 1)
+ n_versions("versions", _("versions"), "v", 1),
+ n_tree_branches("branches", _("branches"), "b", 1)
{
}
@@ -1255,8 +1255,8 @@
I(cvs.stk.size() == 1);
- ticker n_revs(_("revisions"), "r", 1);
- ticker n_manifests(_("manifests"), "m", 1);
+ ticker n_revs("revisions", _("revisions"), "r", 1);
+ ticker n_manifests("manifests", _("manifests"), "m", 1);
while (cvs.branches.size() > 0)
{
@@ -1281,7 +1281,7 @@
// now we have a "last" rev for each tag
{
- ticker n_tags(_("tags"), "t", 1);
+ ticker n_tags("tags", _("tags"), "t", 1);
packet_db_writer dbw(app);
transaction_guard guard(app.db);
for (map<unsigned long, pair<time_t, revision_id> >::const_iterator i = cvs.resolved_tags.begin();
============================================================
--- revision.cc 278be7ae9f1e835cf402808d651e5a1d1a49d72f
+++ revision.cc cb585924f450e19059a826f80a735a328ce06728
@@ -1124,10 +1124,10 @@
existing_graph(existing),
app(a),
max_node(0),
- n_nodes("nodes", "n", 1),
- n_certs_in("certs in", "c", 1),
- n_revs_out("revs out", "r", 1),
- n_certs_out("certs out", "C", 1)
+ n_nodes("nodes", _("nodes"), "n", 1),
+ n_certs_in("certs in", _("certs in"), "c", 1),
+ n_revs_out("revs out", _("revs out"), "r", 1),
+ n_certs_out("certs out", _("certs out"), "C", 1)
{}
bool existing_graph;
============================================================
--- ui.cc 77a48bddc373a115f5ec6cc0077afa17a2a762d0
+++ ui.cc 615b532a26a8e38ba003f85dccb762b1b8b6024a
@@ -23,33 +23,34 @@
using boost::lexical_cast;
struct user_interface ui;
-ticker::ticker(string const & tickname, std::string const & s, size_t mod,
- bool kilocount) :
+ticker::ticker(string const & an_id, string const & tickname,
+ std::string const & s, size_t mod, bool kilocount) :
ticks(0),
mod(mod),
kilocount(kilocount),
+ id(an_id),
name(tickname),
shortname(s)
{
- I(ui.tickers.find(tickname) == ui.tickers.end());
- ui.tickers.insert(make_pair(tickname,this));
+ I(not is_registred());
+ ui.tickers.insert(this);
}
ticker::~ticker()
{
- I(ui.tickers.find(name) != ui.tickers.end());
+ I(is_registred());
if (ui.some_tick_is_dirty)
{
ui.write_ticks();
}
- ui.tickers.erase(name);
+ ui.tickers.erase(this);
ui.finish_ticking();
}
void
ticker::operator++()
{
- I(ui.tickers.find(name) != ui.tickers.end());
+ I(is_registred());
ticks++;
ui.some_tick_is_dirty = true;
if (ticks % mod == 0)
@@ -59,7 +60,7 @@
void
ticker::operator+=(size_t t)
{
- I(ui.tickers.find(name) != ui.tickers.end());
+ I(is_registred());
size_t old = ticks;
ticks += t;
@@ -71,7 +72,13 @@
}
}
+bool
+ticker::is_registred()
+{
+ return ui.tickers.find(this) != ui.tickers.end();
+}
+
tick_write_count::tick_write_count() : last_tick_len(0)
{
}
@@ -90,29 +97,31 @@
unsigned int width;
unsigned int minwidth = 7;
- for (map<string,ticker *>::const_iterator i = ui.tickers.begin();
+ for (set<ticker *>::const_iterator i = ui.tickers.begin();
i != ui.tickers.end(); ++i)
{
- width = 1 + length(utf8(i->second->name));
+ ticker * const t(*i);
+
+ width = 1 + length(utf8(t->name));
if (!first_tick)
{
tickline1 += " | ";
tickline2 += " |";
}
first_tick = false;
- if (length(utf8(i->second->name)) < minwidth)
+ if (length(utf8(t->name)) < minwidth)
{
- tickline1.append(minwidth - length(utf8(i->second->name)),' ');
- width += minwidth - length(utf8(i->second->name));
+ tickline1.append(minwidth - length(utf8(t->name)),' ');
+ width += minwidth - length(utf8(t->name));
}
- tickline1 += i->second->name;
+ tickline1 += t->name;
string count;
- if (i->second->kilocount && i->second->ticks >= 10000)
+ if (t->kilocount && t->ticks >= 10000)
{ // automatic unit conversion is enabled
float div;
const char *message;
- if (i->second->ticks >= 1048576) {
+ if (t->ticks >= 1048576) {
// ticks >=1MB, use Mb
div = 1048576;
// xgettext: mebibytes (2^20 bytes)
@@ -124,13 +133,13 @@
message = N_("%.1f k");
}
// we reset the mod to the divider, to avoid spurious screen updates
- i->second->mod = static_cast<int>(div / 10.0);
- count = (F(message) % (i->second->ticks / div)).str();
+ t->mod = static_cast<int>(div / 10.0);
+ count = (F(message) % (t->ticks / div)).str();
}
else
{
// xgettext: bytes
- count = (F("%d") % i->second->ticks).str();
+ count = (F("%d") % t->ticks).str();
}
if (length(utf8(count)) < width)
@@ -213,10 +222,11 @@
chars_on_line = tickline_prefix.size();
}
- for (map<string,ticker *>::const_iterator i = ui.tickers.begin();
+ for (set<ticker *>::const_iterator i = ui.tickers.begin();
i != ui.tickers.end(); ++i)
{
- map<string,size_t>::const_iterator old = last_ticks.find(i->first);
+ ticker * const t(*i);
+ map<string,size_t>::const_iterator old = last_ticks.find(t->id);
if (!ui.last_write_was_a_tick)
{
@@ -224,27 +234,28 @@
tickline1 += ", ";
tickline1 +=
- i->second->shortname + "=\"" + i->second->name + "\""
- + "/" + lexical_cast<string>(i->second->mod);
+ t->shortname + "=\"" + t->name + "\""
+ + "/" + lexical_cast<string>(t->mod);
first_tick = false;
}
if (old == last_ticks.end()
- || ((i->second->ticks / i->second->mod)
- > (old->second / i->second->mod)))
+ || ((t->ticks / t->mod)
+ > (old->second / t->mod)))
{
- chars_on_line += i->second->shortname.size();
+ chars_on_line += t->shortname.size();
if (chars_on_line > guess_terminal_width())
{
- chars_on_line = tickline_prefix.size() + i->second->shortname.size();
+ chars_on_line = tickline_prefix.size() + t->shortname.size();
tickline2 += "\n" + tickline_prefix;
}
- tickline2 += i->second->shortname;
+ tickline2 += t->shortname;
+ // uhuh ?
if (old == last_ticks.end())
- last_ticks.insert(make_pair(i->first, i->second->ticks));
+ last_ticks.insert(make_pair(t->id, t->ticks));
else
- last_ticks[i->first] = i->second->ticks;
+ last_ticks[t->id] = t->ticks;
}
}
============================================================
--- ui.hh d5866bba3cc59b130fb56ba40e0780801d4314f9
+++ ui.hh d82b0e08d8307292275cc8b382eb56802728f567
@@ -22,15 +22,30 @@
size_t ticks;
size_t mod;
bool kilocount;
+ std::string id;
std::string name;
std::string shortname;
- ticker(std::string const & n, std::string const & s, size_t mod = 64,
- bool kilocount=false);
+ ticker(std::string const & id, std::string const & n, std::string const & s,
+ size_t mod = 64, bool kilocount=false);
void operator++();
void operator+=(size_t t);
~ticker();
+
+private:
+ bool is_registred();
};
+
+struct ticker_pointer_less
+ : std::binary_function<const ticker *, const ticker *, bool>
+{
+ bool operator()(const ticker * a, const ticker * b)
+ {
+ return a->id < b->id;
+ }
+};
+
+
struct tick_writer
{
public:
@@ -92,7 +107,7 @@
bool some_tick_is_dirty; // At least one tick needs being printed
bool last_write_was_a_tick;
- std::map<std::string,ticker *> tickers;
+ std::set<ticker *, ticker_pointer_less> tickers;
tick_writer * t_writer;
void finish_ticking();
void write_ticks();
_______________________________________________
Monotone-devel mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/monotone-devel