TFS - Cannot see Target branch when doing file Merge - version-control

We faced an issue with file Merge at TFS2010. Until now, we merged files from one branch to another without problems (right click at file -> Merge -> Choose Target branch and Merge files). Initially, we added new file at Develop branch, after that added same file at Main branch. After some period we had changes in code at Develop branch and when tried to do Merge with Main branch, cannot see Target (Main) branch. I have two questions regarding to this situation:
Is this good way for 'uploading' new files at TFS. Separately add files at both branches or there is some better practice where we could add new file to Develop branch and after that make copy of that file at Main?
What can be reason for 'hiding' Target branch during the Merge operation?
When tried to solve this problem, I found some articles that can be useful to someone else, but didn't solve problem in my case:
TFS not showing Dev branch in target locations for merging
How to merge new files into another branch in TFS?
http://revweblog.wordpress.com/2010/03/31/missing-target-branch-while-trying-to-merge-in-tfs-baseless-merge/
TnX in advance!
Nemanja

I think the case you should look closer is this, it's a case you have already mentioned.
To your first question:
No, your method of committing new files multiple times is not optimum. Adding a new file into source control (any source control) more than once, doesn't make sense.
To your second question:
The reason behind this behavior was best explained by AakashM in the post above: "In TFS the unit of change is the changeset, and it is changesets (not files) that are checked-in and merged. In the version (changeset number) that the target branch is at, this file simply does not exist, so there is nothing to merge to."
The proper way to operate is to add new files in your 'Development' branch and then merge into your 'Main' branch.
This will not be possible if you right-click on the newly added file & choose "Merge.." (no target-branch will be presented). This will be presented if you do this in the folder containing you new file(s).

I had this issue, when for the Main Branch i did not had the latest code. I Took latest code in Main Branch and then tried Merge to development branch and it worked.

Related

In GitLab, do I need to re-merge a branch because I added a new file to my branch?

I'm trying to make sure all of my code is in the right place and it should all be "merged" with an existing project.
I forked their project and merged when I had two source files, and now I've uploaded a third file to mine.
Do I need to remerge my branch with their project for them to see the new file? If so, how would I do that? (I get an error about there already being a merge request)
Thank you.

Hg Mercurial - Upgrading code not in repository

