Intellij show possible merge conflicts before actual merge - intellij-idea

I have a file that was changed in one branch and renamed in another (but from comparison perspective it was deleted). I use IntelliJ for merging. When I merge the branch where the file was changed into the one where it was deleted, in the merge window the IntelliJ shows two panels one for the deleted file which is obviously empty and the other one for modified file with changes highlighted in darker pink.
I need to add these changes to my renamed file. And I can do it manually, np, however I cannot keep the merge/comparison window open. It must be closed before I can do any code modifications.
My question is: is there a way to get the same kind of comparison with possible merge conflicts highlighted before the actual merge.

IntelliJ relies on the command-line git and needs git to attempt the merge before it can show you the merge dialog. So, unfortunately, it is not possible to get the merge dialog without starting the merge.
However, it seems that to solve the task you only need the merge dialog to be non-modal - here is the request for it in JetBrains tracker https://youtrack.jetbrains.com/issue/IDEA-66552

Using version IDEA 2021.3.3 (Ultimate Edition), I am able to open a merge non-modally by:
When the merge dialog appears, click Cancel
Open the Git view
Click on a changed file in the Local Changes tab.
This initially shows the merge diff in the side pane of the Git view.
To open the merge diff in the main editor area, right-click on the file (in the Local Changes tab) and select "Show Diff".
This will open the merge diff in the main editor area.

Related

How to copy search results in IntelliJ to paste them elsewhere?

I would like to remember my team the ports used for debugging, for several projects.
A Ctrl-F in a directory, and I have my results under IntelliJ_2021.1.3 Ultimate I'm using,
but I have no way to paste them, like they are on this window, either with Ctrl-C or Ctrl-Ins , on another location in order to send a mail to my teammates.
Does a workaround exist, or has this feature been implemented in a later version I should try to upgrade to?
I don't think there is a simple and direct way to do what you want. However, there is a workaround:
Run your search, and then from the Find in Files window click the Open in Find Window button:
Right-click anywhere within that Find window listing the occurrences, then select Export to Text File from the context menu:
An Export Preview window will open, showing the search results in expanded hierarchical form, reflecting the structure under the directory you searched. Within that window you can select any contiguous portion of text, then right click and select Copy from the context menu:
You can then paste the selected text into any other window, and massage the results as necessary:
Notes:
This is only a workaround because unfortunately I don't see a way to directly copy the results in your screen shot, in which each line shows a both a search occurrence and its file location. That information is still in the copied text, but it may take a bit of effort to get it in the form you want.
The Copy button in the Export Preview window ignores any text selection and blindly copies everything, so use Copy from the context menu instead if selecting a subset of the text.
I used IntelliJ IDEA 2023.1 EAP (Ultimate Edition). I don't know whether this functionality exists in your version.

how to make the editor gutter show lines changes against another branch, such as origin/main?

As shown in the screen cap below, the gutter to the left of the editor shows line numbers and color indicators for which lines have changed (and what kind of change):
It shows the changes against the current HEAD.
How could I make it show changes against another branch, such as main or even a remote branch such as origin/main?
For example, if the same change was already made on origin/mainline, I want no color indicator to show at all.
Thank you!!!!!
You can do this with the Git Scope plugin
It adds a Git Scope tool window that looks much like the built-in Git tool window (or the Commit tool window if you have the Git non-modal interface enabled). In the Git Scope window you can select a different branch to be the basis of file change indictors:
Not only that:
If you click on the color indicators, you can see the actual diff against the chosen branch.
The Git Scope window shows all changed files against the chosen branch (much like the built-in git window shows all changed files against HEAD).
As with the built-in window, you can right click on any file to or press ⌘D to see a full diff, or the Show Diff button to iterate over all file changes.
In fact, as far as I can tell, Git-Scope changes the diff context for even the built-in commands for showing the diff of the currently open file.
The Git Scope window has a toggle button to conveniently switch back and forth between normal mode (diffs against HEAD) and the Git Scope mode.

Possible to manually trigger automatic source code formatting in STM32CubeIDE?

I use STM32CubeIDE version 1.6.1, and have noticed that CubeMX outputs formatted code (e.g. indented with 2 spaces). I would like to reapply this source code formatting manually (that is, manually trigger the source code formatting on selected files).
I have found this post: https://www.openstm32.org/forumthread6435 , which mentions:
go the preferences dialog and select C/C++ > Code Style > Formatter
click on “Edit...” change the tab size field. close the preferences
Then, select all the project you want to apply it, click right and select “Source > Format”
So, I'm not 100% sure the above quote refers to STM32CubeIDE, however, the first part is still there, in Window/Preferences I can get to this:
However, I cannot see how to trigger this source code formatting manually, on selected files. For instance, https://dvteclipse.com/documentation/e/Format_Multiple_Files.html for Eclipse (that STM32CubeIDE is built upon), mentions that by right-clicking source files, one can call the command "Format Source Files"; however, when I click my main.c in the STM32CubeIDE Project Explorer, I cannot see anything like that:
So, is there a way to manually trigger automatic source code formatting on selected (single or multiple) source code files in STM32CubeIDE?
Got it, finally - when you right-click the Core node, or any of its children, in Project Explorer in STM32CubeIDE, you get a "Source >" entry in the right-click context menu, which has only one child, "Format":

Intellij vcs plugin, view changed files AND file changes in the same window

I normally do git diff for this but want to leverage the intellij gui.
The Version Control tab just shows me all the files that changed:
To view the actual changes I have to select a file and choose "Show Diff".
This opens another window. Now from this other window if I want to see changes for another file I have to click this button then open the other file:
I don't like that. Is there a way to have this in the same pane? Where on the left I see a list of the changed files and I just have to select the file to see its changes? Otherwise its very clunky and unusable for being able to see a tree of changed files and selecting the one's changes I want to see
Just found it, I wanted "preview diff"

Accurev: change package merge required

I've got a workspace backed to my collaboration stream (CS), the CS has a parent stream (Parent).
In my workspace I changed a file with version Parent/1 and then promoted it to the collaboration stream some times. Its version became CS/2.
Then I got an update from the Parent and found that I don't need to keep my changes in that file and purged it on the CS. Its version became "CS/2*" on the CS and "Parent/2" in my workspace.
Now I'm trying to make some changes in the file in my workspace and promote it to the CS again, but I've got the message "change package merge required" for the file.
If I understand correctly, it can't be promoted due to the file version in my workspace is not derived from CS/2. How can I resolve the issue and promote new changes to the CS?
P.S. Moreover I have a pack of such files - about 70 files. How can I resolve the problem for the whole pack of files?
Open the issue you are associating your promotion with.
Click on Changes tab.
Select the file from the list in changes tab.
Right click -> Remove.
Now promote using this issue.
the only way that i have found to fix this is to use the "send to>issue (specifying ancestor)" command from the version browser tree.
open accurev
view>view streams (pick your depot)
click the "active issues" icon in the upper-right corner
click the "show active issues" icon under the problem stream
right-click>"send to change palatte" on the source issue
right-click>"browse versions" on the problem file
select "everything" in the "show" dropdown
right-click>"send to">"issue (specifying basis)" on the latest version in the current stream
click on the earliest ancestor (this should be a common ancestor of all versions)
enter the target ticket number and click "ok"
these steps should work for any source/target issue, even "unaffiliated" changes. technically, you shouldn't have to "show everything" and choose the oldest version. you really just need to get back to a common ancestor.