monotone

monotone Commit Details

Date:2007-03-11 03:39:54 (12 years 3 months ago)
Author:Derek Scherger
Branch:net.venge.monotone.experiment.commands-with-dashes
Commit:fbd668d69b425adbe20370f8033a173392bcde23
Parents: 9d1c7404d9f04c5ecf8a546bf59321413192f796
Message: * cmd_automate.cc (automate::automate): replace underscores with

dashes in command names before insertion into the command map
(automate::find_automation): also search for automate commands
under their old names for backwards compatibility
* cmd_db.cc (db): replace underscores with dashes in db command
names
* commands.cc (command::command): replace underscores with dashes
in command names before insertion into the command map
* simplestring_xform.{cc,hh} (replace_underscores_with_dashes):
new function
Changes:
Mcmd_automate.cc (3 diffs)
Mcmd_db.cc (3 diffs)
Mcommands.cc (1 diff)
Msimplestring_xform.cc (2 diffs)
Msimplestring_xform.hh (1 diff)

File differences

cmd_automate.cc
1111
1212
1313
14
1415
1516
1617
......
3536
3637
3738
39
40
3841
3942
4043
......
4548
4649
4750
51
52
53
54
4855
56
57
58
59
60
61
4962
5063
5164
#include <map>
#include "cmd.hh"
#include "simplestring_xform.hh"
using std::istream;
using std::make_pair;
first = false;
automations = new map<string, automate * const>;
}
name = replace_underscores_with_dashes(name);
automations->insert(make_pair(name, this));
}
automate::~automate() {}
{
map<string, automation::automate * const>::const_iterator
i = automation::automations->find(name());
// maintain support for both _ and - style command names for a while
// FIXME: should we issue a warning about incorrect usage here?
if (i == automation::automations->end())
{
string other_name = replace_underscores_with_dashes(name);
i = automation::automations->find(other_name);
}
if (i == automation::automations->end())
throw usage(root_cmd_name);
else
return *(i->second);
cmd_db.cc
5151
5252
5353
54
55
56
54
55
56
5757
5858
5959
60
61
60
61
6262
6363
6464
......
8282
8383
8484
85
85
8686
8787
8888
......
9191
9292
9393
94
94
9595
96
96
9797
98
98
9999
100
100
101101
102102
103103
104104
105105
106106
107
107
108108
109109
110110
"load\n"
"migrate\n"
"execute\n"
"kill_rev_locally ID\n"
"kill_branch_certs_locally BRANCH\n"
"kill_tag_locally TAG\n"
"kill-rev-locally ID\n"
"kill-branch-certs-locally BRANCH\n"
"kill-tag-locally TAG\n"
"check\n"
"changesetify\n"
"rosterify\n"
"regenerate_caches\n"
"set_epoch BRANCH EPOCH\n"),
"regenerate-caches\n"
"set-epoch BRANCH EPOCH\n"),
N_("manipulate database state"),
options::opts::drop_attr)
{
build_changesets_from_manifest_ancestry(app);
else if (idx(args, 0)() == "rosterify")
build_roster_style_revs_from_manifest_style_revs(app);
else if (idx(args, 0)() == "regenerate_caches")
else if (idx(args, 0)() == "regenerate-caches")
regenerate_caches(app);
else
throw usage(name);
{
if (idx(args, 0)() == "execute")
app.db.debug(idx(args, 1)(), cout);
else if (idx(args, 0)() == "kill_rev_locally")
else if (idx(args, 0)() == "kill-rev-locally")
kill_rev_locally(app,idx(args, 1)());
else if (idx(args, 0)() == "clear_epoch")
else if (idx(args, 0)() == "clear-epoch")
app.db.clear_epoch(branch_name(idx(args, 1)()));
else if (idx(args, 0)() == "kill_branch_certs_locally")
else if (idx(args, 0)() == "kill-branch-certs-locally")
app.db.delete_branch_named(cert_value(idx(args, 1)()));
else if (idx(args, 0)() == "kill_tag_locally")
else if (idx(args, 0)() == "kill-tag-locally")
app.db.delete_tag_named(cert_value(idx(args, 1)()));
else
throw usage(name);
}
else if (args.size() == 3)
{
if (idx(args, 0)() == "set_epoch")
if (idx(args, 0)() == "set-epoch")
{
epoch_data ed(idx(args,2)());
N(ed.inner()().size() == constants::epochlen,
commands.cc
7474
7575
7676
77
77
78
79
80
7881
7982
8083
{
if (cmds == NULL)
cmds = new map<string, command *>;
(*cmds)[n] = this;
name = replace_underscores_with_dashes(name);
(*cmds)[name] = this;
}
command::~command() {}
std::string command::params() {return safe_gettext(params_.c_str());}
simplestring_xform.cc
185185
186186
187187
188
189
190
191
192
193
194
195
196
197
198
199
200
188201
189202
190203
......
230243
231244
232245
246
247
248
249
250
251
233252
234253
235254
return tmp;
}
string
replace_underscores_with_dashes(string const & s)
{
string tmp = s;
string::size_type loc = tmp.find("_");
while (loc != string::npos)
{
tmp.replace(loc, 1, "-");
loc = tmp.find("_");
}
return tmp;
}
#ifdef BUILD_UNIT_TESTS
#include "unit_tests.hh"
#include <stdlib.h>
== "Ilikegoingforwalks");
}
UNIT_TEST(simplestring_xform, replace_underscores_with_dashes)
{
BOOST_CHECK(replace_underscores_with_dashes("this_is_a_test") == "this-is-a-test");
BOOST_CHECK(replace_underscores_with_dashes("nothing to do") == "nothing to do");
}
#endif // BUILD_UNIT_TESTS
// Local Variables:
simplestring_xform.hh
3434
3535
3636
37
38
3739
3840
3941
// remove leading and trailing whitespace
std::string trim_ws(std::string const & s);
std::string replace_underscores_with_dashes(std::string const & s);
// Local Variables:
// mode: C++
// fill-column: 76

Archive Download the corresponding diff file

Branches

Tags

Quick Links:     www.monotone.ca    -     Downloads    -     Documentation    -     Wiki    -     Code Forge    -     Build Status