Iceberg - finding deleted classes, reverting versions?

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

Iceberg - finding deleted classes, reverting versions?

Tim Mackinnon
Hi - I am interested in what the future holds with Iceberg for things like finding deleted classes or reverting to older versions of things.

As we tend to use lots of classes in Smalltalk (and view them as cheap) - I often create them, then move behaviour around and delete things I don’t need anymore. However, if you want to recover one of those classes - with Envy there was a useful concept of “show me deleted classes in a package” and you would get a list that you could then browse and recover from.  Even older squeaks had some nice tools to pull this information from the .changes file (and while not quite the same as envy, it did let a solo developer work efficiently).

So I was a bit surprised yesterday in Pharo 6.1 - to struggle to find a class I knew that I had deleted. There seemed to be no easy way to do this - and I thought there was somewhere that had that “Available/Deleted classes” menu. Eventually I went to iceberg and browsed older versions of my package and with some riffing - managed to find what a I wanted - but it definitely seemed harder than it should be - for a concept that feels natural to us.

I’ve heard it mentioned that we might get “versions” behaviour back via git on a method or existing class - but what about Deleted classes - is this something we will be able to do more easily?

Tim
Reply | Threaded
Open this post in threaded view
|

Re: Iceberg - finding deleted classes, reverting versions?

Sean P. DeNigris
Administrator
Tim Mackinnon wrote
> Hi - I am interested in what the future holds with Iceberg for things like
> finding deleted classes or reverting to older versions of things.

Great question! It used to be in the Change Sorter that delections were
logged and reversible. At some point that stopped working and then I moved
to git so I don't know if it was ever fixed. Obviously, that only looks back
w/in the current image which doesn't fully solve your issue. The cool thing
about git is that we inherit all its functionality - the good and bad. So
iot got me wondering whether we could drop down to the command line for the
time being. After some googling and experimentation, I came up with the
following:

    git log --full-history -- */{{className}}.class/properties.json

NB. I had to add the properties.json because directories don't work, but
that may not be needed with Tonel



-----
Cheers,
Sean
--
Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html

Cheers,
Sean
Reply | Threaded
Open this post in threaded view
|

Re: Iceberg - finding deleted classes, reverting versions?

Tim Mackinnon
Hi Sean - that is an excellent reply, I didn’t quite get your fu to work - but if you look up how to find deleted classes in git they give the following:

git log --diff-filter=D --summary

This gives you a git list of checkins and shows you the checkin comment, along with the list of files that were deleted (this is using tonel format, so its quite clear).

A bit more man help gives a better:

git log --diff-filter=D --summary --pretty='format:%cd|%h|%cn%n%s%n

Which will output something a bit more like what I think you have to use to then understand how to find your change (the %h is the short hash with the Repository explorer in the new Iceberg shows). So you then get something like this:

Mon Jun 11 01:33:59 2018 +0100|65363ad|Tim Mackinnon
Refactor to a more consistent design with support for a basic link resolver

 delete mode 100644 src/PrismicDemo/PrismicBlock.class.st
 delete mode 100644 src/PrismicDemo/PrismicSpan.class.st
 delete mode 100644 src/PrismicDemo/PrismicSpannedText.class.st
 delete mode 100644 src/PrismicDemo/PrismicTextSpan.class.st

Wed Jun 6 19:05:07 2018 +0100|4bea74d|macta
Better handling of more data types for improved demo

 delete mode 100644 src/PrismicDemo/Text.extension.st


This does highlight a few more thing though (and possibly future things to implement) - there is no search in the Repository list, so you have to scroll down yourself.

Having found the class of interest - if I want to restore it, you are a bit on your own here too, as I think the “Revert Change” menu option (regardless of where you click) is going to try and recover the whole checkin and not let you cherry pick the class you want. You can of course at least see the source in the middle pane, and copy paste each method (but it could be a bit tedious).

Possibly you might then be able to do this:

git checkout 65363ad src/PrismicDemo/PrismicBlock.class.st

I’m not sure how Pharo will then react to this command line jiggery - as I keep getting an error : error: pathspec 'PrismicDemo/PrismicBlock.class.st' did not match any file(s) known to git.

