Jump to content

odd behavior in cm find command using branches


u2468

Recommended Posts

This works:

cm find changeset where branch='main/branch1' --format="{changesetid}>{parent}" --nototal
6>3
7>6
8>7
9>8
 

However if the branch name contains spaces using single quotes around branch name:

cm find changeset where branch='main/bad branch  name' --format="{changesetid}>{parent}" --nototal

(No output)

 

If I change to double quotes around branch name:

cm find changeset where branch="main/bad branch  name" --format="{changesetid}>{parent}" --nototal
Error: unexpected char: '/'

 

If I go back to single quotes and then put double quotes around just the branch name with spaces:

Its hard to see below so here it is with extra spaces so you can see it:  ' main / " bad branch  name " '

 

cm find changeset where branch='main/"bad branch  name"' --format="{changesetid}>{parent}" --nototal
10>2
11>10
12>11
13>12
 

That seems like excessive manipulation needed by users for branch names with spaces. 

 

If the cm tool internally gets the string 'main/bad branch name/another name'  and it knows / is the delimiter, can't you use a regular expression inside your cm tool to figure out that everything between / and (/ or EOL) is a name with spaces without the user having to put more quotes around it?

 

Just a suggestion.

Link to comment
Share on other sites

Hi!

 

you just need to surround the query body with quotes:

cm find "changeset where branch='main/yi ha'" --format="{changesetid}>{parent}" --nototal

This works for windows and windows and saves you to think if the branch names contains blanks, slash symbols etc.

Link to comment
Share on other sites

  • 11 months later...

Hi! This is interesting and good to know!

 

It should be noted though, that the following does not work:

 

cm find "branch where name = 'main/trac6009' "

 

It returns 0 branches, even though that branch exists. If I remove the "parent namespace" of the branch name, leaving only 'trac6009' it works. There is a related uservoice:

 

https://plasticscm.uservoice.com/forums/15467-general/suggestions/13071435-add-support-for-namespace-in-find-branch-command

Link to comment
Share on other sites

Yep, you're correct.

 

This is how the cm find works. What it does is it translates the "find query" into SQL.

 

Some fields are translated to "object ids" client-side, while others travel to the server.

 

The name travels to the server, so when you say name="whatever", there's a query on the server doing branch.sname="whatever". And branches store their name, not the full name including parents.

 

That's why.

 

We'll certainly have to improve it one day...

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...