-
-
Notifications
You must be signed in to change notification settings - Fork 455
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
Added custom name for favorites item #601
Conversation
IgorGalarraga
commented
Sep 16, 2016
•
edited
Loading
edited
- Refs: Assing new name and rename items in Favorites list #599
- Custom name for favorites item.
- Recent item name is now full path.
- Very initial implementation. My first contact with Python.
- TODO:
- Old settings file (~/.config/git-cola/settings) compatible.
- Unify 2 prompt windows when add favorite on one window.
- Traductions for new strings.
- Add rename line on contextual menu.
- Extend renaming to recent repo list.
- Pass Travis C
Recent item name is now full path.
Thanks for this first version. It looks like we're on the right track. The backwards-compatibility thing is probably essential to iron out before rolling this in. I'll see if I can lend a hand in the coming weeks. Please run the test suite via Let me know if you have any questions. I'll do a thorough review of this first version over the weekend. |
I haven't tried the patch, but I wonder if it's sane to rather use the what should be in the git description file? - Stack Overflow |
@Lin-Buo-Ren Is the first time that I ear about .git/description file for GitWeb application. Thanks!.
|
@davvid I know that the backwards-compatibility is very important, but it seem difficult for me and for now with my limited knowledge on Python, anyway, I will try to do it. |
Now automatically "import" old format favorites list saved on settings.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Getting really close. After we address these last notes this looks just about ready to go. Thanks again.
if not self.verify(bookmark): | ||
missing_bookmarks.append(bookmark) | ||
else: | ||
update_bookmarks.append(new_bookmark) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like we're dealing with the old bookmarks format in self.remove_missing()
which is probably a bit too late to upgrade the data.
Instead of doing a try/except
we can check if isinstance(bookmark, dict):
and detect the new format, since the old format will be a string.
A better place to fix this would be to add a separate upgrade()
method and call it from load()
before self.remove_missing()
is called. Try something like this... (if I'm understanding the new format correctly)
def upgrade(self):
"""Upgrade the settings format from v1 to v2"""
if self.bookmarks and not isinstance(self.bookmarks[0], dict):
self.bookmarks = [{'name': os.path.basename(i), 'path': i} for i in self.bookmarks]
this'll allow remove_bookmarks()
to only deal with the new format.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two bookmarks version are a list (of different components). self.remove_missing()
works well on both settings file versions (on my tests), because it deals with whole unit on list not with content, after this parse, the bookmark will be updated.
Yes, try/except
not is more elegant, the use of if isinstance(bookmark, dict):
is the correct choice for this code.
In my first try, I wanted do a first upgrade parse, but I did not know to find the solution in Phyton... thanks for your example.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My comment:
Two bookmarks version are a list (of different components). self.remove_missing() works well on both settings file versions (on my tests), because it deals with whole unit on list not with content, after this parse, the bookmark will be updated.
was an explanation of behavior of self.bookmarks.remove(bookmark)
into def remove_missing(self)
, not for self.remove_missing()
...
|
||
for bookmark in missing_bookmarks: | ||
try: | ||
self.bookmarks.remove(bookmark) | ||
except: | ||
pass | ||
|
||
"""In case of old settings version, clear old bookmars list and fill with new list""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A python idiom is that we really only ever use """
for docstrings. For in-line comments just use # ...
. I guess that probably wasn't clear because the codebase is probably a little terse/under-commented ;-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the clarification.
When add
For better explanation, I attach a patch with working (with problems above) method. Therefore I have changed Also code style has been updated. I am not able to make a prompt window with two text boxes... any help (url, reference, example)? Thanks! |
Simplify the code by upgrading bookmarks immediately instead of making the remove_missing() function deal with the format differences. Related-to: git-cola#599 Related-to: git-cola#601 Signed-off-by: David Aguilar <davvid@gmail.com>
Related-to: git-cola#601 Signed-off-by: David Aguilar <davvid@gmail.com>
Make the code more closely match the original version by homogenizing the data rather than having two code paths. Related-to: git-cola#601 Signed-off-by: David Aguilar <davvid@gmail.com>
Related-to: git-cola#601 Signed-off-by: David Aguilar <davvid@gmail.com>
Related-to: git-cola#601 Signed-off-by: David Aguilar <davvid@gmail.com>
* rename-favorites: doc: update v2.9 release notes draft bookmarks: use settings.rename_bookmark() settings: add rename_bookmark() method bookmarks: wrap long line startup: remove repeated code settings: small style tweaks settings: upgrade bookmarks immediately after loading Added favorites list item renaming functionality Bugfix: default repo now working again on favorites. Bugfix: startup problem on launching git-cola in no git repo path Code style Using isinstance(bookmark,dict) instead of use try/except Backwards-compatibility with old settings file Automatically updates old settins to new bookmarks make test passed for last modification. Added custom name for favorites item Closes git-cola#599 Closes git-cola#601 Signed-off-by: David Aguilar <davvid@gmail.com>