I have a question about the Meld visual diff and merge tool, which is probably a simple misunderstanding.
But how do I adopt lines that were removed in the $REMOTE?
Please see the screenshot below for an example. I have changed the order of the imports and created a merge conflict, so now I want to pull the first change from the right, but then also the second change that would remove those lines that now already exist at top of the imports. I could remove them manually of course, but surely there is an easier way?
Or am I wrong with my assumption, that the middle pane is the result that gets written to $MERGED?
Edit: In this contrived example, I actually have a Delete action that I can use to remove those lines. But in a real-world merge I'm trying to do with meld the Delete action is greyed out, as is the Pull from Right action.
Any idea why Meld wouldn't allow me to Delete those lines that will be made obsolete by a Pull from Right above them?
I found out that holding the Shift key allows me to remove individual changes.
Related
I've been transitioning to using VS Code for my python projects after previously working with the full Visual Studio, and some of the key bindings/features I'm used to in Visual Studio I can't find the equivalent for in VS Code. I'm not sure if the bindings are different or if the feature doesn't exist.
One feature in particular that I can't figure out is if it is possible to do multi-line select past line endings. In Visual Studio, using Alt + Click + Drag, lets you create a multi-line cursor or box selection, that can extend past line ends, implicitly adding spaces as needed so that the right-most side of the box stays uniform. In VS Code, if you drag the selection past the end of a line, the selection box won't go past the end of the line, even if other lines in the selection extend past it. In Visual Studio, this feature even goes further, as you could Alt + Click + Drag even in areas with no characters as all, creating a multiline cursor or box selection to the right of all existing line ends.
This isn't an essential feature, but it's very handy in making code easy to read. For example, when assigning several dictionary entries all at once, with varying key lengths. Is it possible to do something like this in VS Code?
Edit: The feature I'm looking for is virtual spaces (thank you Mark for providing the feature name), which seems to be an outstanding feature request in VS Code.
The short answer is no, vscode does not have a box select, past line ends, built-in. VS Code does not have the concept of virtual spaces which would be necessary to make this work yet.
Below is the issue, lots of comments, not that many upvotes. Upvote it.
https://github.com/microsoft/vscode/issues/5402
Consider the following split view code diff from a browser on GitHub.com:
While looking at this diff, I want to clipboard copy the code from the right-hand side (e.g. in order to paste that snippet into a different project in another window).
However, if I try to use the mouse to select the code on the right-hand side in the usual fashion, the code from both sides ends up selected:
And if I hit Ctrl+C / Cmd+C, I end up with kind of a mess on my clipboard which includes copies of the code from both sides, and all of the + and - indicators, which leaves me with a lot of error-prone manual cleanup to do after I paste. (Particularly when copying from a diff that's more long and complex then the simple one I picked out for illustration purposes in this question!)
My question: How can I cleanly and easily copy code from one side of a split view diff in a web browser on GitHub.com to my clipboard?
Update March 2021: this should be, this time, supported:
Copy one side of split diff
When comparing changes to a file using the split view, you can now select and copy just one side of the diff.
Previously both sides were copied. Selecting over a comment will still copy the comment's contents.
May 2018:
As mentioned by Hugo Giraudel in his tweet in late April 2018, a bit too quickly:
GitHub finally moved the + and - symbols from diffs to CSS pseudo-elements, making it possible to copy code directly from a diff without having to clean it up.
That is long overdue and fantastic. ✨
Actually... this is only true with the help of third-party extension!
Like sindresorhus/refined-github.
Without, you would still copy the '+' and '-'.
GitLab has that feature though.
This is still pending for BitBucket (issue 16204)
timotheecour reports in the comments that it does not help with side-by-side diffs:
the code from both sides ends up selected
This is in the context of using refined-github, a Browser extension that simplifies the GitHub interface: issue 2765.
Update Nov. 2020: that issue just got resolved with PR 3698
I've worked on some project. I'm able to see the difference between my project and its (sole) parent with:
hg kdiff3
(After I've configured "kdiff3" as shown here). However, I want to be able to edit my files, perhaps remove some of my changes, edit some of them or make new changes. But that command only shows me the differences, rather than let me edit them. If I try:
hg merge 5861231e8335
(When "5861231e8335" is the (sole) parent of the working directory) I get:
abort: merging with a working directory ancestor has no effect
So how can I "merge" with the parent? (preferably using "kdiff3")
First, you have misunderstood what hg merge does. It merges changesets from 2 parents. It doesn't merge uncommitted changes.
To merge uncommitted changes into the current tip changeset, you want:
hg commit --amend
which replaces the current tip with a new one.
To answer your question about editing in a differencer. I'm not aware of any method of editing a bunch of files in a file differencer; that's because the set of files get copied into the temp directory where it's obviously pointless to edit them. You can however, diff and edit one file at a time because one file is diffed in place without copying to the temp directory.
But surely, isn't it better to edit files in your normal editor rather than in a file differencer? Surely, one can edit, but only as a last resort. OTOH, if you use the trick of viewing diffs one file at a time, it is possible to edit in your real editor, then watch the diffs change in the differencer.
hg shelve lets you temporarily put aside (on a shelf) parts of the diff between the working directory and its parent, so it will give you the "remove some changes" part of what you want. It does not let you edit, but you could put what you have changed on one shelf, then reimplement the change. If you want to revert to the original change, you just put the new change on a new shelf, and pull the original change off its shelf.
Alternatively, create a copy of the parent changeset using hg export (or hg clone and update to the parent changeset, but you don't need the history for this), Once you've got your copy, you can merge the copy of parent with your working directory using kdiff3 directly, outside of Mercurial.
I know I can have anchors to a certain line, but if the source changes that line might become irrelevant. Example:
...source.php#L33 < line 33 may become line 40 later :(
Is there some way to tell GitHub to link to a certain function or property from the source, without specifying the line?
(The source is written in PHP code.)
AFAIK, no, but you can link to a certain revision of the file, and thus, you can know for sure that line will always point at the start of the function.
The URL looks like /{user}/{repo}/blob/{hash}/{file}#L{line}
To get it, click "Commits", select the last commit, click "Browse code", and find your file and line as usual.
documentation
Yes you can. Newer browsers support highlighting a portion of text and scrolling to it.
Example: common.c#:~:text=static%20ssize_t%20led_current_store
All you have to do is to add this to the end of your URL:
#:~:text=function_name
Some browsers do not support this, though: https://caniuse.com/url-scroll-to-text-fragment
Enjoy!
When comparing two files, for example during a commit, Eclipse shows the original version on the right and modified on the left:
However, I would prefer to see the original version on the left and modified on the right. Is it possible?
Eclipse Neon.2 (4.6.2) has a button to swap the views:
You can either swap the views for every compare, as one answer suggests:
Or you can make the swapped order be the default for all compares:
Windows --> Preferences --> General --> Compare/Patch
Select the Text Compare tab, and mark the check-box of Swap left and right
I think it's just depending of which file you're selecting first. I mean, choose a file, and select compare to .. and choose another one. Next choose the second one and compare to the first one, they'll swap in your window :)
This behaviour is influenced by what exactly is compared. When comparing two local files the view is influenced by the first & second selection. If using e.g. GIT the left hand side will always be what is present locally, the currently checked-out branch or local changes - so changing the branch will influence the view. When using SVN it is mostly the same, so left hand locally, right hand remotly.