Jump to content

Problems with 'cm find' on Linux


Mikael Kalms

Recommended Posts

Hi,

I would like to view the structure of a repository via the commandline, but am running into problems early on. First I would like to list all existing branches.

The following command works on my Windows workstation, but not on a Linux machine (note, it runs inside a Docker container on an Azure VM):

cm find branch on repository 'branchname'

Windows example:

C:\Plastic>cm version
5.4.16.809

C:\Plastic>cm find branch on repository '<reponame>'
<a number of lines with information on all branches in <reponame>>

Linux example:

root@a863dafd279b:/# cm version
6.0.16.884

root@a863dafd279b:/# cm find branch on repository '<reponame>'
Query error: expecting "STRING", found '<reponame>'

I have tried various forms but I keep getting query errors. Never do I manage to get it to say that the repo in question does not exist.

 

(If I create a workspace from the repository on the Linux machine, then I can enter the workspace directory, perform 'cm find branch' and it will print info on the branches.)


Perhaps this is something 6.0.x specific? Any ideas?

Link to comment
Share on other sites

Hi,

This is related to how Bash processes the CLI arguments compared to the Windows prompt. To have your command working, just surround the 'find' predicate within quotation marks, like this:

cm find "branch on repository 'myrepo@myserver:8087'"

The command should run just as it did on Windows.

Please try that and tell us if that solved your problem!

 

Regards,

Miguel

Link to comment
Share on other sites

Thanks, that works for me. I can use the command now. This was not at all obvious from the documentation though. Performing "cm find --help" on the command line on the linux box shows:

 

root@a863dafd279b:/# cm find --help
Perform queries to obtain objects.

Usage:

    cm find object_type [where str_conditions] [on repository 'rep_spec' |
                        on repositories <'rep_spec'>+]
                        [--format=str_format] [--dateformat=date_format]
                        [--nototal] [--file=dump_file] [--xml] [--encoding=name]

    object_type         Object type to find.
                        (See the 'CM FIND GUIDE' to see all the objects to
                        find.)

... etc etc ...

and if I compare this to another command:

 

root@a863dafd279b:/# cm replicate --help
Push or pull a branch to another repo.

Usage:

    cm replicate src_br_spec dst_rep_spec
                 [--push] [--preview] [TranslateOptions]
                 [--user=usr_name [--password=pwd] | AuthOptions]
    (Direct server-to-server replication. Replicates a branch to a repository.)

    cm replicate src_br_spec --package=pack_file [AuthOptions]
    (Package based replication. Creates a replication package in the source
    server with the selected branch.)

    cm replicate dst_rep_spec --import=pack_file [TranslateOptions]
    (Package based replication. Imports the package in the destination server.)

... then I take it that "cm find" wants a single text-string argument whereas "cm replicate" wants multiple arguments? I was unable to see a difference like that from the docs themselves, nor from the "cm find" example page (https://www.plasticscm.com/documentation/cmfind/plastic-scm-version-control-query-system-guide.shtml) ...

Link to comment
Share on other sites

Also, it's worth pointing out that Bash uses the apostrophe as part of its syntax, to delimit string literals (similar to double quotes). This is why 'cm find' complains about getting 'repname' instead of a STRING, since it also requires a text value surrounded with single quotes.

This means that writing this in bash:

cm find branches on repository 'myrepo'

translates into this before calling the cm command:

cm find branches on repository myrepo

As you see, there are no single quotes being passed to the cm find interpreter, which requires them to identify 'myrepo' as a string literal. This would happen as well if you used a SQL interpreter which accepted SQL syntax directly as command line arguments.

This can be solved either by using double quotes, as explained before, or escaping the apostrophes, as follows.

cm find branches on repository \'myrepo\'

Either way, it all comes down to how bash interprets the command line input and understanding it at the time of writing the actual commands. We'll make this explicit on our documentation :-)

 

Regards,

Miguel

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...