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 |
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 |
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: 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
|
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 |
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
|
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): 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. 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 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
|
On Thu, Jun 14, 2018 at 10:17 AM Tim Mackinnon <[hidden email]> wrote:
> 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.
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'
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.
I don't quite understand. Can you paste here your command?
Nope, Iceberg never reads from the disk working copy. Iceberg reads directly from te blob.
You can try to read it using Tonel? I don't know exactly how to use tonel directly, I'll let others answer better.
|
In reply to this post by Guillermo Polito
Guille - just following up on this thread as I’d like to get more confident with this stuff.
You mentioned a Calypso plugin for versions - where is that? I loaded a recentish P7 image and I don’t see those icons? Is this something I can easily load to try out? As I don’t have that plugin, I’ve followed up on your next suggestion (just to learn how to do this) about looking up a commit having used the command line git history to list all of my deleted classes (I think this might be a useful thing to add to Iceberg BTW). Not sure how to get a repository but I cobbled together the following? (IceLibgitRepository registry detect: [ :r | r name beginsWith: 'Prismic' ]) lookupCommit: '65363ad’. This give me an IceGitCommit - but then what can I easily do with this to try and iterate over deleted classes to try and get the one I’ve identified back? Failing all of this - I went back to the command line again (which should work) - and I’m really wondering if we do something weird with files or paths when checking in? Having got a valid commitID (I used: git log --diff-filter=D --summary —pretty="format:%cd|%h|%cn%n%s%n” ) if I simply run the following (with the id and pathname taken from the output of my previous command I keep getting an error : error: pathspec ‘src/PrismicDemo/PrismicBlock.class.st' did not match any file(s) known to git. Are you able to confirm if you can restore a deleted class from a commit? I’ve tried it on 2 different OSX machines and neither of them works - making me think we do something odd. Tim
|
Just to add more information to this - I did try what was suggested here (it refers to a branch and not a commit id - but heck worth a shot) https://stackoverflow.com/questions/5989592/git-cannot-checkout-branch-error-pathspec-did-not-match-any-files-kn - but nah /refs/heads/src… or /origin/src… didn’t seem to give a recognised path.
Grasping at straws I also tried --ignore-skip-worktree-bits So I’m really curious if anyone else has managed to restore a deleted Pharo class in git? Tim
|
I’d be really interested if someone with lower level GIT knowledge might try a:
For their project - as I don’t understand what I’m doing wrong - and I’d like the comfort of knowing that our source is in a place/state where we can rely on normal git tools in a case of emergency. At the moment, I’m a bit nervous that we are corrupting something . Tim
|
On 25 June 2018 at 19:41, Tim Mackinnon <[hidden email]> wrote:
I'm not sure if this is what you wanted, but I found a test case for for Pharo 7, a deleted class "MultiByteFileStreamTest.class.st" https://github.com/pharo-project/pharo/pull/1031/files#diff-750a25fb99d29cda8c2c388dc18f6c1cL1 From Windows 10 cmd.exe I tried the following (I can't remember which tool installed `git`)... > mkdir C:\temp\test > cd C:\temp\test > git clone [hidden email]:pharo-project/pharo.git > cd pharo\src\Deprecated70 > dir Multi* no result > git checkout e74308e67d9f84 MultiByteFileStreamTest.class.st > dir Multi* Then I compared the file I checked out to the raw file on github and they were identical...
btw, I did get a momentary error "error: pathspec 'src/Deprecated70/MultiByteFileStreamTest.class.st' did not match any file(s) known to git." when I incorrectly did... > cd pharo\src\Deprecated70
> git
git checkout e74308e67d9f84
src/Deprecated70/MultiByteFileStreamTest.class.st
This worked with the longer path... > cd pharo > git git checkout e74308e67d9f84 src/Deprecated70/MultiByteFileStreamTest.class.st cheers -ben |
Hey thanks Ben - this still doesn’t work for me… good idea to try on the Pharo repo itself.
I have a fork of it, which I catch up periodically - so I tried a similar suggestion to you - went into my directory (underneath the src folder) and typed: log --diff-filter=D --summary --graph --pretty='format:%cd | %h | %H | %cn%n-> %s%n’ This gave me: Tue Jun 19 19:28:37 2018 +0200 | 13e81343e | 13e81343e8a23a8d6ca43f1c77b804b8134fc986 | CyrilFerlicot -> Remove now useless logs delete mode 100755 bootstrap/scripts/printFolderContent.sh Mon Jun 18 16:50:19 2018 +0200 | 0433d908d | 0433d908de2987fa0069a47dee1f0794ccbb52c2 | GitHub -> Revert "22161-Add-more-log-to-bootstrap" delete mode 100755 bootstrap/scripts/printFolderContent.sh Thu Jun 14 11:41:16 2018 +0200 | b4a285a61 | b4a285a61d3eb0cc1e642b2fcc242dac7092617f | Marcus Denker -> fix the last sender of #asIcon https://pharo.fogbugz.com/f/cases/22139/fix-the-last-sender-of-asIcon delete mode 100644 src/Polymorph-Widgets-Rules/IconShortcutRule.class.st So then I tried to recover that last one (again at root underneath the src directory) git checkout b4a285a61 src/Polymorph-Widgets-Rules/IconShortcutRule.class.st error: pathspec 'src/Polymorph-Widgets-Rules/IconShortcutRule.class.st' did not match any file(s) known to git. And I still get that dreaded pathspec error. This is on OSX (not windows) - so I’m struggling to understand what I could be doing wrong. It must be something obvious - but damned if I can see how I’m doing anything different to you. And it wouldn’t make sense that git is broken on OSX? Tim
|
And just to add to this - I just did a git clone (git clone [hidden email]:pharo-project/pharo.git) in a fresh directory and can see that same deleted file - and when I try to do a checkout, it gives the path spec error.
This is very weird - is it some osx thing? I will try it on ubuntu - but I feel I must be missing something, like do I need a different prefix on path names (but you didn’t seem to need one)? I’d be very worried if git is acting up… but I still suspect user error here. Tim
|
For the record - I get the same error using those steps on Ubuntu as well. So I must be doing something wrong?
(Note in my message when I pasted the command used - I neglected the git in front of: log --diff-filter=D --summary —pretty="format:%cd | %h | %H | %cn%n-> %s%n”) Tim
|
> You mentioned a Calypso plugin for versions - where is that? I loaded a recentish P7 image and I don’t see those icons? Is this something I can easily load to try out? As soon as a class is inside a package that is managed by iceberg, you should see in Calypso a new button and menu item on methods (called History, with a little box icon). > Not sure how to get a repository but I cobbled together the following? > (IceLibgitRepository registry detect: [ :r | r name beginsWith: 'Prismic' ]) lookupCommit: '65363ad’. > This give me an IceGitCommit - but then what can I easily do with this to try and iterate over deleted classes to try and get the one I’ve identified back? Well there is no magic :). Either you walk the commits (#parent or #newCommitWalk (!! too low level)) and calculate for each a diff against its parent (#diffTo:). Other thing you can do to check how IceGitLog is implemented, using directly libgit. About the git error, I don't have time to check now but, I think it may be something easy that is going under your nose :) You got your commitish from the `git log --diff-filter=D --summary —pretty="format:%cd|%h|%cn%n%s%n”`, didn't you? Then, this means the commitish you got has the file already deleted! So if you want to recover it, you have to check its parent! Can you try (notice the added the ~1) $ git checkout 65363ad~1 src/PrismicDemo/PrismicBlock.class.st ? On Thu, Jun 28, 2018 at 2:32 AM Tim Mackinnon <[hidden email]> wrote:
|
In reply to this post by Tim Mackinnon
On 28 June 2018 at 07:38, Tim Mackinnon <[hidden email]> wrote:
Concrete examples help.
I get the same error when I try checking that file out from b4a285a61
there is no file
Ic So from try clicking the <History> button, and currently at the top you'll see "
b4a28" on Jun 14, and the next one down is "d4b4464". Click the "<>" button to the right of that, then browse back to .../src/Polymorph-Widgets-Rules and now you'll see
Ic So the following works for me... In summary ;), you can't check out a file from a commit that doesn't exist in that commit. HTH cheers -ben |
Thanks Ben - I hadn’t really thought of using the GitHub web ui itself (so many places to choose from ;)
Effectively the ~1 syntax Guille mentioned is exactly what you’ve explained (so that hangs together nicely). Now looking back at the tutorial I had followed, I didn’t notice the ~1 in there. This one will be firmly embedded in my brain for sure. Still, its stuff like this that helps you learn the wider toolset in play. Tim p.s. Appreciate you guys following up with me - it was bugging me in the background. I kept returning to it, annoyed that it didn’t work and should (now completely explained)
|
Free forum by Nabble | Edit this page |