But I suspect its something like that?

Tim

On 13 Jun 2018, at 17:23, Sean P. DeNigris <[hidden email]> wrote:

Tim Mackinnon wrote
Hi - I am interested in what the future holds with Iceberg for things like
finding deleted classes or reverting to older versions of things.

Great question! It used to be in the Change Sorter that delections were
logged and reversible. At some point that stopped working and then I moved
to git so I don't know if it was ever fixed. Obviously, that only looks back
w/in the current image which doesn't fully solve your issue. The cool thing
about git is that we inherit all its functionality - the good and bad. So
iot got me wondering whether we could drop down to the command line for the
time being. After some googling and experimentation, I came up with the
following:

   git log --full-history -- */{{className}}.class/properties.json

NB. I had to add the properties.json because directories don't work, but
that may not be needed with Tonel



-----
Cheers,
Sean
--
Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html


Reply | Threaded
Open this post in threaded view
|

Re: Iceberg - finding deleted classes, reverting versions?

Sean P. DeNigris
Administrator
Tim Mackinnon wrote
> I didn’t quite get your fu to work

Interesting.

When I searched for commits affecting the deleted class SuDebianKey:

$ git log --full-history -- */SuDebianKey.class/properties.json

I got back a list of commits (obviously with the last chronologically being
the deletion):

commit a38fbced4abec59ff9879d4c607da80dc89b6637
Author: Sean DeNigris <[hidden email]>
Date:   Mon Jan 30 17:13:58 2017 -0500

    Extract Lots to ComputerWorld, Absorb Rest of Old ScriptingBase Project

commit 61175745d57c60a1707d5e2f9a2fc92e6c19a6ea
Author: Sean DeNigris <[hidden email]>
Date:   Sat Aug 20 17:14:12 2016 -0400

    Basket O' Enhancements
...



-----
Cheers,
Sean
--
Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html

Cheers,
Sean
Reply | Threaded
Open this post in threaded view
|

Re: Iceberg - finding deleted classes, reverting versions?

Tim Mackinnon
Hi Sean - I tried it again, and it worked:

git log --full-history -- */PrismicBlock.class*

(I got my wildcard slightly wrong for tonel format) - although the beauty of the one I gave was that it shows you all deleted classes (in case you don’t know the name)

I’m still confused why I can’t checkout the deleted class though - damn you git, for the cryptic error: : error: pathspec 'PrismicDemo/PrismicBlock.class.st' did not match any file(s) known to git.

I was hoping a quick hack to iceberg might be to OSProcess a few choice git commands to help us along while we work out better ways to do things.

Tim

On 13 Jun 2018, at 21:53, Sean P. DeNigris <[hidden email]> wrote:

Tim Mackinnon wrote
I didn’t quite get your fu to work

Interesting.

When I searched for commits affecting the deleted class SuDebianKey:

$ git log --full-history -- */SuDebianKey.class/properties.json

I got back a list of commits (obviously with the last chronologically being
the deletion):

commit a38fbced4abec59ff9879d4c607da80dc89b6637
Author: Sean DeNigris <[hidden email]>
Date:   Mon Jan 30 17:13:58 2017 -0500

   Extract Lots to ComputerWorld, Absorb Rest of Old ScriptingBase Project

commit 61175745d57c60a1707d5e2f9a2fc92e6c19a6ea
Author: Sean DeNigris <[hidden email]>
Date:   Sat Aug 20 17:14:12 2016 -0400

   Basket O' Enhancements
...



-----
Cheers,
Sean
--
Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html


Reply | Threaded
Open this post in threaded view
|

Re: Iceberg - finding deleted classes, reverting versions?

Guillermo Polito
Hi,

Regarding history, right now we have a history browser implemented as a Calypso plugin, that is open using context menu => history or the little box button on the top right of the method pane (second button from the left in the picture):

Screen Shot 2018-06-14 at 09.34.24.png

That button will nowadays only be shown if the method's package is linked to an iceberg repository.
Once you click it, you will have the entire history of the method.

