Git overriding repo load from different source

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

Git overriding repo load from different source

Peter Uhnak
Hi,

I'm trying to load local package over git one...
basically:

Projects A and B.
A depends on B.
A loads B from its BaselineOfA, the reference points to github.

Now I have also local copy of B git repository, and I would like to
either
a) Override the load of B with local B (so the packages will point to local instead of remote).
Currently it fails on MetacelloRepositorySpec>>hasNoLoadConflicts: because each (local and git) repo points to different place.
This would be useful if I want to make change to B AFTER the project B is already loaded.

b) Add all packages from B to local B repo (same as manually using "add to package..." in Monticello Browser")
This will work only if both the repos have the same packages, so probably not that useful. (i.e. no code differences)

c) Override the GitHub B repository in the BaselineOfA BEFORE the project is loaded.
This would require some mapping in Monticello browser, I've seen something like "repositoryOverrides:" but I don't know how it works.
This would be useful if I knew beforehand that I want to make changes also to B.

So how would one go about this? Having option "c)" would be probably the best; I can live without "a)". :)

Any pointers appreciated,
Peter
Reply | Threaded
Open this post in threaded view
|

Re: Git overriding repo load from different source

Peter Uhnak
d) unload all B packages, remove B github repo, load B locally
However currently I can only unload packages one at a time manually, instead of all related to a repo.

Peter
Reply | Threaded
Open this post in threaded view
|

Re: Git overriding repo load from different source

Peter Uhnak
e) having separate baseline method which does not load github packages and expects that they are already loaded
But since baseline only uses single method I don't see how this could be done.
Reply | Threaded
Open this post in threaded view
|

Re: Git overriding repo load from different source

Thierry Goubier
In reply to this post by Peter Uhnak
Hi Peter,

I'm not sure how to answer all those cases (did I remember a
conversation during PharoDays?).

Can you elaborate on a) and the failure? Because I remember looking at
the ability to override conflicts in Metacello by just saying:
onConflict: [:ex | ex allow ]

(for example:
Metacello new
   baseline: 'Metacello';
   repository: 'github://dalehenrich/metacello-work:master/repository';
   onConflict: [:ex | ex allow];
   load
)

But, overall, for such a need, I would see two approaches:

- a cache-type repository which overrides loads, as the MC package-cache
is doing, based on package name and version (which is bad).

- Metacello overrides, which may already exist but I'm not knowledgeable
enough.

Thierry

Le 21/03/2015 14:41, Peter Uhnák a écrit :

> Hi,
>
> I'm trying to load local package over git one...
> basically:
>
> Projects A and B.
> A depends on B.
> A loads B from its BaselineOfA, the reference points to github.
>
> Now I have also local copy of B git repository, and I would like to
> either
> a) Override the load of B with local B (so the packages will point to
> local instead of remote).
> Currently it fails on MetacelloRepositorySpec>>hasNoLoadConflicts:
> because each (local and git) repo points to different place.
> This would be useful if I want to make change to B AFTER the project B
> is already loaded.



>
> b) Add all packages from B to local B repo (same as manually using "add
> to package..." in Monticello Browser")
> This will work only if both the repos have the same packages, so
> probably not that useful. (i.e. no code differences)
>
> c) Override the GitHub B repository in the BaselineOfA BEFORE the
> project is loaded.
> This would require some mapping in Monticello browser, I've seen
> something like "repositoryOverrides:" but I don't know how it works.
> This would be useful if I knew beforehand that I want to make changes
> also to B.
>
> So how would one go about this? Having option "c)" would be probably the
> best; I can live without "a)". :)
>
> Any pointers appreciated,
> Peter


Reply | Threaded
Open this post in threaded view
|

Re: Git overriding repo load from different source

Dale Henrichs-3
In reply to this post by Peter Uhnak
Peter, sorry for not answering sooner ... I keep an eye out for posts
with Metacello in the subject line so I missed this one ...

So if i understand your question, you have a GitHub project that you
normally download like this:

   Metacello new
     baseline: 'Sample';
     repository: 'github://GsDevKit/sampleProject:master/repository';
     load.

now you have cloned the repository to a local git repository:

   cd /opt/git
   git clone [hidden email]:GsDevKit/sampleProject.git

and you can directly load the project like this:

   Metacello new
     baseline: 'Sample';
     repository: 'filetree:'///opt/git/sampleProject/repository';
     load.

but in another configuration (that you may not control) there is
dependency upon Sample that looks like this:

   spec baseline: 'Sample' with: [ spec repository:
'github://GsDevKit/sampleProject:master/repository' ].

and you are wondering how you can force you local clone to be used ...
is that correct?

If so then the trick is to use the Metacello `lock` ... Do the following
BEFORE loading the project that depends upon you sample project:

   Metacello new
     baseline: 'Sample';
     repository: 'filetree:'///opt/git/sampleProject/repository';
     lock.

Then whenever Metacello finds a dependency upon 'Sample' the local clone
(the `lock`ed) project will be used instead.

This is use case is the primary reason for the existence of the `lock`
command. Also note that you need to use the scripting api for all loads
to make sure that the lock is honored. Finally you can use the onLock:
message to break the lock in certain cases ... the default Metacello
load honors all locks (a Warning is dumped to the transcript) ...

As Thierry mentions, you should be using the latest version of Metacello
on github ...

If I missed the mark here let know ...

Dale



On 3/21/15 6:41 AM, Peter Uhnák wrote:

> Hi,
>
> I'm trying to load local package over git one...
> basically:
>
> Projects A and B.
> A depends on B.
> A loads B from its BaselineOfA, the reference points to github.
>
> Now I have also local copy of B git repository, and I would like to
> either
> a) Override the load of B with local B (so the packages will point to
> local instead of remote).
> Currently it fails on MetacelloRepositorySpec>>hasNoLoadConflicts:
> because each (local and git) repo points to different place.
> This would be useful if I want to make change to B AFTER the project B
> is already loaded.
>
> b) Add all packages from B to local B repo (same as manually using
> "add to package..." in Monticello Browser")
> This will work only if both the repos have the same packages, so
> probably not that useful. (i.e. no code differences)
>
> c) Override the GitHub B repository in the BaselineOfA BEFORE the
> project is loaded.
> This would require some mapping in Monticello browser, I've seen
> something like "repositoryOverrides:" but I don't know how it works.
> This would be useful if I knew beforehand that I want to make changes
> also to B.
>
> So how would one go about this? Having option "c)" would be probably
> the best; I can live without "a)". :)
>
> Any pointers appreciated,
> Peter


Reply | Threaded
Open this post in threaded view
|

Re: Git overriding repo load from different source

Peter Uhnak
In reply to this post by Thierry Goubier
I'm not sure how to answer all those cases
Those were just options that came to my mind how to solve it - practically just one is needed.
 
(did I remember a conversation during PharoDays?).
We spoke only very briefly about something else since I didn't use Git at the time yet.
 
Can you elaborate on a) and the failure? Because I remember looking at the ability to override conflicts in Metacello by just saying: onConflict: [:ex | ex allow ]
 Yes, onConflict: solves the overriding issue, thanks!

Peter
Reply | Threaded
Open this post in threaded view
|

Re: Git overriding repo load from different source

Peter Uhnak
In reply to this post by Dale Henrichs-3
On Sun, Mar 22, 2015 at 11:19 PM, Dale Henrichs <[hidden email]> wrote:
I keep an eye out for posts with Metacello in the subject line so I missed this one ...
I'll keep that in mind next time. 
 
If so then the trick is to use the Metacello `lock` ... Do the following BEFORE loading the project that depends upon you sample project:
Combined with onConflict: mentioned by Thierry this works like a charm, thanks a lot. :)
 
(a Warning is dumped to the transcript) ...
I got a warning prompt which I had confirm ("proceed") couple of times, but that's just a detail.

Thanks a lot!

Peter

Reply | Threaded
Open this post in threaded view
|

Re: Git overriding repo load from different source

Jan Blizničenko
Hello

I was able to get by those warnings automatically by adding onLock: [ :ex | ex disallow ]; in addition to onConflict

Metacello new
baseline: '...'
repository: 'gitfiletree:///.../repository'
onConflict: [ :ex | ex allow ];
onLock: [ :ex | ex disallow ];
load

I'm not sure whether it couldn't cause any problems, but it seems to be working.

Jan

Peter Uhnák wrote
> If so then the trick is to use the Metacello `lock` ... Do the following
> BEFORE loading the project that depends upon you sample project:
>
Combined with onConflict: mentioned by Thierry this works like a charm,
thanks a lot. :)


> (a Warning is dumped to the transcript) ...
>
I got a warning prompt which I had confirm ("proceed") couple of times, but
that's just a detail.

Thanks a lot!

Peter
Reply | Threaded
Open this post in threaded view
|

Re: Git overriding repo load from different source

Dale Henrichs-3
In reply to this post by Peter Uhnak


On 3/24/15 11:47 PM, Peter Uhnák wrote:
On Sun, Mar 22, 2015 at 11:19 PM, Dale Henrichs <[hidden email]> wrote:
I keep an eye out for posts with Metacello in the subject line so I missed this one ...
I'll keep that in mind next time. 
 
If so then the trick is to use the Metacello `lock` ... Do the following BEFORE loading the project that depends upon you sample project:
Combined with onConflict: mentioned by Thierry this works like a charm, thanks a lot. :)
 
(a Warning is dumped to the transcript) ...
I got a warning prompt which I had confirm ("proceed") couple of times, but that's just a detail.

Peter,

There's an onWarningLog message that will catch the Warning, log it to the Transcript and proceeed ... there's also an onWarning: message that lets you customize your response ...

Dale
Reply | Threaded
Open this post in threaded view
|

Re: Git overriding repo load from different source

Dale Henrichs-3
In reply to this post by Jan Blizničenko


On 3/25/15 1:35 AM, Jan B. wrote:

> Hello
>
> I was able to get by those warnings automatically by adding onLock: [ :ex |
> ex disallow ]; in addition to onConflict
>
> Metacello new
> baseline: '...'
> repository: 'gitfiletree:///.../repository'
> onConflict: [ :ex | ex allow ];
> onLock: [ :ex | ex disallow ];
> load
>
> I'm not sure whether it couldn't cause any problems, but it seems to be
> working.
>

I'd recommend that you not put in the unconditional onConflict: ... at
one point in time the onConflict: was required to handle locks, but
currently the default handler for onConflict: will honor locks and the
default handler for onLock: will dump signal a Warning and then honor
the lock.

Putting in onLock: as you've done _is_ a good way to bypass the onLock:
Warnings ... you can use `honor` instead of `disallow` and `break`
instead of `allow` for the onLock: notification as those messages read a
bit better ...

The interesting onConflict: notifications occur when an incoming project
decides to change the version or repository or configuration type
(BaselineOf or ConfigurationOf) ... so if you care to know when this
type of thing happens, then you can _leave off the onConflict:_ and
you'll get a chance to decide if you want to have that change made to
your system, before it is loaded rather than discover the change after
it is loaded ... this is basically why I added the onLock: message - so
that you weren't tempted to add an uncoditional onConflict: block just
because you were working with locks:)

Dale