#
# patch "ChangeLog"
# from [eb658f98166488e70a7f77d3b8083dbd1e80b561]
# to [eaaff738ed11962e325446589148f43180a24a9d]
#
# patch "commands.cc"
# from [1d3ffb053901c8cbdaae7aab407b213c5f2c9707]
# to [fe6b9b042986fa8f7b00c35a64034d94131b5954]
#
# patch "contrib/monotone.zsh_completion"
# from [b33e733138eb4fcf899d310e0fa4c850f03735f9]
# to [ab021dfed85eff74d530e395c9c3adbe760ccbe1]
#
# patch "database.cc"
# from [a59a347c6c190c09f42107d114045da78f942d4a]
# to [181e7b79e4435b2ffa1561ce8b9162a41563ed72]
#
# patch "database.hh"
# from [794783807386029f0a6d8067e2a7bb0eba88b0a2]
# to [402c6310d759c4934fc19ba823f2536ca3251d46]
#
# patch "monotone.texi"
# from [97d124d7ac72f65675b5c8187e7b1f65357302fc]
# to [8a9cd557db06ece0fc71ec40c31bb4d6c60c3ba8]
#
# patch "tests/t_rebuild.at"
# from [e3f4f08554861d111bc6c04483ad312398524880]
# to [68ad455c84d87ba7be00af45d8efbf0d67d803b0]
#
# patch "vocab.hh"
# from [9aa50b972ad3671eb3b0af85fec6227ff21f165e]
# to [77bb3d7df9abc7e4e5202cb20b313c925dad2c13]
#
# patch "vocab_terms.hh"
# from [2ac7518f6c9951c9335409298b21fcbe8ad76e27]
# to [5f62e709188e8b758c4ed51615580884cfd3b4e3]
#
--- ChangeLog
+++ ChangeLog
@@ -1,3 +1,15 @@
+2005-06-02 Joel Reed
+
+ * commands.cc, database.cc, database.hh, vocab.hh, vocab_terms.hh:
+ add complete key subcommand and provide --brief option of zsh/bash
+ completion. See http://lists.gnu.org/archive/html/monotone-devel/2005-05/msg00461.html
+ * tests/t_rebuild.at: add tests for complete key subcommand
+ * monotone.texi: document new subcommand
+ * contrib/monotone.zsh_completion: update for new complete key
+ command, improve _monotone_existing_entries using new --depth=0
+ option, add revision completion for cert command, and a bugfix
+ for cat command
+
2005-05-28 Joel Reed
* app_state.cc, app_state.hh, commands.cc, monotone.cc, options.h:
--- commands.cc
+++ commands.cc
@@ -3273,17 +3273,20 @@
P(F("[merged] %s\n") % merged);
}
-CMD(complete, "informative", "(revision|manifest|file) PARTIAL-ID",
+CMD(complete, "informative", "(revision|manifest|file|key) PARTIAL-ID",
"complete partial id",
- OPT_NONE)
+ OPT_BRIEF)
{
if (args.size() != 2)
throw usage(name);
+ bool brief = global_sanity.brief;
+
+ N(idx(args, 1)().find_first_not_of("abcdef0123456789") == string::npos,
+ F("non-hex digits in partial id"));
+
if (idx(args, 0)() == "revision")
{
- N(idx(args, 1)().find_first_not_of("abcdef0123456789") == string::npos,
- F("non-hex digits in partial id"));
set completions;
app.db.complete(idx(args, 1)(), completions);
for (set::const_iterator i = completions.begin();
@@ -3292,8 +3295,6 @@
}
else if (idx(args, 0)() == "manifest")
{
- N(idx(args, 1)().find_first_not_of("abcdef0123456789") == string::npos,
- F("non-hex digits in partial id"));
set completions;
app.db.complete(idx(args, 1)(), completions);
for (set::const_iterator i = completions.begin();
@@ -3302,14 +3303,25 @@
}
else if (idx(args, 0)() == "file")
{
- N(idx(args, 1)().find_first_not_of("abcdef0123456789") == string::npos,
- F("non-hex digits in partial id"));
set completions;
app.db.complete(idx(args, 1)(), completions);
for (set::const_iterator i = completions.begin();
i != completions.end(); ++i)
cout << i->inner()() << endl;
}
+ else if (idx(args, 0)() == "key")
+ {
+ typedef set< pair > completions_t;
+ completions_t completions;
+ app.db.complete(idx(args, 1)(), completions);
+ for (completions_t::const_iterator i = completions.begin();
+ i != completions.end(); ++i)
+ {
+ cout << i->first.inner()();
+ if (!brief) cout << " " << i->second();
+ cout << endl;
+ }
+ }
else
throw usage(name);
}
--- contrib/monotone.zsh_completion
+++ contrib/monotone.zsh_completion
@@ -94,13 +94,18 @@
compadd -- file manifest revision
else
local mtype="$words[2]"
- local id="$words[3]"
+ local id="$words[3]:gs/-//"
if (( $#id )); then
compadd -- $(monotone complete $mtype $id)
fi
fi
}
+(( $+functions[_monotone_cert] )) ||
+_monotone_cert() {
+ _monotone_revisions
+}
+
(( $+functions[_monotone_checkout] )) ||
_monotone_checkout() {
_arguments \
@@ -127,7 +132,7 @@
(( $+functions[_monotone_complete] )) ||
_monotone_complete() {
- compadd -- file manifest revision
+ compadd -- file key manifest revision
}
(( $+functions[_monotone_cvs_import] )) ||
@@ -278,7 +283,7 @@
(( $+functions[_monotone_existing_entries] )) ||
_monotone_existing_entries() {
- _path_files -F "$_monotone_ignore_default" -g "*"
+ for i in `monotone ls known --depth=0 .`; do compadd -- $i:t; done
}
(( $+functions[_monotone_branches] )) ||
--- database.cc
+++ database.cc
@@ -2136,6 +2136,30 @@
completions.insert(file_id(res[i][0]));
}
+void
+database::complete(string const & partial,
+ set< pair > & completions)
+{
+ results res;
+ completions.clear();
+
+ fetch(res, 2, any_rows,
+ "SELECT hash, id FROM public_keys WHERE hash GLOB '%q*'",
+ partial.c_str());
+
+ for (size_t i = 0; i < res.size(); ++i)
+ completions.insert(make_pair(key_id(res[i][0]), utf8(res[i][1])));
+
+ res.clear();
+
+ fetch(res, 2, any_rows,
+ "SELECT hash, id FROM private_keys WHERE hash GLOB '%q*'",
+ partial.c_str());
+
+ for (size_t i = 0; i < res.size(); ++i)
+ completions.insert(make_pair(key_id(res[i][0]), utf8(res[i][1])));
+}
+
using selectors::selector_type;
static void selector_to_certname(selector_type ty,
--- database.hh
+++ database.hh
@@ -415,6 +415,9 @@
void complete(std::string const & partial,
std::set & completions);
+ void complete(std::string const & partial,
+ std::set< std::pair > & completions);
+
void complete(selectors::selector_type ty,
std::string const & partial,
std::vector > revision_id;
typedef manifest< hexenc > manifest_id;
typedef file< hexenc > file_id;
+typedef key< hexenc > key_id;
typedef epoch< hexenc > epoch_id;
typedef epoch< hexenc > epoch_data;
--- vocab_terms.hh
+++ vocab_terms.hh
@@ -38,6 +38,7 @@
DECORATE(revision); // thing associated with a revision
DECORATE(manifest); // thing associated with a manifest
DECORATE(file); // thing associated with a file
+DECORATE(key); // thing associated with a key
DECORATE(epoch); // thing associated with an epoch
ENCODING(gzip); // thing which is gzipped
@@ -54,6 +55,7 @@
EXTERN template class revision< hexenc >;
EXTERN template class manifest< hexenc >;
EXTERN template class file< hexenc >;
+EXTERN template class key< hexenc >;
EXTERN template class epoch< hexenc >;
EXTERN template class hexenc;