Screen Shot 2018-06-14 at 09.47.46.png

With the possibility to install that version of the method (among others).

Now, regarding the recovery of deleted classes/methods, have you tried the repository browser?
Go to Iceberg, right click on a repository and select "Repository".
You can there select a commit in history and then in the tabs below see the diff between
 - your current version and the selected commit
 - the selected commit and its main parent

Of course any of these can be improved, but if you have concrete requests, it is much easier :)


Guille

On Wed, Jun 13, 2018 at 11:22 PM Tim Mackinnon <[hidden email]> wrote:
Hi Sean - I tried it again, and it worked:

git log --full-history -- */PrismicBlock.class*

(I got my wildcard slightly wrong for tonel format) - although the beauty of the one I gave was that it shows you all deleted classes (in case you don’t know the name)

I’m still confused why I can’t checkout the deleted class though - damn you git, for the cryptic error: : error: pathspec 'PrismicDemo/PrismicBlock.class.st' did not match any file(s) known to git.

I was hoping a quick hack to iceberg might be to OSProcess a few choice git commands to help us along while we work out better ways to do things.

Tim

On 13 Jun 2018, at 21:53, Sean P. DeNigris <[hidden email]> wrote:

Tim Mackinnon wrote
I didn’t quite get your fu to work

Interesting.

When I searched for commits affecting the deleted class SuDebianKey:

$ git log --full-history -- */SuDebianKey.class/properties.json

I got back a list of commits (obviously with the last chronologically being
the deletion):

commit a38fbced4abec59ff9879d4c607da80dc89b6637
Author: Sean DeNigris <[hidden email]>
Date:   Mon Jan 30 17:13:58 2017 -0500

   Extract Lots to ComputerWorld, Absorb Rest of Old ScriptingBase Project

commit 61175745d57c60a1707d5e2f9a2fc92e6c19a6ea
Author: Sean DeNigris <[hidden email]>
Date:   Sat Aug 20 17:14:12 2016 -0400

   Basket O' Enhancements
...



-----
Cheers,
Sean
--
Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html




--

   

Guille Polito

Research Engineer

Centre de Recherche en Informatique, Signal et Automatique de Lille

CRIStAL - UMR 9189

French National Center for Scientific Research - http://www.cnrs.fr


Web: http://guillep.github.io

Phone: +33 06 52 70 66 13

Reply | Threaded
Open this post in threaded view
|

Re: Iceberg - finding deleted classes, reverting versions?

Tim Mackinnon
Hi Guille - I have tried the repo browser with the new iceberg loaded in Pharo 6.1 and I couldn’t see how it helps me? (I will make a firm point of using 7 now as I think I’ve now got a reasonable grasp of how things should work).

From the threads below - how would I find the commit with my missing class - Sean has pointed me to a git query that helps with that (and presumablyq is something we can plug into iceberg - maybe I will even take a look).

Having identified the hash with the class I want - getting to it is awkward (there is no search - again pretty easy for us to plug in, but something to do)

Having got to my commit - how can I retrieve one class? Maybe this is something only in Pharo 7 with Calypso? All I can see are diffs - so I’d have to copy and paste 20 methods and a class def. doable,  but painful. I’m hoping there is a way to get a shadow copy of the commit from the tonel file and then use it to restore classes and methods? As this sounds like a decent chunk of work, I’m guessing it’s not done yet?

As a fallback, Any thoughts on why git won’t let me checkout a file from that commit? Something about the pathspec (is it mangled in some way)? And if I could restore a tonel file - would iceberg then recognise it to bring it back in, or Would I need to use some filestream foo to do that (as this would at least be a viable workaround for now)?

Tim

Sent from my iPhone



Sent from my iPhone
On 14 Jun 2018, at 08:52, Guillermo Polito <[hidden email]> wrote:

Hi,

Regarding history, right now we have a history browser implemented as a Calypso plugin, that is open using context menu => history or the little box button on the top right of the method pane (second button from the left in the picture):

<Screen Shot 2018-06-14 at 09.34.24.png>

