Selects objects by their metadata
Product | Command Type |
---|---|
ClearCase | general information |
ClearCase LT | general information |
Attache | general information |
Platform |
---|
UNIX |
Windows |
The query language is used to formulate queries on VOBs. It includes logical operators similar to those in the C programming language. A query searches one or more VOBs and returns the names of objects: versions, branches, and/or elements. A query may return a single object, many objects, or no objects at all.
A query primitive evaluates to TRUE
or FALSE
. A TRUE
value selects an object, such as an element, branch, or version; a FALSE
value excludes it.
A query must be enclosed in quotes if it includes spaces. You may also need to enclose a query in quotes to prevent shell-level interpretation of characters such as ( (open parenthesis). Quoting parentheses in config specs is not required.
You can use a query in a version selector in these contexts:
Command-line options in the following cleartool commands:
describe, merge, mkattr, mkbranch, mklabel, rmattr, rmlabel, rmver
Configuration rules; see the config_spec reference page
Version-extended pathnames in ClearCase, ClearCase LT, and Attache commands; see the pathnames_ccase reference page
A query in a version selector must be enclosed in braces ( {} ).
When a query is applied to a single branch, ClearCase and ClearCase LT select the most recent version on that branch that satisfies the query. For example:
cmd-context describe -ver '/main/{attype(QAed)}' util.c
Using a query without a branch pathname causes an element's entire version tree to be searched. If the query returns a single version, the version-selection operation succeeds; the operation fails if the query returns no version (not found
) or returns more than one version (ambiguous
). For example:
cmd-context describe -ver "{attype(QAed)}" util.c
cleartool: Error: Ambiguous query: "{attype(QAed)}"
You can also use queries in the find and findmerge commands. In this context, the query can be enclosed in braces ({...}). The query returns the names of all matching objects. For example:
UNIX:
cleartool find util.c -ver attype(QAed) -print
util.c@@/main/1
util.c@@/main/3
Windows (notice the quotes):
cleartool find util.c -ver "attype(QAed)" -print
util.c@@\main\1
util.c@@\main\3
The query language includes these primitives:
attribute-type-name comparison-operator value
TRUE
if the object itself has an attribute of that type and the value comparison is true. To test whether an object or its subobjects has a particular attribute (for example, an element or its branches and versions), use the attr_sub primitive.TRUE
, but BugNum!=671 is FALSE
. The second query would be true if an attribute of type BugNum existed, but had a different value.attr_sub (attribute-type-name, comparison-operator, value)
With elements |
|
With branches |
|
With versions |
|
With elements |
|
With branches |
|
With versions |
|
attype_sub (attribute-type-name)
With elements |
|
With branches |
|
With versions |
|
With elements |
|
With branches |
|
With versions |
|
created_by (login-name)
In all cases, TRUE
if the object was created by the user login-name (as shown by the describe command).
TRUE
if the object was created since date-time. The date-time argument can have any of the following formats:date | := | day-of-week | long-date |
time | := | h[h]:m[m][:s[s]] [UTC [ [ + | - ]h[h][:m[m] ] ] ] |
day-of-week | := | today |yesterday |Sunday | ... |Saturday |Sun | ... |Sat |
long-date | := | d[d]-month[-[yy]yy] |
month | := | January |... |December |Jan |... |Dec |
eltype (element-type-name)
In all cases, TRUE
if the element to which the object belongs is of type element-type-name.
TRUE
if the object is either end of a hyperlink (first form) named hlink-type-name, or is the from-end of a hyperlink (second form), or is the to-end of a hyperlink (third form)
lbtype (label-type-name)
In all cases, TRUE
if the object itself is labeled label-type-name. (Because elements and branches cannot have labels, this primitive can be true only for versions.)
With elements |
|
With branches |
|
With versions |
|
merge (from-location , to-location)
In all cases, TRUE
if the element to which the object belongs has a merge hyperlink (default name: Merge) connecting the from-location and to-location. You can specify either or both locations with a branch pathname or a version selector. Specifying a branch produces TRUE
if the merge hyperlink involves any version on that branch. The branch pathname must be complete (for example, /main/rel2_bugfix, not rel2_bugfix).
pool (pool-name)
In all cases, TRUE
if the element to which the object belongs has a source pool or cleartext pool named pool-name.
trtype (trigger-type-name)
In all cases, TRUE
if the element to which the object belongs has an attached or inherited trigger named trigger-type-name.
With elements |
|
With branches |
|
With versions |
|
Primitives can be combined into expressions with logical operators. An expression can take any of these forms, where query is a primitive or another expression:
query || query | (logical OR) |
query && query | (logical AND) |
! query | (logical NOT) |
( query ) | (grouping to override precedence) |
The precedence and associativity of the operators for attribute comparisons and formation of logical expressions are the same as in the C programming language:
highest precedence: ! | (right associative) |
lower precedence: < <= > >= | (left associative) |
lower precedence: == != | (left associative) |
lower precedence: && | (left associative) |
lowest precedence: || | (left associative) |
The UNIX examples in this section are written for use in csh. If you use another shell, you may need to use different quoting and escaping conventions.
The Windows examples that include wildcards or quoting are written for use in cleartool interactive mode. If you use cleartool single-command mode, you may need to change the wildcards and quoting to make your command interpreter process the command appropriately.
In cleartool single-command mode, cmd-context represents the UNIX shell or Windows command interpreter prompt, followed by the cleartool command. In cleartool interactive mode, cmd-context represents the interactive cleartool prompt. In Attache, cmd-context represents the workspace prompt.
On a UNIX system, display all versions of test .c for which the attribute QAed has the value Yes.
%
cat `cleartool describe -s -ver /main'{QAed=="Yes"}' test.c`
Attach the label REL6 to the version of test.c that is already labeled REL5.
%
cleartool mklabel -ver '{lbtype(REL5)}' REL6 test.c
Created label "REL6" on "test.c" version "/main/4".
Z:\vob2\src>
cleartool mklabel -ver "{lbtype(REL5)}" REL6 test.c
Created label "REL6" on "test.c" version "\main\4".
Attach an attribute to the latest version of test.c created since yesterday at 1 P.M. by user asd. Note the use of backslashes (\) to escape quote characters (") required to specify a string argument to mkattr.
%
mkattr -ver '{created_since(yesterday.13:00)&&created_by(asd)}' QAed \"No\" test.c
Created attribute "QAed" on "test.c@@/main/5".
cleartool>
mkattr -ver "{created_since(yesterday.13:00)&&created_by(asd)}" QAed ^
\"No\" test.c
Created attribute "QAed" on "test.c@@\main\5".
List each branch named rel2_bugfix that occurs in an element to which a trigger named mail_all has been attached.
%
cleartool find . -branch 'brtype(rel2_bugfix)&&trtype(mail_all)' -print
./util.c@@/main/rel2_bugfix
Z:\vob2\src>
cleartool find . -branch "brtype(rel2_bugfix)&&trtype(mail_all)" -print
.\util.c@@\main\rel2_bugfix
config_spec, pathnames_ccase, version_selector
Feedback on the documentation in this site? We welcome any comments!
Copyright © 2001 by Rational Software Corporation. All rights reserved. |