Jump to content

Add an attribute to a newly created branch / changeset


JakubH

Recommended Posts

I want to add an attribute to a newly created object (branch, changeset,...). I set up an after-mkbranch trigger which should add the attribute to the new branch. However, it fails with a message saying that the branch cannot be located.

It is probably because of the "relative" name of the branch – the environment variable PLASTIC_BRANCH_NAME is set to XYZ instead of /main/XYZ. How can I find out the full branch name within the trigger?

Link to comment
Share on other sites

I can do that, but there can be multiple branches with the same name (and different full name). Then I need to find out which is the last added branch or which branch of that name has not set the attribute. Then I have a decent level of certainty that I found the branch I've just created because probability of someone else creating a branch of the same name at the same time is very low.

Still, all these are workarounds. The trigger should give a unique identification directly.

Link to comment
Share on other sites

I have another very similar problem now: how I can find out whether a specific branch has set an attribute to a specific value? I thought I can use the find command, but there is the same problem – even though I have the full name of the branch, the find command supports the short name only. So I cannot distinguish among branches with the same name.

 

As a workaround, I think it would be better to disallow using the same name of a branch more times. I can make a before-mkbranch trigger for that.

 

Still, I don't understand why you allow non-unique names while don't support search by a full name.

Link to comment
Share on other sites

  • 1 year later...

Hi!

 

Still, I don't understand why you allow non-unique names while don't support search by a full name.

 

Well there's not a reason behind it, It's just not supported, a missing feature.

 

 

Even worse, [find branch where name = 'main'] returns 1 branch, but [find branch where name = '/main'] returns none!

 

Yes, this is how it currently works, right now "main" is a valid branch name, "/main" is not. So the find system behaves as it's currently defined. Once we support full branch name then "/main" will start working.

 

A dirty workaround, I have a lot of "scm111" branches, and I do know the full branch name, so...

cm find "branch where name='scm111' and attribute ='test' and attrvalue = 'passed'" | grep "/main/scm001/scm111 "
Link to comment
Share on other sites

  • 4 months later...
  • 2 weeks later...

Hi! To answer the original question regarding after-mkbranch:

 

"... the environment variable PLASTIC_BRANCH_NAME is set to XYZ instead of /main/XYZ. How can I find out the full branch name within the trigger?"

 

According to documentation ( at https://www.plasticscm.com/documentation/triggers/plastic-scm-version-control-triggers-guide.shtml#Createbranch ) there is now a variable PLASTIC_FULL_BRANCH_NAME, which is supposed to contain the full branch name specification.

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...