That button will nowadays only be shown if the method's package is linked to an iceberg repository.
Once you click it, you will have the entire history of the method.

<Screen Shot 2018-06-14 at 09.47.46.png>

With the possibility to install that version of the method (among others).

Now, regarding the recovery of deleted classes/methods, have you tried the repository browser?
Go to Iceberg, right click on a repository and select "Repository".
You can there select a commit in history and then in the tabs below see the diff between
 - your current version and the selected commit
 - the selected commit and its main parent

Of course any of these can be improved, but if you have concrete requests, it is much easier :)


Guille

On Wed, Jun 13, 2018 at 11:22 PM Tim Mackinnon <[hidden email]> wrote:
Hi Sean - I tried it again, and it worked:

git log --full-history -- */PrismicBlock.class*

(I got my wildcard slightly wrong for tonel format) - although the beauty of the one I gave was that it shows you all deleted classes (in case you don’t know the name)

I’m still confused why I can’t checkout the deleted class though - damn you git, for the cryptic error: : error: pathspec 'PrismicDemo/PrismicBlock.class.st' did not match any file(s) known to git.

I was hoping a quick hack to iceberg might be to OSProcess a few choice git commands to help us along while we work out better ways to do things.

Tim

On 13 Jun 2018, at 21:53, Sean P. DeNigris <[hidden email]> wrote:

Tim Mackinnon wrote
I didn’t quite get your fu to work

Interesting.

When I searched for commits affecting the deleted class SuDebianKey:

$ git log --full-history -- */SuDebianKey.class/properties.json

I got back a list of commits (obviously with the last chronologically being
the deletion):

commit a38fbced4abec59ff9879d4c607da80dc89b6637
Author: Sean DeNigris <[hidden email]>
Date:   Mon Jan 30 17:13:58 2017 -0500

   Extract Lots to ComputerWorld, Absorb Rest of Old ScriptingBase Project

commit 61175745d57c60a1707d5e2f9a2fc92e6c19a6ea
Author: Sean DeNigris <[hidden email]>
Date:   Sat Aug 20 17:14:12 2016 -0400

   Basket O' Enhancements
...



-----
Cheers,
Sean
--
Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html




--

   

Guille Polito

Research Engineer

Centre de Recherche en Informatique, Signal et Automatique de Lille

CRIStAL - UMR 9189

French National Center for Scientific Research - http://www.cnrs.fr


Web: http://guillep.github.io

Phone: +33 06 52 70 66 13

Reply | Threaded
Open this post in threaded view
|

Re: Iceberg - finding deleted classes, reverting versions?

Guillermo Polito

On Thu, Jun 14, 2018 at 10:17 AM Tim Mackinnon <[hidden email]> wrote:
Hi Guille - I have tried the repo browser with the new iceberg loaded in Pharo 6.1 and I couldn’t see how it helps me? (I will make a firm point of using 7 now as I think I’ve now got a reasonable grasp of how things should work).
From the threads below - how would I find the commit with my missing class - Sean has pointed me to a git query that helps with that (and presumablyq is something we can plug into iceberg - maybe I will even take a look).

> git log --full-history -- */{{className}}.class/properties.json

Yes, this is definitely *doable* but nobody made the effort to do it yet.
Doing it well should take into account what format the code is stored (filetree/tonel) and consider that the format would have changed in the middle of the history.
If somebody wants to give it a try I can give some advice.
 

Having identified the hash with the class I want - getting to it is awkward (there is no search - again pretty easy for us to plug in, but something to do)

Yes, I've found this issue that also in the past. It's not common to me to be looking for a commit like that, and when it is the UI is cumbersome. From the backend, you can always inspect the repository and do

repository lookupCommit: aCommitishString

For example:

repository lookupCommit: '726254360c987b9b3472a6098b5869970e819cc9'


Having got to my commit - how can I retrieve one class? Maybe this is something only in Pharo 7 with Calypso? All I can see are diffs - so I’d have to copy and paste 20 methods and a class def. doable,  but painful. I’m hoping there is a way to get a shadow copy of the commit from the tonel file and then use it to restore classes and methods? As this sounds like a decent chunk of work, I’m guessing it’s not done yet?

Well on the items of the diff you have a "Revert change" option. That should work on most of the cases.
I know that it would be also useful to be able to easily browse a commit. I've opened an issue.


For the moment what I do from the backend (inspecting):

aCommit fileSystem

and you'll get a file system on the commit. So you'll see the exact files of the commit but "uniterpreted". That is, packages will be seen as repositories and not as packages.
 

As a fallback, Any thoughts on why git won’t let me checkout a file from that commit? Something about the pathspec (is it mangled in some way)?

I don't quite understand. Can you paste here your command?
 
And if I could restore a tonel file - would iceberg then recognise it to bring it back in,

Nope, Iceberg never reads from the disk working copy. Iceberg reads directly from te blob.
 
or Would I need to use some filestream foo to do that (as this would at least be a viable workaround for now)?

You can try to read it using Tonel? I don't know exactly how to use tonel directly, I'll let others answer better.
 

Tim

Sent from my iPhone



Sent from my iPhone
On 14 Jun 2018, at 08:52, Guillermo Polito <[hidden email]> wrote:

Hi,

Regarding history, right now we have a history browser implemented as a Calypso plugin, that is open using context menu => history or the little box button on the top right of the method pane (second button from the left in the picture):

<Screen Shot 2018-06-14 at 09.34.24.png>

That button will nowadays only be shown if the method's package is linked to an iceberg repository.
Once you click it, you will have the entire history of the method.

<Screen Shot 2018-06-14 at 09.47.46.png>

With the possibility to install that version of the method (among others).

Now, regarding the recovery of deleted classes/methods, have you tried the repository browser?
Go to Iceberg, right click on a repository and select "Repository".
You can there select a commit in history and then in the tabs below see the diff between
 - your current version and the selected commit
 - the selected commit and its main parent

Of course any of these can be improved, but if you have concrete requests, it is much easier :)


Guille

On Wed, Jun 13, 2018 at 11:22 PM Tim Mackinnon <[hidden email]> wrote:
Hi Sean - I tried it again, and it worked:

git log --full-history -- */PrismicBlock.class*

(I got my wildcard slightly wrong for tonel format) - although the beauty of the one I gave was that it shows you all deleted classes (in case you don’t know the name)

I’m still confused why I can’t checkout the deleted class though - damn you git, for the cryptic error: : error: pathspec 'PrismicDemo/PrismicBlock.class.st' did not match any file(s) known to git.

I was hoping a quick hack to iceberg might be to OSProcess a few choice git commands to help us along while we work out better ways to do things.

Tim

On 13 Jun 2018, at 21:53, Sean P. DeNigris <[hidden email]> wrote:

Tim Mackinnon wrote
I didn’t quite get your fu to work

Interesting.

When I searched for commits affecting the deleted class SuDebianKey:

$ git log --full-history -- */SuDebianKey.class/properties.json

I got back a list of commits (obviously with the last chronologically being
the deletion):

commit a38fbced4abec59ff9879d4c607da80dc89b6637
Author: Sean DeNigris <[hidden email]>
Date:   Mon Jan 30 17:13:58 2017 -0500

   Extract Lots to ComputerWorld, Absorb Rest of Old ScriptingBase Project

commit 61175745d57c60a1707d5e2f9a2fc92e6c19a6ea
Author: Sean DeNigris <[hidden email]>
Date:   Sat Aug 20 17:14:12 2016 -0400

   Basket O' Enhancements
...



-----
Cheers,
Sean
--
Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html




--

   

Guille Polito

Research Engineer

Centre de Recherche en Informatique, Signal et Automatique de Lille

CRIStAL - UMR 9189

French National Center for Scientific Research - http://www.cnrs.fr


Web: http://guillep.github.io

Phone: +33 06 52 70 66 13



--

   

Guille Polito

Research Engineer

Centre de Recherche en Informatique, Signal et Automatique de Lille

CRIStAL - UMR 9189

French National Center for Scientific Research - http://www.cnrs.fr


Web: http://guillep.github.io

Phone: +33 06 52 70 66 13