Author Topic: VersionControlAdd not working (V14.0)  (Read 613 times)

yonatan.lehman

  • EA User
  • **
  • Posts: 45
  • Karma: +0/-0
    • View Profile
VersionControlAdd not working (V14.0)
« on: May 23, 2022, 08:58:12 pm »
I'm trying to add a package to version control in JScript  that is is equivalent to doing it manually:



pkg.VersionControlAdd("OM_SW_ONE","","",true);

The outcome is no exception, and the package is not in version control (no version control icon in the project tree and error if I try to check it in/out)

I pass the 2nd parameter as an empty string as the 2nd because I don't want "Export as Model Branch" - I also tried passing undefined and null - undefined gave me a type error and null didn't work, just as the  empty string.
If I pass a string as a 2nd Parameter it works - but I don't want an EAB file or the bother of making it unique.

Solutions ?
Thanks

« Last Edit: May 23, 2022, 09:00:26 pm by yonatan.lehman »

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 11849
  • Karma: +460/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: VersionControlAdd not working (V14.0)
« Reply #1 on: May 23, 2022, 09:30:50 pm »
VersionControlAdd links you package to an xmi file in your working copy folder.
If you don't supply a filename this will not work.

We use this in our scripting:
Code: [Select]
package.VersionControlAdd versionControlID, _
subfolder & package.PackageGUID + cleanFileName(package.Name) & ".xml", _
"Initial addition of package " & package.Name , _
false

Geert

yonatan.lehman

  • EA User
  • **
  • Posts: 45
  • Karma: +0/-0
    • View Profile
Re: VersionControlAdd not working (V14.0)
« Reply #2 on: May 24, 2022, 04:01:31 pm »
Thanks Geert
Do you mean there is no way to add a package to version control without creating an external file using a script?
It should be possible since when I do add to version control manually, I have the option not to create an external file in the dialog.

As a secondary question - maybe my approach is wrong - I have a large package hierarchy which models my C code directory hierarchy (e.g. directory per systems, subsystems, packages, module). I put every package under version control explicitly so that it can be checked out individually - but as far as I know - I have no need for the EAB files - so I should be able to add a package to version control with an external file - what am I missing ?

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 11849
  • Karma: +460/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: VersionControlAdd not working (V14.0)
« Reply #3 on: May 24, 2022, 04:23:38 pm »
I don't know what you mean by "adding to version control without an external file".

AFAIK there is no such thing. How would it work? How does your version control system know the contents of your package?

You don't need EAB file, that's true, but you do need .xml files for each controlled package, whether you do it manually, or with a script.

Geert

yonatan.lehman

  • EA User
  • **
  • Posts: 45
  • Karma: +0/-0
    • View Profile
Re: VersionControlAdd not working (V14.0)
« Reply #4 on: June 06, 2022, 05:04:30 pm »
Go it.
Can you explain a bit more about the path name of the file? Can it be anything as long as it is unique?
I see in your script you use
subfolder & package.PackageGUID + cleanFileName(package.Name)

I assume the subfolder is what I see in the repo as ea1,ea2 etc. Is the number significant or does EA just put a fixed number in each folder?

Regarding the name of the file - the files created by EA have names such as 5A2A442EEFD0.xml  - and when I look in the xml file I see that the name comes from the line
<UML:Package name="hw_monitor_common" xmi.id="EAPK_7D8C608A_0FEE_484c_8B47_5A2A442EEFD0"

So EA only uses the last part of the xmi.id
I assume that in your script you use the  PackageGUID  and cleanFileName(package.Name) to generate a unique name?

Does cleanFileName() just get rid of spaces, or perhaps non alphanumerics ?
Thanks




Geert Bellekens

  • EA Guru
  • *****
  • Posts: 11849
  • Karma: +460/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: VersionControlAdd not working (V14.0)
« Reply #5 on: June 06, 2022, 09:26:24 pm »
cleanFileName strips the name of the file from all invalid characters for a filename. (think "/", ":", etc...)
The subfolder is whatever you want it to be. You don't need a subfolder, you can also put everything in the same folder, but it makes finding the relevant files harder if you have hundreds (or thousands) of files.
We group them by subject and domain.

The name can be anything, but it has to be unique (within the folder). Using the GUID is an easy way to make your file unique.
The name of the package is useful when searching for the correct file.
Putting the (cleaned) name of the package first (instead of last like we did) makes it easier to order your files alphabetically.

Geert

yonatan.lehman

  • EA User
  • **
  • Posts: 45
  • Karma: +0/-0
    • View Profile
Re: VersionControlAdd not working (V14.0)
« Reply #6 on: June 06, 2022, 10:15:41 pm »
Got it - thanks

yonatan.lehman

  • EA User
  • **
  • Posts: 45
  • Karma: +0/-0
    • View Profile
Re: VersionControlAdd not working (V14.0)
« Reply #7 on: June 06, 2022, 10:18:02 pm »
Tried to mark Geert's message as "Helpful"
Got a
" Sorry, you can't repeat a karma action without waiting 1 hours."

Seems they didn't take Geert's helpfulness into account !!! Cheers!