Jump to content

Switch to end of branch identified by label in CLI


WDNichols

Recommended Posts

We have been using plastic for about a year, and are currently using version 5.0.44.509 - Hawaii.

 

We have about a half dozen repositories, and in each repository we create a branch off the main branch for each sprint, about 3 weeks, then merge back to the main branch at the end of the sprint. We have an automated nightly build that builds the code on the main branch. But I would like to add a build of the current sprint branch as well, since that's closer to where the work is going on, and so more likely to change from day to day. However, I cannot figure out how to use the CLI to switch to the end of the sprint branch, without having to change the nightly build batch file for every sprint (to include the name of the sprint branch).

 

I am doing something like this to switch to the end of the main branch before building each night. This works fine, since the name of the main branch does not change:

cm stb --repository="Lab@vc-svr:8034" --workspace="C:\Lab" br:"/main"

 

What I think I should be able to do is add a label (called "Sprint") to the current sprint branch. At the start of each sprint, when a new sprint branch is created, I would move the "Sprint" label to the new sprint's branch. From the CLI I should then be able to find out what branch the label "Sprint" is on, then switch to that branch (which makes the newest change set of the that branch my new home).

 

Can you tell me how I can use the CLI to do this?

 

Bill.

Link to comment
Share on other sites

Hi!

 

well if you create a label you are forced to remember to move the label to the latest cset in that moment.... Is more uncomfortable as the problem is....

 

We have the same "problem" but as our build system is connected with our task system it knows in which sprint we are working so it test the correct branch automatically... can you do something similar?

 

Another option is the following, test the last created branch called Sprint*

1) Get the branches starting with the string "Release"
cm find branch where name like 'Release%'

2) Get the first raw returned, this is the Sprint branch we need to build.
3) Update the workspace to the branch.
4) Build

What do you think?

Link to comment
Share on other sites

Greetings,

 

Regarding the Label, I was hoping not to have to move the label, except when the new sprint branch is first created. I had hoped that once I located the label (which would always have the same name) I could then discover the name of the branch on which it occurs, and then move by home to (the end of) that branch. If I can't get the label to work without moving it every time the branch changes, then I will just shelve that idea for now.

 

Your suggestion using CM FIND sounds promising. I will give that a try, and let you know how it works.

 

Thanks for the feedback.

 
Link to comment
Share on other sites

Regarding the Label, I was hoping not to have to move the label, except when the new sprint branch is first created. I had hoped that once I located the label (which would always have the same name) I could then discover the name of the branch on which it occurs, and then move by home to (the end of) that branch. If I can't get the label to work without moving it every time the branch changes, then I will just shelve that idea for now.

 

Hehehe cm shelve the idea yes, I think it's very complicated.

 

Tell me if you have any question regarding the cm find! here you have a pretty useful guide: http://plasticscm.com/guides/cmfind/main.shtml

Link to comment
Share on other sites

I tried your using CM FIND to get a list of the sprint branches. This worked, except that they appear in a random order. The most recently created sprint branch appeared as the third out of 32 branches listed. The list of branches appears something like this:

 

C:\_Dev.NET\Lab>cm find branch where name like '%Sprint%'
32670    9/3/2013 2:26 PM /main/2013 - Sprint 18 - pre DevExpress vesion 13 WDN Lab T
39993    10/29/2013 1:01 PM /main/4.x/Sprint 22 DF Lab T
49445    1/7/2014 7:59 AM /main/2014 - Sprint 1 DF Lab T
16407    3/28/2013 10:15 AM /main/DE20031593/2013-Sprint6 WDN Lab T
 
(and so on) where the red text is the branch name that I am actually looking for. In addition to the random order, the branch name is embedded in the other listing text, requiring some parsing to locate the actual branch name.
 
For all the work I would have to do to get the branch name in a batch file, it would be no harder, and perhaps less hard (though not easy) to get the branch name using a label. In that case, if I were to update the workspace to the label "Sprint", then use "cm showselector", I get something like this:
 
Selector for workspace Lab:
repository "Lab@vc-svr:8087"
  path "/"
    smartbranch "/main/2014 - Sprint 1" changeset "1338"
 
At least in this case, I ONLY get the branch I am looking for, and the branch name is delimited by quotes, making parsing easier.
 
Nevertheless, I was hoping there was a way to avoid capturing the CLI output, parsing it and then generating a new CLI command dynamically from that result (all from a batch file).
 
I would like a CLI command that would allow me to navigate my home "relative" to my current home, such as "move my home to the end of the current branch".
 
 
Thanks.
Link to comment
Share on other sites

Hi!

 

Some ideas:

 

1

Use cmdrunner to help you parsing the output and executing command easily and faster: http://codicesoftware.blogspot.com/2012/01/cmdrunner-power.html

 

If your Sprints are smaller than one month, for example, you can do the following to reduce the rows returned:

cm find "branch where date>= 'this month'"

Then sorting the rows by date is pretty easy: http://stackoverflow.com/questions/1618863/how-to-sort-a-collection-by-datetime-in-c-sharp

Pick the newer one and it's solve.

 

2

 

Use a well know name for your Sprint branches, for example: Sprint-XY

Use the query to get the branches but getting only the branch name:

cm.exe find "branch where date>= 'this month'" --format={name} --nototal

So now in cmdrunner you have a list of branch names, you just need to get the one with the higher ID. Parsing XXXX-ZY has to be easy using "-" as separator from an string and an int.

 

 

Tell me what you think!

 

 

I would like a CLI command that would allow me to navigate my home "relative" to my current home, such as "move my home to the end of the current branch".

Don't know if this is what you are asking for but you can do the following:

 

cm update . --last

 

That will move your house to the latest cset in the branch.

Link to comment
Share on other sites

  • 2 weeks later...

Manu,

 

I tried your last suggestion (cm update . --last) and that seems to be very close to what I am looking for.

 

It works fine, as long as my current directory is in the target work space. However, the batch files I have been using thus far to manipulate plastic have NOT changed to the current directory. Instead, I have used CLI commands like this:

 

cm stb --repository="Delphi.LabDAQ 4@vc-svr:8087" --workspace="C:\_Dev.Delphi\LabDAQ 4" br:"/main"
 
Where I explicitly identify the target work space. (I am not sure if I need to identify BOTH the repository AND the work space, but this works.)
 
I would like to be able to do the same thing with the update command. Is this possible? I do not see either --repository or --workspace options listed in the help for cm update.
 
Regards,
Bill.
Link to comment
Share on other sites

Archived

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

×
×
  • Create New...