Show differences between files on two branches unrelated to present view - branch

I'm working on a (GNU/Linux) system with a ClearCase client installed. On this system, people don't always have views correspond to every branch; and have different "branch trees" for different files.
Now, given that I have no relevant view set as the present working view, or that the PWV is irrelevant to the branches I'm interested in - how do I generate a diff between the files existing on two specific branches?
In this question:
https://stackoverflow.com/a/2786120/1593077
there are assumptions about the PWV being relevant, I believe.

One simple way would be to create two snapshot views dedicated for that task:
one with a config spec selecting branch1
one with a config spec selecting branch2
Then a Linux tool like kdiff3 (or at least a simple diff -qr dir1 dir2) would display the difference between files list and file contents.

Related

Install two mutually-exclusive files with the same name to the same directory

My program deploys with a configuration option that I've chosen to expose as a feature. This option can be one of two values.
Each configuration changes a set of settings files. They have different input file names (for the sake of example, let's call it option1-config20-lv80.xml), but should be installed to the configuration directory as config20-lv80.xml. Each option has a prefix that should be stripped like that, which also means only one of these options can be selected for install at a time. However, even with conditions preventing the install of one feature when the other is selected, my output is littered with:
LGHT0204: ICE30: The target file 'config20-lv80.xml' is installed in 'path' by to different components... This breaks component reference counting.
How can I give my users the option to choose between these configuration options and get around my ICE30 issues without any negative side effects?
I saw an similar question answered, but I'm not 100% sure how to implement it in wix#, or if there are other ways open to me to achieve my goal without disabling ICE30 validation or creating 2 installers.
A bit rushed, have a look...
Milk & Honey Winnie: In cases like this I prefer to install both files with different names using two different components and then switch between them with an option shown in the application itself. On launch or in the preferences. Makes deployment simpler, it is already complex (section "The Complexity of Deployment"). The linked answer you refer to can work technically, as can more hacky approaches.
Alternatives: I have a long answer here on different ways to install settings files: Create folder and file on Current user profile, from Admin Profile ranging from eliminating the whole file and using internal defaults, to downloading settings files from the network or just relying on clouded web-service settings retrieval from a database. Not 100% match, but maybe give it a skim?
A related issue is when you have a settings file that regular users can't write to. This is a list of approaches for eliminating that condition: System.UnauthorizedAccessException while running .exe under program files.

Consolidate Perforce `add` and `edit` file operations

To automate Perforce staging, I face a dilemma that add and edit are two different ops and they work on files of different SCM status, i.e., "already under SCM or not".
This is different from git where staging is uniformly add.
I'd like to have something like pseudo-code:
filepath = '/path/to/myfile.ext'
if p4.is_under_scm(filepath):
p4.edit(filepath)
else:
p4.add(filepath)
or better yet, simply hide the detail with:
p4.staging(filepath)
How should I achieve this with calling p4 command-line program?. I'm not using any programming-language bindings right now.
You might want to use the p4 reconcile command, which automatically opens workspace files for an action that matches their current state relative to the depot.
Keep in mind if you go this route that reconcile operates only on unopened files that are different from the depot version, so it's meant to be used after making local modifications (this is different from the standard workflow where you open a file with p4 edit prior to editing it -- the idea is that you use reconcile to fix things after the fact if you've had to work disconnected or something like that). In addition, if you change your mind about what you're doing with the file (e.g. you delete the local copy after it's been opened for edit but before you submit), you may need to revert -k it and re-reconcile to ensure that it's open for the correct action.
For something that matches the pseudocode in your question, you probably want the p4 have command, which tells you if a local file corresponds to a depot revision (and if so which one). p4 edit only works on a file that you have, whereas p4 add would be for a file in your workspace that does not correspond to an existing depot file. (A very subtle point here -- it's possible for the file to map to a depot file despite not having been synced from the depot! If that's the case you'll hit a conflict when you go to submit your add.)

Managing checkouts of same binary file in different branches in Perforce

How to prevent checking out / changing one binary file in different branches of the same content. Situations like: designers have edited some game level (*.umap binary file) in their branch. Programmes changed same file in their branch (for example - added some blueprint on this game level). So now we have three different versions of this file, one in master branch before all changes, one in designers branch without programmes changes, one in programmes branch without designers changes. And now we must merge designers changes and programmes changes into master branch, but we cant.
So the question is - how to organise right this situations? Maybe we can setup perforce to checkout binary file in multiply branches at the same time, or something like this? Thanks...
There are a couple of different ways to think about this.
If you don't want work to continue/begin in one branch, until changes from another branch have been merged in to it, you can use Helix (Perforce) Protections, to give users read-only access to the branch.
This means they will be able to open files for edit, but won't be able to submit their changes.
More info about protections is here:
https://www.perforce.com/perforce/doc.current/manuals/p4sag/chapter.security.html
The protections would need to be changed, when you are ready for work on the other branches to start.
If you want a file to be automatically checked out on all branches, each time someone checks it out on any branch where it exists, you would currently have to script this.
You could do it using the broker and a workspace for every branch, that has a view that just includes the files you want to be checked out everywhere.
The files would then need to be checked out in these workspaces and locked, so that other users can't submit to these branches until the locks are removed.
This is not trivial and may have a performance impact.
You might also be able to do it using pre-command triggers, if your server version is new enough.
If you want to go in to more detail about any of the above, I recommend you contact Perforce Technical Support.
Hope this helps,
Jen.

What is the correct way to create branch in RCS, and do you need to set a lock first?

I am looking for best practices using branches in RCS.
I had read the man page for rcs and ci and also browsed at the following links:
http://www.gnu.org/software/rcs/manual/html_node/Concepts.html
http://www.gnu.org/software/rcs/manual/html_node/Quick-tour.html
Suppose i have revision 1.3 on tip of the trunk.
I now want to change file 1.2 (as 1.3 have several other changes I cannot yet use).
I understand I can create branch on revision 1.2 using ci -r1.2.1
My question are the follows:
1. Do I need to set a lock on the file? If so, on which revision?
2. If no lock set, I cannot use -u flag in order to keep the file in my local dir. In case I wish to do so, is it still possible without co the file again?
Side note: I feel RCS does not suit my company needs however migrating to another system is not my decision to make, so currently I need to keep working with it.
I'm looking for much the same thing, but seeing you've had no answers, I'll offer my current practice:
I use branches for development, not for keeping different variants going in parallel. The trunk is reserved for my best, presumably working, code on the and I try not to check in anything there that might break it. I branch the code when I want to start a line of development that will take some time, break it for a while, is an experiment I might have to be abandon, etc.
To start a new line of development I change the default branch to a new branch off the trunk rev that's to be the base of my code, and force a checkin onto that branch, with:
rcs -b1.2.1 foo.cpp
ci -f1.2.1 -l foo.cpp
Now I can dive in to developing the branch, and my next check-ins will go onto the new branch instead of onto the trunk. Whether you lock a revision or not is only relevant to whether you intend to modify the working file.
You're correct that you can't keep both revisions, trunk-tip and branch-tip in the same folder; they have the same file name. But you can check out one of them with a -p switch which forces the output to stdout (instead of to a local file) which you can then redirect into a sub-folder, or to a local file with a unique name.

API - How to programmatically merge a list of merge candidates returned by .VersionControlServer.GetMergeCandidates?

I am creating a clone of Default Merge Window, to add a feature.
I already have a Merge candidates in a grid from command below:
MergeCandidate[] candidates = tfs.GetMergeCandidates(edtSelectedSource.Text, cbxTargetBranchs.Text);
Now, the user selected 1 or more candidates and I need to merge them.
But the TFS API VersionControl.Merge requires source path and target path.
At first, my question, I need to iterate each candidate and merge each file of its changesets, one by one ?
Second, how could I obtains the target path from a changeset ?
First off, I've done a fair amount of programming with the TFS API, but merging is something that I would never blindly trust to automation. Merge conflicts are best dealt with by human beings. Yes, it's painful and can be automated in many cases, but in many others - things can go terribly wrong. I would think twice and then twice again before doing this on Production branches.
Here's some tips that should help:
You need to create a temp Workspace. The Workspace is the sandbox where everything happens. The Workspace can have files and thus, file locations associated with it. Workspace items have rich metadata.
Have a look at the Workspace and WorkspaceInfo classes.
Then have a look at the workspace client:
http://msdn.microsoft.com/en-us/library/microsoft.teamfoundation.versioncontrol.client.item.aspx
As long as the changesets are continuous, you can do it in a single merge call. If they are not continuous, you need to submit n merges for each continuous block. Let's say they select changesets 10, 15 and 20 and these are continuous (i.e. there are no additional candidates between that range) then you would submit a merge with a versionFrom of 10 and versionTo of 20.
As far as paths go, you want to use the ones that you passed into QueryMergeCandidates and you'll want to specify the full recursion type as well.