perforce merging file branched into overlay workspace - merge

Assume I have these two directories
/root/subdir1
/root/subdir2
and a perforce workspace with an overlay, like
Root:
/root
View:
//depot/project/... //workspace/...
+//depot/project/subdir2/... //workspace/subdir1
where subdir2 is overlaid on top of subdir1.
At some point I branch (integrate) a file from subdir1 to subdir2, and both files keep being changed and submitted to perforce, either on the overlaid workspace, thus under subdir2 or on another non-overlaid workspace, thus changing the file in subdir1.
How do I now merge (integrate) the files such that only the file on the non-overlaid workspace exists?
If I merge into the non-overlaid workspace and delete from the overlaid workspace, the file no longer shows in the overlaid workspace. If I don't delete it, the version before the merge stays there in the overlaid workspace.

For tasks like this, it can be much easier to use a workspace which has no overlay lines in its view mapping. Then it's not so confusing about which repository file corresponds to which local file, and you can refer to all the different repository files without dealing with the filename ambiguities introduced by overlay mappings.
Also, have a look at 'p4 where'; it gives you a lot of information about how a particular file in your workspace is mapped into its corresponding repository location.

This is one of the drawback of using overlays in workspace view specification: Order matters.
If when you apply an overlay, a file has been deleted in this overlay, on top of a folder where this file exist, then the existing file will never show up.
There is nothing you can do about it, as this is the perforce logic of how folders are populated.
You can try to fiddle with you view paths:
//depot/project/... //workspace/...
+//depot/project/subdir2/... //workspace/subdir1
+//depot/project/subdir1/... //workspace/subdir1
And you will see your integrated file back.
Overlays are great, but then moving/deleting files can mess up with them.
Note that if you rename the file as you move it from directory, then you won't have the problem. I.e. if you move/rename a file from:
//depot/project/subdir2/my_file_in_dir2
to
//depot/project/subdir1/my_file_in_dir1
And then apply your overlay:
//depot/project/... //workspace/...
+//depot/project/subdir2/... //workspace/subdir1
It's OK, as they don't share the same name anymore.

Related

Any way to have workspace/folder settings ONLY apply to files in that workspace/folder and not random files outside the workspace?

I know about workspace settings. My issue is that workspace settings also apply to any files that are opened not in that workspace. Example:
"editor.formatOnSave": true // put this in some workspace settings.
open a file not in that workspace (maybe in a different project) in the same window. This happens when I type $ code ~/someFile.txt
When I save that file, it gets formatted when it shouldn't.
Any workarounds?
Specifically for saving a file without formatting, try new command for saving without formatting. Just added in v1.28.0:
The new command Save without Formatting
(workbench.action.files.saveWithoutFormatting) can be used to save a
file without triggering any of the save participants (for example,
formatters, remove trailing whitespace, final newline). The default
keybinding is Ctrl+K S. This is useful when editing files outside your
normal projects, which may have different formatting conventions.

How to exclude .class files from file search in Eclipse?

I want eclipse to ignore all .class files when I search for a keyword in files. I don't want a particular directory to be excluded, instead I want to exclude all files of type .class
when you open the File Search in Eclipse, there is a text box for filename patterns. You can enter the patterns you DO want to include, like *.java, *.xml, etc. (each pattern separated by a comma) , and it will only search in files of that type.
EDIT:
To exclude a file type, place an exclamation mark in front of the pattern, like
!*.class, !*.svn
I managed to exclude files of a specific extension in eclipse using resource filters:
Right-click on the project in project explorer -> select properties
Expand the Resource heading on the left of the properties window and select Resource filters
Select the Add Filter button
In my scenario, I was ignoring tar.gz archives:
So in this example *.class could have been inputted rather than *.tar.gz to ignore all files with the class extension.
You can create a Working Set pointing it to your java source dir,
and select it on Open Resource (Ctrl+Shift R normally)
Open Resource window Image
menu Image
The working set will be remembered when you open it again.

In Mercurial, how to "merge" with the commit's (single) parent?

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.

How to avoid repeated matching items in Eclipse 'Open Resource'?

The project I'm working in uses Maven and its typical standar directory layout.
When I look for a resource with Eclipse 'Open Resource' I get these matches:
Where I get repeated matches.
There are only 2 XML files in filesystem.
The one under src/ and the one under target/.
For example, the path to the src/ file is:
maindev/common/utils/persistence/src/main/resources/com/ericsson/m2m/common/utils/persistence/impl/mybatis/custom/xml/
But 'Open Resource' indicates 3 matches for the same file with relative paths:
maindev/common/utils/persistence/src/...
common/utils/persistence/src/...
persistence/src/...
Is there a way in Eclipse to avoid those repeated matches?
Moreover, is there a way in Eclipse to indicate not to return resources for target/ directories?
NOTE: I tried Wojtek O. suggestion, but still getting matches:
You see multiple files because they logically are contained withing difference Eclipse projects. You could try to close some of those projects but that may as well result in compilation errors. If you wish to hide some files from the Open Resource... dialog you need to mark the folder containg those files as derived by right clicking on it in the Project Explorer and selecting Derived checkbox under Attributes section.
This is a really old thread, but in the newer Eclipse versions (Photon+) there's a filter option for resource search.
On the Open Resource dialog (Ctrl+Shift+R), click the drop-down on top "Enter resource name prefix..." and select "Filter Duplicated Resources".
If you're just looking for Java classes you can also use Open Type dialog (CTRL-Shift-T).

Undo clear selected from workspace mapping p4v

I was trying to move my workspace root around and did clear workspace mappings in p4v. What this did was clear every subfolder from the mappings. Then when I try to include the whole tree, it only includes the selected folder, since all the subfolders were cleared. Is there a way around this?
It may not list them, but if you are including the top folder "recursively" (i.e. follow the directory name with a slash and "..."), it includes all subdirectories without listing them explicitly.
To add the top directory in the "View Workspace Mappings as Tree" view, navigate to your depot or the highest-level directory you want to add. Right-click the directory and choose "Include Tree". Expand the tree views to verify that they are included.
If you're used to the "Workspace mapping as text", add the depot and client paths of the top-level directory that contains the subdirectories you want. Make sure the mappings are "recursive" and include all files and directories below by appending "..." after each side.
Ex:
Suppose you want to include dir1 and dir2, both of which reside under top_dir. Add this line to your workspace mapping:
//depot1/top_dir/... //myclient/top_dir/...
This will include //depot1/top_dir/dir1 and //depot1/top_dir/dir2, and all other files and directories under "top_dir".