I have a customized local repository of NopCommerce 3.5. The new version of NopCommerce (3.6) is out and I would like to try to update to it. I downloaded their source code and I would like to somehow replace all the files in my local repository with the new files (outside the repository) and then have mercurial detect the changes and merge them with my changes. Obviously the merge would be manual but I have no problem with that.
In case I am not explaining this properly, let me give you and example:
I have file foo.cs (v3.5) which has custom code in my local repository. I downloaded the new foo.cs (v3.6) which is not in any repository. How can I merge them so that I can keep my changes and the the new changes added by the NopCommerce team?
This is what I have tried so far:
I created a new branch called "Nop3.6" and replaced foo.cs. Then I tried to merge the "Nop3.6" branch with my "default" branch hoping to be able to merge manually and keep both, my custom code and the new changes added in foo.cs (v3.6).
As you might expect this didn't work. my foo.cs file (v3.5) was completely replaced with the new foo.cs and all my changes were lost.
Any help in the right direction would be much appreciated.
Doing the merge vice versa (your changes into v3.6 might work better. Also make sure that you have selected a reasonable merge tool (internal works, but there are possibly more convenient ones out there, I use kdiff3 myself):
I assume you have a repository with v3.5 and on top of that you have one or several changesets which are your own modifications of that source. If you haven't committed your changes as changesets on top of v3.5, then do that now.
Then, in order to get a decent merge with v3.6 do the following:
update to the unmodified v3.5 again. Copy v3.6 over this and commit the complete change as v3.6. You end up with a repository which has two anonymous branches with v3.5 being their common ancestor.
Now you can merge those two branches. As you possibly want to keep your changes on top of v3.6, update to v3.6 and merge your local changes into that branch.

Exclude a config file from the merge process

Is there a way to exclude a specified file from the merge process? when merging from our production branch to the test branch for the testers to use, we want to exclude a config file which contains the SQL connection string. Preventing the need to edit it post merge. I did see a comment about using the cloak option but i can only see this available for folders not files.
Tim
There are a few different ways you can do this. If you don't plan on changing your config file in the future and you just don't want its current contents to make it to the parent branch, you could simply do a "tf merge /discard" on the file and check that in. That basically says, never merge the changes that have happened to this file to the target branch. However, if the file changes again, it will be a candidate for a merge.
So, if you plan on continuing to change the config file in question, then you have two options. The first is to always cloak this file in the target branch workspace that you are performing the merge in. Yes, it is possible to cloak files, it is just the picker in the dialog doesn't make this easy. If you navigate all of the way down to the containing folder, select that and then manually enter the file name at the end of the folder string, the cloak will work on the file. This approach has the downside that you have to remember to always cloak this file in the workspace that you are performing the merge in and if someone forgets to do that, the file will be merged up.
The third, and likely best, solution to this problem is to use the tfpt.exe power tool with the branches command to cloak the config file from the parent's branch mappings. You can download the latest 2010 power tools here. You will want to run "tfpt branches /properties /collection:" and then select the "mappings" channel. In there you will probably just see a single mapping for the root of the branch. You will want to create a cloak mapping for the file you do not want to be merged and then click OK. On all subsequent merges to that branch (note, from any other branch) the file in question will not be merged.
Not a very nice solution, but you could remove the checkin security on that file so you are unable to checkin the file after a merge.

Eclipse Merge Branch into Trunk

I am trying to merge my development branch back into the trunk of my repo. Steps I took:
Switch to trunk
check that it is up to date, resolve any conflicts
Go to Team->Merge
Select URL : development branch
Start Revision: Revision when branch was created
End Revision: HEAD
OK
This should do the magic - it opens up the syncronize view which is fine, shows me all the conflicts, but there the problem happens:
In the compare editor I see two files:
Local File | Remote File (306)
This is really strange, the revision number of the remote file is actually the one of the file in the working copy (trunk) and so is the content. The local file has the content of the file in the branch.
Now the arrow shows correctly that I am merging from left to right (branch to trunk). This also happens when I click ok.
BUT I can only move changes from right to left!!! That's not what I want - I do not want to overwrite the changes in the branches with the old content of the trunk. I want to move the content from left (branch) to right (trunk). But I can't even write in the right file.
I do not know why it writes remote file there?? It's clearly showing the working copy file in the remote file window, and the file from the branch (for merging) is shown in local file.
Some bug in Subversive?
Thx,
Martin
Merges are never been easy with subversive (as mentioned in this old SO question), so may be doing the merge externally (or with subclipse) would be easier here.
If your client and repository are both at least in SVN1.5, Subversive new merge capabilities are better, but still dangerous as illustrated by this thread.
Since Subversive has been modified for SVN 1.5 the whole merge behavior has changed. One thing I really liked is the ability to choose what changes I wanted, apply that to my working copy and then commit to trunk.
Subversive now no longer does that but forces all changes onto your working copy and then you choose what to put in the trunk.
This is not only undesirable behavior but it's also dangerous (if you ignore the possibility of a revert anyway). I prefer to commit things I know work. We have a release branch which gets changes which may or may not need to be migrated to the trunk.
Well this seemed mysterious at first, now I shall provide a decent stab at updating this answer for everyone. This regards merging using the SVN Subversive client for Eclipse:
You are doing your merge correctly, starting in Trunk and then pointing to your file under your local Branch. Your files open up in the "Text Compare" window under the Team Synchronizing tab. If you do not see conflicts over in the left hand navigation column, then your merge has just happened. Yes, this is confusing and non-intuitive.
What the Text Compare window offers you is the ability to undo your change (or any others that may have gotten into your merged file unawares) before you commit it. Remember that you are pulling in the file from Branch, so the idea is that the Branch file is in Trunk but in a kind of virtual limbo until finally committed, and changing or undoing unwanted changes here references the file in Branch (obviously). That is why you only have a one-way pipe (Trunk to Branch) to overwrite those changed merged into Trunk via your working copy. Your merge has taken place, but it's not quite official yet.
If all looks as it should, right click the file in the navigator window (left pane in my Eclipse Helios install) and choose Accept from the drop-down. Then click back over to your main code-viewing tab (in my installation it's PHP but it could be whatever you are using) and then commit the file to Trunk.
If you want to test this, do a view of the file "as is" in Trunk before committing and you should see your changes reflected there if you have done your merge correctly. This appears to be the way it is working for me on an OSX Snow Leopard Macbook Pro. Not sure if it's the same for Windows or Linux folks. I assume it's essentially the same/similar process.
it's easy
check out trunk with check out as... give a different project name.
Now you have both locally as working copy, trunk you wanna commit to and the branch you are working on and whose changes you have comitted to the repository.
Now rightclick the trunk project (and I mean the project, not single files) - merge - select the branch project (again, PROJECT)
accept all changes to local copy
commit what you need to trunk as used to
all fine, delete trunk again and keep working on the branch
especially with branches this seems super easy and worked like a charm for me

Can someone explain the perforce integration options?

Specifically:
Why do I need to explicitly enable "Enable baseless merges" all the time? I am integrating from my branch to the trunk.
What does "Enable integrate over
deleted targets" mean? Shouldn't it
do this by default? If the file
doesn't exist, and you integrate to
that branch with the file, it should
create the file, right??
What does "Do not get latest revision
of selected files" have to do with
integrating? I should be choosing a
source revision, and a target (to
create a new target revision).
What does "Disregard indirect
integration history" mean? I've never used it, since it sounds scary.
I would be grateful to know, as I am a little unsure of what options to enable when I am trying to do various integration tasks from our trunk to various branches or vice versa. (I am not the buildmaster, but hey, I want to know what he knows).
Why do I need to explicitly enable
"Enable baseless merges" all the time?
I am integrating from my branch to the
trunk.
Can't help you here. Something is not right.
What does "Enable integrate over
deleted targets" mean?
If the target file has been deleted and the source file has changed, will re-branch the source file on top of the target file. Without this option, a file on the branch, that has been changed on the branch and deleted on the trunk, would not be allowed to be integrated back into the trunk.
Shouldn't it do this by default?
Not if you are integrating a file back into the trunk, which you branched from the trunk, then deleted on the trunk. Normally 'p4 integrate' avoids mixing outstanding edits with a deleted file. You have to use the advanced options to tell it how to deal with a deleted file.
If the file doesn't exist, and you
integrate to that branch with the
file, it should create the file,
right?
When integrating a file, that previously never existed (i.e., it was added to the branch), from one location to another, yes, Perforce will simply create it in the location into which you are integrating. However, if the file originally came from the trunk, was deleted on the trunk, and now you're trying to integrate it back into the trunk from the branch, you have to tell it what to do via these integration options. Here's the command line switches to which these options correspond:
Enable integrations around deleted revisions = -d
Integrate over deleted targets = -Dt
Delete target file when source is deleted = -Ds
Try to integrate changes when source is deleted and re-added = -Di
You can learn more about them in the integrate command help (type "p4 help integrate" at the command line).
What does "Do not get latest revision
of selected files" have to do with
integrating?
This tells Perforce to use the workspace revision of the target file. By default, the head revision of the target file is automatically retrieved into the workspace before integrating. Say you have made one revision to a branch file and integrated it back into the trunk. The trunk and branch now have two revisions of this file. You submit a change to the branch file so it now has 3 revisions. You sync the branch file back to revision 2. If you were to do a normal integration right now, Perforce would assume you want to integrate everything up to the head revision and would integrate revision 3 of the branch file into the trunk. If you were to select this option, it would say, "all revision(s) already integrated" because you have revision 2 in your workspace. It would be the same as attempting to integrate with the "Limit the range of the integration:" option set to "Integrate all revisions up to:" Revision 2.
What does "Disregard indirect
integration history" mean? I've never
used it, since it sounds scary.
I can't figure out, nor find any info about, what this does.
In general, to merge two files, perforce looks for a "base", the closest revision to the two files, and uses that to provide a much better diff than just directly running a diffing the two files. See Knowledge Base Article. Without knowing your perforce setup, I couldn't say what was going wrong, however, p4win has some nice graphical tools to visualize branches, you might be able to determine why perforce can't find a base for you. This is also what "Disregard indirect integration history" does: stops it from looking for the base.
For the "don't sync to head": when integrating, your "target" is the files in your local client, which you aren't specifying a revision for; instead, perforce will either sync your revision head (if you don't use "-h"), or will use the one you currently have. You can't specify an arbitrary revision because your local client only has a particular one.
"Enable integrate over deleted targets" can lead to problems if done blindly. Here's an example: Imagine you refactor your code in your next release branch, and eliminate a source file as a result - the functionality was merged into some other source files. You then fix a bug in that original source file in a maintenance branch for the previous release. If you integrate over delete by default, the dead source file comes back, but it won't be built and the bug wouldn't have been fixed. It'd better to be warned that this occurred so you could manually merge the fix into the other source files.