#
# patch "ChangeLog"
# from [43b0449780bad0e10e2c99acece0f6c62b3f1486]
# to [ee91d46179bc8840666957153affde72c853e587]
#
# patch "database.cc"
# from [ce32421c060f79d8de74419e4d9249fee7da236b]
# to [7700f558782068baadcacb73f7623ad2b7933456]
#
# patch "monotone.texi"
# from [c2ec4ec3f9a87edc9c10b100835c3bbef269253f]
# to [ad41028e3431d1b52cf14e03eb22d73e54fbab24]
#
# patch "selectors.cc"
# from [af2e5813aba3cdf936fbcbb31dbb05ddf3690ccc]
# to [7ae313b2c960a3f68e40a68db0f883bd48b59ac3]
#
# patch "selectors.hh"
# from [54ed172da5c3a3c4721152012d831f51e693cab9]
# to [ef621e16abcf9bc95e46c55a999158f8b3c73d32]
#
========================================================================
--- ChangeLog 43b0449780bad0e10e2c99acece0f6c62b3f1486
+++ ChangeLog ee91d46179bc8840666957153affde72c853e587
@@ -1,3 +1,10 @@
+2005-10-13 Emile Snyder
+
+ * database.cc (complete): implementation for h:branch selector to
+ find heads of a branch.
+ * selectors.{cc,hh}: add sel_head with selector character 'h'.
+ * monotone.texi: document it.
+
2005-10-13 Matt Johnston
* botan/mem_pool.cpp: fix bug preventing remove_empty_buffers()
========================================================================
--- database.cc ce32421c060f79d8de74419e4d9249fee7da236b
+++ database.cc 7700f558782068baadcacb73f7623ad2b7933456
@@ -2027,6 +2027,10 @@
prefix = suffix = "";
s = branch_cert_name;
break;
+ case selectors::sel_head:
+ prefix = suffix = "";
+ s = branch_cert_name;
+ break;
case selectors::sel_date:
case selectors::sel_later:
case selectors::sel_earlier:
@@ -2049,6 +2053,7 @@
vector > const & limit,
set & completions)
{
+ //L(F("database::complete for partial '%s'\n") % partial);
completions.clear();
// step 1: the limit is transformed into an SQL select statement which
@@ -2115,6 +2120,46 @@
lim += (boost::format(" AND unbase64(value) glob '*%s*'")
% i->second).str();
}
+ else if (i->first == selectors::sel_head)
+ {
+ // get branch names
+ string subquery = (boost::format("SELECT DISTINCT value FROM revision_certs WHERE name='%s' and unbase64(value) glob '%s'")
+ % branch_cert_name % i->second).str();
+ vector branch_names;
+ results res;
+ fetch(res, one_col, any_rows, subquery.c_str());
+ for (size_t i = 0; i < res.size(); ++i)
+ {
+ base64 row_encoded(res[i][0]);
+ data row_decoded;
+ decode_base64(row_encoded, row_decoded);
+ branch_names.push_back(row_decoded());
+ }
+
+ // for each branch name, get the branch heads
+ set heads;
+ for (vector::const_iterator bn = branch_names.begin(); bn != branch_names.end(); bn++)
+ {
+ set branch_heads;
+ get_branch_heads(*bn, *__app, branch_heads);
+ heads.insert(branch_heads.begin(), branch_heads.end());
+ L(F("after get_branch_heads for %s, heads has %d entries\n") % (*bn) % heads.size());
+ }
+
+ lim += "SELECT id FROM revision_certs WHERE id IN (";
+ if (heads.size())
+ {
+ set::const_iterator r = heads.begin();
+ lim += (boost::format("'%s'") % r->inner()()).str();
+ r++;
+ while (r != heads.end())
+ {
+ lim += (boost::format(", '%s'") % r->inner()()).str();
+ r++;
+ }
+ }
+ lim += ") ";
+ }
else
{
string certname;
@@ -2136,6 +2181,7 @@
break;
}
}
+ //L(F("found selector type %d, selecting_head is now %d\n") % i->first % selecting_head);
}
}
lim += ")";
@@ -2181,7 +2227,7 @@
fetch(res, one_col, any_rows, query.c_str());
for (size_t i = 0; i < res.size(); ++i)
{
- if (ty == selectors::sel_ident)
+ if (ty == selectors::sel_ident)
completions.insert(res[i][0]);
else
{
========================================================================
--- monotone.texi c2ec4ec3f9a87edc9c10b100835c3bbef269253f
+++ monotone.texi ad41028e3431d1b52cf14e03eb22d73e54fbab24
@@ -2330,6 +2330,11 @@
Uses selector type @code{b}. For example, @code{b:net.venge.monotone} matches
@code{branch} certs where the cert value is @code{net.venge.monotone}.
Values to match for can have shell wildcards.
address@hidden Heads selection
+Uses selector type @code{h}. For example, @code{h:net.venge.monotone} matches
address@hidden certs where the cert value is @code{net.venge.monotone} and
+the associated revision is a head revision on that branch. Values to match
+for can have shell wildcards like the branch selector.
@item Date selection
Uses selector type @code{d}. For example, @code{d:2004-04} matches
@code{date} certs where the cert value begins with
========================================================================
--- selectors.cc af2e5813aba3cdf936fbcbb31dbb05ddf3690ccc
+++ selectors.cc 7ae313b2c960a3f68e40a68db0f883bd48b59ac3
@@ -46,6 +46,9 @@
case 'b':
type = sel_branch;
break;
+ case 'h':
+ type = sel_head;
+ break;
case 'd':
type = sel_date;
break;
========================================================================
--- selectors.hh 54ed172da5c3a3c4721152012d831f51e693cab9
+++ selectors.hh ef621e16abcf9bc95e46c55a999158f8b3c73d32
@@ -21,6 +21,7 @@
{
sel_author,
sel_branch,
+ sel_head,
sel_date,
sel_tag,
sel_ident,