In every version control system, we frequently need to get usage information about what files are being changed or just searching for a specific change or a specific branch.
The best way of achieving this is by using queries. So when we created Plastic SCM, we added a very powerful query system called cm find, a command that allows you to get specific information involving changesets, branches, labels, merges, code reviews, and more.
The find command can also be used to customize views in the GUI.
This guide covers (with examples) some scenarios that can be handled with the cm find command. They are a small subset of what you can do in your Plastic SCM installation. Each example includes a question, a step-by-step solution, and the expected output to help you understand what kind of information is returned.
This guide will show you examples about using the cm find command with some and not all the available objects.
You can get the complete list of objects you can find by running the cm showfindobjects command.
Note: You can use both singular and plural to find an object. For example, you can use both cm find branch or cm find branches.
Note: All cm find queries are case-sensitive.
Note: When you run queries using comparison operators (>, <, >=, <=) from the command
line, remember that the shell considers these operators as IO redirections.
So you will need to enclose the queries with quotation marks:
Note about PowerShell
The PowerShell console will escape the "double" quotes by default (but not the "simple"), so we must put an extra pair of quotes to specify we want them inside our command:
cm find replicationlog where branch = "'/semanticmain'" --format="{date}" --nototal | select -Last 1Or, you can enclose all the query:
cm find replicationlog "where branch = '/semanticmain'" --format="{date}" --nototal | select -Last 1We can retrieve the branches created by a user in a specific period, and then we can filter by a specific attribute.
We start retrieving all the branches available:
cm find branches 301186 09/01/2013 8:18:51 /main/Fix-4.1/SCM12154 borja codice T 378467 12/02/2013 12:43:24 /main/scm12336 violeta codice T 379892 12/02/2013 17:52:14 /main/scm12336/scm12013 pablo codice T 407817 22/04/2013 16:32:31 /main/scm12636/scm12666 pablo codice T 426648 29/05/2013 17:36:04 /main/scm12313 pablo codice T Total: 5We only want our branches, so we filter by user:
cm find branches "where owner='pablo'" 379892 12/02/2013 17:52:14 /main/scm12336/scm12013 pablo codice T 407817 22/04/2013 16:32:31 /main/scm12636/scm12666 pablo codice T 426648 29/05/2013 17:36:04 /main/scm12313 pablo codice T Total: 3After filtering by user, we now want only the branches related to this sprint, so we are looking for the ones created after a specific date:
cm find branches "where owner='pablo' and date >= '2013/03/01'" 407817 22/04/2013 16:32:31 /main/scm12636/scm12666 pablo codice T 426648 29/05/2013 17:36:04 /main/scm12313 pablo codice T Total: 2You can use a formatted output:
cm find branches "where owner='pablo' and date >= '2013/03/01'" --format="{name,-30} {date}" /main/scm12636/scm12666 22/04/2013 16:32:31 /main/scm12313 29/05/2013 17:36:04 Total: 2Finally, we look for a specific attribute. According to our internal feature lifecycle, each branch must pass tests before integrating it on the main branch.
When a branch passes the test, the "test" attribute will be set to "passed," and so, we filter by attribute name and by attribute value:
cm find branches "where owner='pablo' and date >= '2012/01/01' and attribute ='test' and attrvalue = 'passed'" 426648 29/05/2013 17:36:04 /main/scm12313 pablo codice T Total: 1The following table displays the different filtering options that are currently available to be used with cm find branch command:
Filtering options ( where... ) | |||||
---|---|---|---|---|---|
attribute | attrvalue | changesets | comment | date | guid |
id | item | name | owner | parent | repllogid |
replsrcdate | replsrcid | replsrcrepository | replsrcserver |
* Condition date corresponds to Creation date column in the Branches view.
Learn how to filter by date using constants.
This table displays the different output options that are currently available to be used with cm find branch command:
Output options ( --format... ) | |||||
---|---|---|---|---|---|
comment | date | id | name | owner | parent |
You can find a lot of info for the changesets, and the comments are just one of those. For quick info, you can use cm log and do your own filtering (using shell commands) or let cm find to do the job for you.
This example shows the date and comment for all the changesets that belong to a branch:
cm find changeset "where branch = 'main/scm12800'" --format="{date} - {comment}" 27/05/2013 13:25:53 - Updated output. 27/05/2013 13:26:45 - Changed SccPlugin with the new change. 27/05/2013 13:35:15 - Added solution. Total: 3Here are all the changesets, for example, you're looking for the word "solution." Here we can easily see it, but it becomes harder to spot when you have a couple of hundred changesets. For filtering by a specific word, use the SQL-syntax LIKE and % for an approximate search because you're not looking for the complete comments:
cm find changeset "where branch = 'main/scm12800' and comment like '%solution%'" --format="{date} - {comment}" 27/05/2013 13:35:15 - Added solution. Total: 1You can also query the changesets by replication date, using the following command (see replication log on how to get the last replication date):
cm find changeset "where branch='semanticmain' and replsrcdate > '2013/06/17'" --nototal 427425 16794 /semanticmain 07/06/2013 11:06:38 violeta codice IntegrateMiryamtask 12838 427435 16804 /semanticmain 07/06/2013 19:25:31 violeta codice Changeassemblyversion (0.9.28.0). 427436 16805 /semanticmain 07/06/2013 19:54:35 lrodriguez codice Updatemapallreturnparent allows you to get the parent of a specific changeset or revision. That way, if you want to know what happened before the changeset you can use:
cm find changeset "where changesetid = 16583 and returnparent = 'true'" --nototal 423630 16582 /main/scm12800 27/05/2013 13:25:53 roberto codice Updated output.The following table displays the different filtering options that are currently available to be used with cm find changeset command:
Filtering options ( where...) | |||||
---|---|---|---|---|---|
attribute | attrvalue | branch | changesetid | comment | date |
guid | id | owner | parent | repllogid | replsrcdate |
replsrcid | replsrcrepository | replsrcserver | returnparent |
* Conditions changesetid, date, and owner correspond to Name , Creation date and Created by columns respectively in the Changesets view.
Learn how to filter by date using constants.
This table displays the different output options that are currently available to be used with cm find changeset command:
Output options ( --format...) | |||||
---|---|---|---|---|---|
branch | changesetid | comment | date | guid | id |
owner | parent |
Given a branch, you can get all the replication operations from any time chronologically.
cm find replicationlog "where branch = '/semanticmain'" --nototal 424089 03/06/2013 12:16:42 codice@diana:9095 F pablo 426718 17/06/2013 18:46:38 codice@diana:9095 F pablo 427606 17/06/2013 18:50:47 codice@diana:9095 F pabloIf you only want the last date, you can filter by date and select the last row using PowerShell or bash.
PowerShell:
cm find replicationlog "where branch = '/semanticmain'" --format="{date}" --nototal | select -Last 1Bash:
cm find replicationlog "where branch = '/semanticmain'" --format="{date}" --nototal | tail -n 1Result:
17/06/2013 18:50:47The following table displays the different filtering options that are currently available to be used with cm find replicationlog command:
Filtering options ( where...) | |||||
---|---|---|---|---|---|
branch | date | id | owner | package | repositoryname |
server |
Learn how to filter by date using constants.
This table displays the different output options that are currently available to be used with cm find replicationlog command:
Output options ( --format...) | |||||
---|---|---|---|---|---|
date | id | owner | package | server |
You can find all the labels in a specific repository:
cm find label --format="{name} {owner} {branch} {branchid}" --nototal on repository 'codice' BL234 dpenalba /main 3 BL235 lrodriguez /main 3 BL236 jgonzalez /main/task001 4 BL237 jgonzalez /main 3 BL238 lrodriguez /main/task002 5 BL239 lrodriguez /main 3And you can find all the labels that created in specific branch in a particular repository:
cm find label "where branch = '/main'" --format="{name} {owner}" --nototal on repository 'codice' BL234 dpenalba BL235 lrodriguez BL237 jgonzalez BL239 lrodriguezYou may want to find which branch contains a specific release:
cm find label "where name = 'BL237' on repository 'codice'" --nototal 191871 17/11/2011 16:38:06 BL237 10503 /main lrodriguez codiceIn the above example, the label BL237 comes from the main branch.
You can get the label's date, and later ask for the changesets created in that timespan in that branch. Getting the information for two (or more) labels is very simple:
cm find label "where name = 'BL237' or name='BL235' on repository 'codice'" --nototal 191869 11/11/2011 14:20:02 BL235 1750 /main lrodriguez codice 191871 17/11/2011 16:38:06 BL237 10503 /main lrodriguez codiceThe following table displays the different filtering options that are currently available to be used with cm find label command:
Filtering options ( where... ) | |||||
---|---|---|---|---|---|
attribute | attrvalue | branch | branchid | changeset | comment |
date | guid | id | name | owner | repllogid |
replsrcdate | replsrcid | replsrcrepository | replsrcserver |
* Condition date corresponds to Creation date column in the Labels view.
Learn how to filter by date using constants.
This table displays the different output options that are currently available to be used with cm find label command:
Output options ( --format... ) | |||||
---|---|---|---|---|---|
branch | branchid | changeset | comment | date | id |
name | owner |
The attributes can be applied to branches, changesets, and labels, without any distinction. The first thing you need is the object Id. You can get it by specifying the id when querying for a branch:
cm find branch "where name = 'main'" --format="{id}" --nototal 3Once you have it, you can get the attribute list with the following commands:
cm find attributes "where srcobj = 3" --nototal objid:3@repid:2@repserver:localhost:8087 -- status --> PASSEDIn this case, the attribute name is "status", and the attribute value is "Passed".
You can combine these two commands using some PowerShell scripting:
cm find branch "where name = 'main'" --format="{id}" --nototal |Foreach-Object { cm find attributes where srcobj= $_ --nototal}Or bash scripting:
for branch_id in 'cm find branch "where name = 'main'" --format="{id}" --nototal' ;do cm find attributes "where srcobj=$branch_id" --nototal; doneThe output will be the same as before:
objid:3@repid:2@repserver:localhost:8087 -- status --> PASSEDAnd you will get the same output by running the following query:
cm find attributes "where srcobj='br:/main'" --nototalLet's suppose you set a specific attribute to some objects (in this case, the test "status"). You can query for these attributes, no matter the object that contains it.
cm find attributes "where type = 'status' and value='PASSED' and date > 'this month'" objid:253012@repid:2@repserver:localhost:8087 -- status --> PASSED objid:253013@repid:2@repserver:localhost:8087 -- status --> PASSED objid:253014@repid:2@repserver:localhost:8087 -- status --> PASSED objid:268518@repid:2@repserver:localhost:8087 -- status --> PASSEDThe following table displays the different filtering options that are currently available to be used with cm find attributes command:
Filtering options ( where... ) | |||||
---|---|---|---|---|---|
comment | date | guid | id | owner | srcobj |
type | value |
* Conditions date and type correspond to Creation date and Name columns respectively in the Attributes view.
Learn how to filter by date using constants.
This table displays the different output options that are currently available to be used with cm find attributes command:
Output options ( --format... ) | |||||
---|---|---|---|---|---|
comment | date | id | owner | type | value |
With a specific changeset retrieved in the previous sample, you may want to know more about the files that have changes in it, and for that purpose you may use find revision.
You use a custom format, because you only want the file and folder paths:
cm find revisions "where changeset=16716" --format="{path}" d:\linked_replicated\ d:\linked_replicated\01nerva d:\linked_replicated\01nerva\src d:\linked_replicated\01nerva\src\client d:\linked_replicated\01nerva\src\client\plastic d:\linked_replicated\01nerva\src\client\plastic\libplasticTranslations.es.resx d:\linked_replicated\01nerva\src\client\plastic\libplasticTranslations.resx d:\linked_replicated\01nerva\src\client\plastic\ActionMenuManager.cs Total: 8You could also filter by folder with some command line help (grep on Linux, and where on Windows PowerShell):
PowerShell:
cm find revisions "where changeset=16716" --format="{path}" --nototal | where {$_ -match "client\\"}Bash:
bcm find revisions "where changeset=15430" --format="{path}" --nototal | grep client\/Then the output would be something like this:
d:\linked_replicated\01nerva\src\client\plastic d:\linked_replicated\01nerva\src\client\plastic\libplasticTranslations.es.resx d:\linked_replicated\01nerva\src\client\plastic\libplasticTranslations.resx d:\linked_replicated\01nerva\src\client\plastic\ActionMenuManager.csYou can also get the revision info for a branch, searching in all its changesets. You can start by getting all the changed items from a branch and a time span:
cm find revisions "where branch = 'main/Fix-4.1/scm12814' and date <= '2013/05/30' and date > '2013/05/28'" --format="{date} - {path}"Later you can use our favourite shell tool, in our case Powershell, to filter that info.
cm find revisions "where branch = 'main/Fix-4.1/scm12814' and date <= '2013/05/30' and date > '2013/05/28'" --format="{date} - {path}" | where {$_ -match "view\\"}If you prefer bash, this is your line:
cm find revisions "where branch = 'main/Fix-4.1/scm12814' and date <= '2013/05/30' and date > '2013/05/28'" --format="{date} - {path}" | grep view\/The expected output looks like this:
28/05/2013 12:35:18 - d:\linked_replicated\01nerva\src\client\plastic\view\releasediagram 28/05/2013 12:35:18 - d:\linked_replicated\01nerva\src\client\plastic\view\releasediagram\drawingStyles 28/05/2013 12:35:18 - d:\linked_replicated\01nerva\src\client\plastic\view\releasediagram\drawingStyles\BaseDrawingStyle.csThe following table displays the different filtering options that are currently available to be used with cm find revisions command:
Filtering options ( where... ) | |||||
---|---|---|---|---|---|
archived | attribute | attrvalue | branch | changeset | date |
guid | id | item | itemid | label | marker |
owner | parent | repllogid | replsrcdate | replsrcid | replsrcrepository |
replsrcserver | returnparent | size | type | workspacecheckoutid |
Learn how to filter by date using constants.
This table displays the different output options that are currently available to be used with cm find revisions command:
Output options ( --format... ) | |||||
---|---|---|---|---|---|
branch | changeset | date | id | item | itemid |
owner | parent | size | type |
It's possible to track the merges from and to a specific branch or changeset.
If you want to know where a branch has been integrated on, type the following command:
cm find merge "where srcbranch ='main/Fix-4.1/SCM11769'" br:/main/Fix-4.1/SCM11769@55613 -->br:/main/Fix-4.1/Release-4.1.10.447@55808 Total: 1And if you want to know which branches are integrated in a specific branch, the command is:
$ cm find merge "where dstbranch ='main/Fix-4.1/Release-4.1.10.447'" br:/main/Fix-4.1/SCM12835@55568 -->br:/main/Fix-4.1/Release-4.1.10.447@55801 br:/main/Fix-4.1/scm11898@55647 -->br:/main/Fix-4.1/Release-4.1.10.447@55802 br:/main/Fix-4.1/scm12839@55678 -->br:/main/Fix-4.1/Release-4.1.10.447@55803 br:/main/Fix-4.1/SCM11769@55613 -->br:/main/Fix-4.1/Release-4.1.10.447@55808 br:/main/Fix-4.1/SCM12860@55735 -->br:/main/Fix-4.1/Release-4.1.10.447@55809 Total: 5The previous commands can also use our format flags to customize the output by returning only the branch names, that way, for example, the second command would become something like this:
$ cm find merge "where dstbranch ='main/Fix-4.1/Release-4.1.10.447'" --format="{srcbranch}" --nototal br:/main/Fix-4.1/SCM12835 br:/main/Fix-4.1/scm11898 br:/main/Fix-4.1/scm12839 br:/main/scm12419 br:/main/SCM4052 br:/main/Fix-4.1/SCM11769 br:/main/Fix-4.1/SCM12860Or:
cm find merges "where dstbranch='br:/main/ReleaseBL274'" --format="{srcbranch}@{srcchangeset} --> {dstbranch}@{dstchangeset}({type})" --nototal br:/main/scm11148@43953 --> br:/main/ReleaseBL274@44094 (merge) br:/main/scm11181@43969 --> br:/main/ReleaseBL274@44096 (merge) br:/main/Fix-4.0/SCM11101@44010 --> br:/main/ReleaseBL274@44030 (merge) br:/main/scm11135@43980 --> br:/main/ReleaseBL274@44031 (merge) br:/main/ReleaseBL272@43914 --> br:/main/ReleaseBL274@44032 (cherrypick) br:/main/ReleaseBL268@43663 --> br:/main/ReleaseBL274@44033 (cherrypick) br:/main/scm10957@43952 --> br:/main/ReleaseBL274@44093 (merge) br:/main/SCM11195@43981 --> br:/main/ReleaseBL274@44095 (merge) br:/main/SCM10924@43942 --> br:/main/ReleaseBL274@44033 (merge)Remember that find merge returns all types of merges: regular merges, cherrypicked merges, and subtractive merges.
So you can get interval merges to a given branch:
cm find merges "where dstbranch='br:/main/Fix-4.1/ReleaseBL285' and type='intervalcherrypick'" --format="({basebranch}@{basechangeset}, {srcbranch}@{srcchangeset}] --> {dstbranch}@{dstchangeset}" --nototal (br:/main@44448, br:/main/scm11318@44461] --> br:/main/Fix-4.1/ReleaseBL285@44463You can do this with two queries (find branches, find merge) and some PowerShell hacking. Place this code on a PS1 file and run it from your PowerShell console:
$allBranches = cm find branches "where date >= '2013/06/20'" --format="{name}" --nototal; $allMerged = cm find merge "where date >= '2013/06/20'" --format="{srcbranch}" --nototal; for($i = 0; $i -le $allBranches.length -1; $i++) {$allBranches[$i] = 'br:' + $allBranches[$i]} $allBranches| ?{$allMerged -notcontains $_}Here is a sample output:
br:/main/scm12619 br:/main/Fix-4.1/scm12916 br:/main/Fix-4.1/scm12899/scm12947 br:/main/Fix-4.1/scm11180 br:/main/Fix-4.1/scm8782 br:/main/Fix-4.1/scm12944 br:/semanticmain/SCM12759/scm12948This code performs the following actions:
An equivalent code in bash shell would be the following:
$ allBranches='cm find branches "where date >= '2013/06/20'" --format="{name}" --nototal' $ allMerged='cm find merge "where date >= '2013/06/20'" --format="{srcbranch}" --nototal' $ for branch in $allBranches; do [ ! 'echo $allMerged | grep 'br:$branch'' ] && print "br:$branch"; doneThis code does the following:
We are looking for this scenario:
We want those branches that have been integrated into another branch (so we must discard merges into the same branch) but have changesets pending to integrate (the orange cset on the picture), and yes, we can do it with a single query, and then some post-processing with some Powershell code:
$allMergedNonFiltered = cm find merge "where date >= '2013/06/01'" --format="{srcbranch} {dstbranch} {srcchangeset}" --nototal; $allMerged = $allMergedNonFiltered | ForEach-Object {$res = $_.Split(" "); if($res[0] -ne $res[1]) {$res[0] + " " + $res[2]} }; $semiMerged = $allMerged | ForEach-Object {$_.Split(" ")[0] }; $allBranches = cm find branches where "date >= '2013/06/01'" --format="{name} {changeset}" --nototal; for($i = 0; $i -le $allBranches.length -1; $i++) {$allBranches[$i] = 'br:' + $allBranches[$i]} $allBranches| ?{$allMerged -notcontains $_ -and $semiMerged -contains $_.Split(" ")[0]}Here is a sample output:
br:/main/Fix-4.1/scm12861 56049 br:/main/Fix-4.1/SCM12817 56300 br:/main/Fix-4.1/scm12899 56270This code performs the following actions:
If you are using bash, here's an alternative:
$ cm find merge "where date >= '2013/06/01'" --format="{srcbranch}#{dstbranch}#{srcchangeset}" --nototal |awk -F "#" '{if($1 != $2) print $1 "#" $3}' | tee allMerges | cut -d'#' -f1 | sort -u > mergedBranches $ for branch in 'cm find branches where "date >= '2013/06/01'" --format="br:{name}#{changeset}" --nototal;'; do [ ! "'grep $branch allMerges'" ] && [ "'echo $branch | grep -f mergedBranches'" ] && echo $branch; done $ rm allMerges mergedBranchesWhat you've just done:
For example, you want to know which branches have been integrated into version 1.0, directly or indirectly. As before, you only need one single query to the server and some more PowerShell to filter the data. In this specific example, you want to get all the branches that have been integrated into /main.
function ListAll($list, $visited, $targetBranch, $depth) { $visited += $targetBranch; $list | ForEach-Object { $res = $_.Split(" "); if(($res[1] -eq $targetBranch) -and ($visited -notcontains $res[0])) { Write-Host $depth $res[0]; $visited += $res[0]; $temp_visited = ListAll $list $visited $res[0] ($depth + "-"); $temp_visited | ForEach-Object{ if($visited -notcontains $_) { $visited += $_; } } } } return $visited; } $targetBranch = "br:/main"; $allMergedNonFiltered = cm find merge "where date >= '2013/01/01'" --format="{srcbranch} {dstbranch}" --nototal; $allMerged = $allMergedNonFiltered | ForEach-Object {$res =$_.Split(" "); if($res[0] -ne $res[1]) {$res[0] + " " + $res[1]} } $visited = @(); $targetBranch ListAll $allMerged $visited $targetBranch "-" | Out-Null;Here is a sample output, You can see that the branch 12299 is indirectly integrated in the release 4.3.39.406
br:/main br:/main/Release-4.2.29.406 br:/main/SCM12356 br:/main/scm12238 br:/main/Release-4.2.28.387/SCM12169/scm12230 br:/main/SCM12243/scm12280/scm12277/scm12293 br:/main/scm12238/scm12299A brief explanation of the script:
An equivalence under bash can be done with the following script:
cm find merge "where date >= '2013/01/01'" --format="{srcbranch}#{dstbranch}" --nototal | awk -F "#" '{if($1 != $2) print $1 "#" $2}' > list touch old_targets touch next_targets echo "br:/main" | tee targets depth=">" while [ -s targets ]; do for merge in 'grep -f targets list'; do src_branch=${merge%#*} was_already_target="'grep ${src_branch} old_targets 2>/dev/null'" already_on_next_targets="'grep ${src_branch} next_targets 2>/dev/null'" if [ ! "$was_already_target" ] && [ ! "$already_on_next_targets" ]; then echo ${src_branch} >> next_targets echo ${depth}${src_branch} fi done depth="-${depth}" cat targets >> old_targets [ -s next_targets ] && mv next_targets targets || rm -f targets done rm -f list old_targetsA brief explanation for this script:
The following table displays the different filtering options that are currently available to be used with cm find merge command:
Filtering options ( where... ) | |||||
---|---|---|---|---|---|
date | dstbranch | dstchangeset | guid | id | owner |
srcbranch | srcchangeset | type |
Learn how to filter by date using constants.
This table displays the different output options that are currently available to be used with cm find merge command:
Output options ( --format... ) | |||||
---|---|---|---|---|---|
date | dstbranch | dstchangeset | id | owner | srcbranch |
srcchangeset | type |
The integrated code review feature allows you to get information about the status of a review. In this example, start getting 'my' reviews (the ones assigned literally to 'me' where 'me' is the current user). You can also put a user's name like previous examples.
cm find reviews "where assignee = 'me'" 399982 08/03/2013 10:43:30 danipen Status1 pablo "scm12563" Branch id:399570 419067 20/05/2013 9:59:49 asalim Status0 pablo "scm12411" Branch id:416824 8424078 29/05/2013 14:50:35 borja Status1 pablo "Review scm12816" Branch id:424073 425830 05/06/2013 17:04:37 jesusmg Status0 pablo "Review scm11179" Branch id:413120 426717 14/06/2013 14:01:14 roberto Status1 pablo "Code review 1" Branch id:426648 Total: 5Afterwards, you can scope the result to those reviews that have a specific status (1 = approved):
cm find reviews "where assignee = 'me' and status = 1" 399982 08/03/2013 10:43:30 danipen Status1 pablo "scm12563" Branch id:399570 8424078 29/05/2013 14:50:35 borja Status1 pablo "Review scm12816" Branch id:424073 426717 14/06/2013 14:01:14 roberto Status1 pablo "Code review 1" Branch id:426648 Total: 3Finally, you find reviews in a specific time frame:
cm find "review where assignee = 'me' and date > '2013/05/01' and date < '2013/06/29'" 419067 20/05/2013 9:59:49 asalim Status0 pablo "scm12411" Branch id:416824 8424078 29/05/2013 14:50:35 borja Status1 pablo "Review scm12816" Branch id:424073 425830 05/06/2013 17:04:37 jesusmg Status0 pablo "Review scm11179" Branch id:413120 426717 14/06/2013 14:01:14 roberto Status1 pablo "Code review 1" Branch id:426648 Total: 4So you want to compare it with the ones that have this specific span and this specific condition:
cm find "review where assignee = 'me' and date > '2013/06/14' and date < '2013/06/15' and status = 1" 8424078 29/05/2013 14:50:35 borja Status1 pablo "Review scm12816" Branch id:424073 426717 14/06/2013 14:01:14 roberto Status1 pablo "Code review 1" Branch id: 426648 Total: 2With these two queries, you could get a ratio of approved/all reviews on this sprint.
The following table displays the different filtering options that are currently available to be used with cm find review command:
Filtering options ( where... ) | |||||
---|---|---|---|---|---|
assignee | comment | date | guid | id | owner |
status | targetid |
* Conditions date and targetid correspond to Creation date and Reviewed object columns respectively in the Code reviews view.
Learn how to filter by date using constants.
This table displays the different output options that are currently available to be used with cm find review command:
Output options ( --format... ) | |||||
---|---|---|---|---|---|
assignee | date | id | owner | status | target |
targettype | title |
You can get the shelves that are created by your team members during the last year:
cm find shelve "where owner != 'me' and date >= '1 years ago'" 3848 2 04/10/2018 5:58:22 PM pablo doom3code Shelve - temporary compilation.txt file 3860 3 06/23/2018 11:08:06 PM pablo doom3code Shelve - test with a new configuration Total: 2The following table displays the different filtering options that are currently available to be used with cm find shelve command:
Filtering options ( where...) | |||||
---|---|---|---|---|---|
owner | date | attribute | attrvalue | comment | guid |
parent | shelveid | id |
Learn how to filter by date using constants.
This table displays the different output options that are currently available to be used with cm find shelve command:
Output options ( --format...) | |||||
---|---|---|---|---|---|
id | shelveid | date | owner | repository | comment |
In this guide, you've seen how to customize the output, but you can also set the output as XML and save it to a file for later analysis:
cm find revisions "where changeset=16716" --xml --file=output.xmlGenerates the following XML content:
<?xml version="1.0" encoding="utf-8" ?> <PLASTICQUERY> <REVISION> <ID>426098</ID> <COMMENT></COMMENT> <DATE>07/06/2013 16:00:09</DATE> <OWNER>roberto</OWNER> <TYPE>dir</TYPE> <SIZE>0</SIZE> <CHANGESET>16716</CHANGESET> <PARENT>426069</PARENT> <ITEM>d:\linked_replicated\</ITEM> <ITEMID>2</ITEMID> <BRANCH>br:/main/Fix-4.1/scm12863</BRANCH> <PATH>d:\linked_replicated\</PATH> <REPOSITORY>codice</REPOSITORY> <REPNAME>codice</REPNAME> <REPSERVER>localhost:8087</REPSERVER> <HASH>kWJO1fm+7RCiZZcgSjM4/Q==</HASH> </REVISION> <REVISION> <ID>426092</ID> <COMMENT></COMMENT> <DATE>07/06/2013 16:00:09</DATE> <OWNER>roberto</OWNER> <TYPE>txt</TYPE> <SIZE>78238</SIZE> <CHANGESET>16716</CHANGESET> <PARENT>426056</PARENT> <ITEM>d:\linked_replicated\01nerva\src\client\plastic\ActionMenuManager.cs</ITEM> <ITEMID>37736</ITEMID> <BRANCH>br:/main/Fix-4.1/scm12863</BRANCH> <PATH>d:\linked_replicated\01nerva\src\client\plastic\ActionMenuManager.cs</PATH> <REPOSITORY>codice</REPOSITORY> <REPNAME>codice</REPNAME> <REPSERVER>localhost:8087</REPSERVER> <HASH>FXmLNV7B9Et1wTGqULWpgQ==</HASH> </REVISION> </PLASTICQUERY>
This content can be later imported into tools like Excel.
Suppose you want to get the information of all the changesets in our repository. You can execute the following command:
cm find changeset --xml --file=output.xmlYou can then load the output in Excel; this is the result:
Excel includes a very useful utility called PivotTable that allows us to get more statistics.
Using the filtering and sorting features available in Excel, you can get the group the changesets user and convert those stats into graphs:
You can also group by branch, and you could get, grouping by branch, how many users have contributed, and how many changesets have been created by each user, on each branch.
The find command has a default output for each object, but you can define your custom output options as seen before, retrieve the result using XML format with the --xml attribute, and save the result in a file with the --file attribute for later analysis.
The general syntax is the following:
cm find object "[where conditions] [on repositories]" [sort options] [pagination options] [format options]Where:
This will work as long as you have the authorization to query that repository.
You can query together from not only different repositories but also different servers. For example
cm find "changesets where date >= '2017/11/17' on repositories 'documentation/plasticdocu@localhost:8087','codice@codice@cloud'" --nototal 68621 1451 /main/scm21135 11/20/2017 3:32:31 PM maria documentation/plasticdocu Added documentation about the EOL conversion mechanism. 4821759 132324 /main/SCM21120 11/20/2017 1:41:45 PM pablo codice Added missing config file 4821840 132326 /main/scm21149/scm21150 11/20/2017 1:54:35 PM vsanchezm@codicesoftware.com codice Fix HAL FAILED - Conflicts and user intervention required. Rebase from main. 4821941 132333 /main 11/20/2017 2:38:28 PM hal codice HAL: merged /main/scm21076/scm21084/scm21093 : GTK Gluon: add pending changes viewWhen filtering by date, you can use date formats that follow your machine localization settings. For example, if your computer displays dates in the 'MM-dd-yyyy' format, you can use dates such as '12-31-2021' in your queries.
You can also use the following constants to simplify your queries:
'today'
: today's date.yesterday'
: yesterday's date.this week'
: current week's Monday date.this month'
: current month's 1st day date.this year'
: current year's January 1st date.one day ago'
: one day before the current date.one week ago'
: seven days before the current date.one month ago'
: one month before the current date.n days ago'
: 'n' days before the current date.n months ago'
: 'n' months before the current date.n years ago'
: 'n' years before the current date.The following where clauses are valid for fields of type date:
Every find object complies with pagination, defining a limit and an offset to manage the result size and starting point.
For example:
For example. Let's suppose that the following command returns a total of 60 branches: cm find branch "where owner='me'"
You want to get the results in blocks of 20 branches. So you'll have to run the cm find command with the pagination options three times to get three blocks of 20 branches. First, you run: cm find branch "where owner='me'" limit 20 offset 0
If you don't have permission to see some rows in the first block, then you'll get a minor number of 20 branches. So, you'll have to run the cm find command with the pagination options more than three times to get the total of 60 branches.
You can sort some objects by different fields. This way, the order by clause can be used with the following objects and some of its fields:
Sort object | By these fields |
---|---|
branch |
date , branchname |
changeset |
date , changesetId |
label |
date , labelname |
review |
date , modifiedate , status |
For example: