-
-
Notifications
You must be signed in to change notification settings - Fork 137
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
Blame walk #661
Blame walk #661
Conversation
I'm not confident I know how to use it but... If I hit open commit gives:
show file at commit results in an untitled and blank tab with the following in the console:
|
(a) |
I'm not sure what you mean about the blame details. Both options seem to open a version of the file from the past. (a) is HEAD and (b) is the commit corresponding to "this line's commit." Speaking of syntax highlighting, the resulting tabs that are opened have no syntax highlighting; they are opened as plain text for some reason....? |
|
HEAD -> C
HEAD -> E
HEAD -> D
HEAD -> C At this stage, you are not on any branch. This is very useful if you want to look at how the code looked 2 weeks ago. If you make a commit when you have checked out a commit, it will be hard to find that commit again. Hope That explain it a bit better. If you have other questions to git lets take it in the gitter chat. https://gitter.im/divmain/GitSavvy |
Okay, forgive my mentioning of HEAD, but what do you mean "without blame info." Could you show me what it is supposed to look like with blame info? |
Unfortunately is's not an "easy fix" for us. .sublime-syntax is a completely different format so it's not going to happen in the foreseeable future.
Maybe GitSavvy should check for |
@stoivo, in MagicStack/MagicPython/issues/86 they say they aren't likely to migrate away from .tmLanguage. Could you detect that in addition to .sublime-syntax? |
I open a PR for sublime-syntax on MagicStack/MagicPython#86 |
Okay. I would change:
I think "Show file at this line's commit" is okay, though it is really "at this row" or "where the cursor is". For a while I thought "show file at this line's commit" meant that when it opened that version, it would automatically go to those line numbers, which would still be a neat feature. |
New thought for the second: "Show file at this chunk's commit" |
@reagle, Thanks for naming commands with me. It is appreciated. I added one more feature. When to select show file. it jumps to the line you were at. And fixed some other bug when a file is renamed. |
Looks great and the goto line is indeed handy. |
BTW: I think the blame tab should be opened read-only, like the GRAPH tab. |
core/ui_mixins/quick_panel.py
Outdated
@@ -157,6 +157,7 @@ class PaginatedPanel: | |||
limit = 6000 | |||
selected_index = None | |||
on_highlight = None | |||
is_this_selected = None |
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.
If I understand correctly, we need this because the index number of the selected item would be unknown if a generator is used. Instead of adding one more argument here, I suggest using the existing variable selected_index
.
We could check if it is a callable. If it is, just do
if selected_index(entry):
bla bla bla
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.
Yes, I squashed into 514b317, Blame option: Pick a new commit, if you are on a commit, set it as selected.
core/commands/blame.py
Outdated
self.view.run_command("gs_blame_initialize_view") | ||
|
||
|
||
class BlameCommitPanel(PaginatedPanel): |
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.
Would it make more sense to extend it from LogPanel
?
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.
Not really. The only thing in common is format_item
.
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.
But one could argue that LogPanel and PaginatedPanel are only differed by format_item. The on_selection
is almost identical.
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.
Also, BlameCommitPanel and LogPanel are both history-related. I don't see why we shouldn't extend it from LogPanel.
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.
Check this
core/git_mixins/history.py
Outdated
@@ -63,12 +65,13 @@ def log(self, author=None, branch=None, file_path=None, start_end=None, cherry=N | |||
|
|||
return entries | |||
|
|||
def commit_generator(self, limit = 6000): | |||
def commit_generator(self, limit = 6000, follow=False): |
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.
This is related to an earlier refactoring, should we actually pass the arguments branch
and file_path
?
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.
Yes. Generally, I prefer to pass several arguments then to set instance variables. On log it looks a little ugly, but it is very nice and explicit what's all the arguments.
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.
One less important point, this function returns a generator of log entries rather that commits. Maybe log_generator
is a better name for this?
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.
log_generator
seem good since it if calls to log.
"commit_hash": commit_hash, | ||
"filepath": self.file_path, | ||
"lineno": self.find_lineno(), | ||
"lang" : self.view.settings().get('git_savvy.original_syntax', None) |
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.
Nice, any idea to patch the diff view? I don't think the same fix could be applied to diff view.
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.
I think is is already handled https://github.com/divmain/GitSavvy/blob/53b878a5891f15b90f8d796c34c16c44639d0f5e/core/commands/inline_diff.py#L40-L49
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.
Or which diff did you think of?
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.
I am talking about https://github.com/divmain/GitSavvy/blob/53b878a5891f15b90f8d796c34c16c44639d0f5e/core/interfaces/status.py#L261
and
https://github.com/divmain/GitSavvy/blob/53b878a5891f15b90f8d796c34c16c44639d0f5e/core/commands/diff.py#L277
In these functions, the file syntax is detected using the util function but not the default syntax.
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.
I can't think of any way to get that without opening the file and read the syntax, then close it. 👎
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.
We could open the file in the output panel to make it invisible to users.
PS: it turns out we cannot open file directly in the output panel.
https://stackoverflow.com/questions/37905081/open-a-file-in-output-panel
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.
We could also capture the scopes of the file in the output panel to highlight the blame view.
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.
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.
Yes but this can be a separate PR.
1a2c0b6
to
0f1c2e7
Compare
core/git_mixins/history.py
Outdated
@@ -63,12 +65,13 @@ def log(self, author=None, branch=None, file_path=None, start_end=None, cherry=N | |||
|
|||
return entries | |||
|
|||
def commit_generator(self, limit = 6000): | |||
def commit_generator(self, file_path, branch=None, limit=6000, follow=False): |
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.
Is there any reason to switch the order of file_path and branch?
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.
Perhaps something like this?
def log_generator(self, limit=6000, **kwargs):
# Generator for show_log_panel
skip = 0
while True:
logs = self.log(limit=limit, skip=skip, **kwargs)
if not logs:
break
for l in logs:
yield l
skip = skip + limit
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.
Yes
core/commands/log.py
Outdated
self._file_path = file_path | ||
self._branch = branch | ||
sublime.set_timeout_async(self.run_async) | ||
sublime.set_timeout_async(lambda: self.run_async(file_path, branch), 0) | ||
|
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.
These changes are not necessary per se. But they do not hurt.
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.
I have to disagree, the change does hurt, multiple commands get broken. Specifically, any command inheriting from LogMixin
that overrides run_async
and does not support the 2 new arguments.
I'm going to patch the occurrences I found so far, to support this cleaner call type: GsLogByAuthorCommand
, GsLogByBranchCommand
, GsResetCommand
and GsBranchesLogCommand
. See commit 0776af2
Unfortunately this patch did not fix the issue I was seeing in "reset to branch" command, and I have run out of time. Hope you guys can help me again 😅
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.
Just answering my own question, as in commit message: implicitly passing more arguments into kwargs raises an issue in python3, as seen here: http://www.asmeurer.com/python3-presentation/slides.html#15
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.
I have also noticed that reset commands are not working as they should. Thanks for testing
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.
@asfaltboy you are absolutely right. 👍
BTW: "hunk" is already a term in git, so maybe we should use that instead of chunk. |
but I think of |
We also need a help pop up for blame view: https://github.com/divmain/GitSavvy/blob/master/popups/diff_view.html Some more keybinds to navigate between commits should also be considered. |
Should |
I would say neither. Perhaps |
…file When always opening the file with the original syntax if the file extension changes it will be go wrong. I don't think thats a big deal. We can't always find the correct syntax files since some packages uses tmLanguage like https://github.com/MagicStack/MagicPython
I wanted to use the commit description but the syntax does not give it a scope and it's simpler to to use the commit hash. I think it as good to use commit sha as commit message. Maybe even better.
Blame popup option 2 sqash me Fix typoes
core/commands/blame.py
Outdated
@@ -71,8 +72,7 @@ def picked_commit(self, commit_hash): | |||
super().run() | |||
|
|||
|
|||
|
|||
class GsBlameInitializeViewCommand(TextCommand, GitCommand): | |||
class GsBlameInitializeViewCommand(GsHandleVintageousCommand, TextCommand, GitCommand): |
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.
I am sorry, thought of vintage support but apparently forgot. Sorry.
I think the issue is that either you need to call
view.run_command("gs_handle_vintageous")
on line 65
Then you won't need to inherit it here.
This is who it's done in inline diff core/commands/inline_diff.py#L84-L85
@asfaltboy, this should do the trick. |
NOTE: I'm not sure whether this was added in python 3, but passing 3 positional arguments when method expects 1 pos and 2 kwargs, seems to cause an issue...
Hi, I just want to tell you that I will leave for vacation on Wednesday next week, and will probably not reply or make any updated for the coming 5 weeks. |
@stoivo, what needs to be done for this to be merged? If documentation is all that is left, we can document the remaining work in a separate issue, so that this can be merged prior to your vacation. Also, have fun! |
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.
core/commands/log.py
Outdated
self._file_path = file_path | ||
self._branch = branch | ||
sublime.set_timeout_async(self.run_async) | ||
sublime.set_timeout_async(lambda: self.run_async(file_path, branch), 0) | ||
|
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.
I have to disagree, the change does hurt, multiple commands get broken. Specifically, any command inheriting from LogMixin
that overrides run_async
and does not support the 2 new arguments.
I'm going to patch the occurrences I found so far, to support this cleaner call type: GsLogByAuthorCommand
, GsLogByBranchCommand
, GsResetCommand
and GsBranchesLogCommand
. See commit 0776af2
Unfortunately this patch did not fix the issue I was seeing in "reset to branch" command, and I have run out of time. Hope you guys can help me again 😅
core/commands/log.py
Outdated
self._file_path = file_path | ||
self._branch = branch | ||
sublime.set_timeout_async(self.run_async) | ||
sublime.set_timeout_async(lambda: self.run_async(file_path, branch), 0) | ||
|
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.
Just answering my own question, as in commit message: implicitly passing more arguments into kwargs raises an issue in python3, as seen here: http://www.asmeurer.com/python3-presentation/slides.html#15
@asfaltboy, I fixed the reset. Can you pull it and see if you can find any other bug? |
Reset to branch works now, I'll keep using the branch for a while to see if anything else creeped in |
I pulled this down and it looks great to me. How do you feel about merging into master and resolving any issues that pop up there? This is a big branch, and my preference is to merge early in order to avoid merge conflicts and subtle errors from master/branch divergence. @stoivo @asfaltboy? |
@divmain agreed, good point! |
I would like to merge |
Thanks a ton @stoivo! This is merged :) |
This also needs an update of the relevant docs. |
closed #102 #152
First off, sorry for the big PR. Bit it is a big feature.
I would like to have some review of the code of one other contributor.
Hello, @yyyc514, @benmosher, @stevage, @rchl, @reagle, @dlnsk, @jipumarino, @jipumarino, @jipumarino, @maxim, @zx8
Finally, I got around to implement this. If you are running GitSavvy from git pull down the branch a see if there is something we can improve further?