Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

History log is restarted when updating Spyder version #591

Closed
spyder-bot opened this issue Feb 17, 2015 · 7 comments
Closed

History log is restarted when updating Spyder version #591

spyder-bot opened this issue Feb 17, 2015 · 7 comments

Comments

@spyder-bot
Copy link
Collaborator

From ccordoba12 on 2011-03-18T15:46:02Z

Unfortunately, the history log is erased/restarted when you update spyder or when you switch versions. This is a kind of a headache for me, since I'm using spyder to do my own work and to develop spyder, so I would like to see that history is preserved in these cases.

Thanks,
Carlos

Original issue: http://code.google.com/p/spyderlib/issues/detail?id=591

@spyder-bot
Copy link
Collaborator Author

From pierre.raybaut on 2011-03-19T06:36:37Z

This is a bug and I'm afraid it's not new.

Only the configuration file .spyder.ini should change when upgrading/downgrading Spyder (and a backup file is created then: .spyder.ini.bak).

This needs to be investigated further because you won't find anywhere in the code a place where the .history.py file is removed. My guess is that there's sometimes a problem when loading the history file -- and I think this may also happen without upgrading/downgrading Spyder.

@spyder-bot
Copy link
Collaborator Author

From ccordoba12 on 2011-03-19T08:31:43Z

I have seen a change only when upgrading/downgrading but I couldn't tell for sure because I don't stay in the same version for too long. I'll try to investigate further then.

@spyder-bot
Copy link
Collaborator Author

From ccordoba12 on 2011-03-20T11:11:01Z

I think I found a clue to this problem: it has to do with the header of the history log.

The header is composed of these lines:

-- coding: utf-8 --

*** Spyder v2.1.0dev -- History log ***

Now, if you go to your .spyder2 dir and change the spyder version in this header to, for example, v2.0.9, and then start spyder, you'll see that your history is gone.

But if you made a copy of .history.py before, and just restore the right version in it (i.e. the one that matches the current spyder version), then history is preserved correctly.

So my guess is that there's some piece of code that tries to match the header version with the running one, and if that's not possible, it somehow restarts the log.

@spyder-bot
Copy link
Collaborator Author

From ccordoba12 on 2011-03-20T14:23:11Z

I've found the solution following the clues I gave myself above!

I put the patch below. As you can see, it's a quite simple fix. Please test it and if ok, merge it!

Cheers,
Carlos

diff -r 0be87ba10451 spyderlib/widgets/shell.py
--- a/spyderlib/widgets/shell.py Sat Mar 19 14:52:58 2011 +0100
+++ b/spyderlib/widgets/shell.py Sun Mar 20 16:17:56 2011 -0500
@@ -499,7 +499,7 @@ class ShellBaseWidget(ConsoleBaseWidget)
rawhistory, _ = encoding.readlines(self.history_filename)
rawhistory = [line.replace('\n', '') for line in rawhistory]
if rawhistory[1] != self.INITHISTORY[1]:

  •            rawhistory = self.INITHISTORY
    
  •            rawhistory[1] = self.INITHISTORY[1]
     else:
         rawhistory = self.INITHISTORY
     history = [line for line in rawhistory \
    

@spyder-bot
Copy link
Collaborator Author

From pierre.raybaut on 2011-03-20T14:49:03Z

This issue was closed by revision 4faa4bfe081d .

Status: Fixed

@spyder-bot
Copy link
Collaborator Author

From pierre.raybaut on 2011-03-20T14:50:37Z

This issue was closed by revision 9b77341788ac .

@spyder-bot
Copy link
Collaborator Author

From pierre.raybaut on 2011-04-24T07:38:40Z

This issue was closed by revision 9b77341788ac .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant