Hi,
I have a question for the Monticello gurus on the list.
I am trying to programatically write the last comitted version of a package to a mcz file and I made the following code snipet for that purpose:
| package version | package := MCPackage named: 'Monticello'. version := MCVersion package: package info: package workingCopy currentVersionInfo. file := FileStream newFileNamed: (FileDirectory default fullNameFor: version fileName). version fileOutOn: file. file close.
This do-it seems to work but what I would like to know if this is the right way of doing it.
Big thanks
Regards, Hernán
On Aug 2, 2004, at 11:19 AM, Hernan Tylim wrote:
Hi,
I have a question for the Monticello gurus on the list.
I am trying to programatically write the last comitted version of a package to a mcz file and I made the following code snipet for that purpose:
| package version | package := MCPackage named: 'Monticello'. version := MCVersion package: package info: package workingCopy currentVersionInfo. file := FileStream newFileNamed: (FileDirectory default fullNameFor: version fileName). version fileOutOn: file. file close.
This do-it seems to work but what I would like to know if this is the right way of doing it.
That will work, although note that if the package has been modified since the last committed version, this will create a new version instead of writing out the old one. What's odd about it, however, is that you're creating a new MCVersion instance rather than using an existing one. In some rare cases (for example, the package gets changed but somehow the modified flag isn't set) this could end up with two version files with the same UUID but slightly different contents. So you're bettter to look for the old version instance:
version := package workingCopy repositoryGroup versionWithInfo: package workingCopy currentVersionInfo.
Avi
Thanks Avi,
I didn't know how to get an existing MCVersion. I had thought that I might need to create them lazily as it was done before with PackageInfo instances.
version := package workingCopy repositoryGroup versionWithInfo: package workingCopy currentVersionInfo.
Looking at #MCWorkingCopy>>currentVersionInfo I see that the method will save a new version if exists uncomitted changes. So to get the last comitted version should I use <package workingCopy ancestors first>, instead?
Thanks a lot Avi. Monticello is really great.
Regards, Hernán
----- Original Message ----- From: "Avi Bryant" avi@beta4.com To: "The general-purpose Squeak developers list" squeak-dev@lists.squeakfoundation.org Sent: Wednesday, August 04, 2004 2:46 PM Subject: Re: [Q][Monticello] snipet for saving a mcz file
| package version | package := MCPackage named: 'Monticello'. version := MCVersion package: package info: package workingCopy currentVersionInfo. file := FileStream newFileNamed: (FileDirectory default fullNameFor: version fileName). version fileOutOn: file. file close.
That will work, although note that if the package has been modified since the last committed version, this will create a new version instead of writing out the old one. What's odd about it, however, is that you're creating a new MCVersion instance rather than using an existing one. In some rare cases (for example, the package gets changed but somehow the modified flag isn't set) this could end up with two version files with the same UUID but slightly different contents. So you're bettter to look for the old version instance:
version := package workingCopy repositoryGroup versionWithInfo: package workingCopy currentVersionInfo.
Avi
On Aug 4, 2004, at 11:45 AM, Hernan Tylim wrote:
Looking at #MCWorkingCopy>>currentVersionInfo I see that the method will save a new version if exists uncomitted changes. So to get the last comitted version should I use <package workingCopy ancestors first>, instead?
Er, <package workingCopy ancestry ancestors first>, I guess. That will be the last version that was either committed or loaded (whichever happened more recently).
Avi
squeak-dev@lists.squeakfoundation.org