I have checked in the same file (filename) twice in 2 different branches (say, development and release).
This breaks just about anything, so I want to take 1 version and "properly" copy/merge it to the other branch, later merging in the lost changes manually (from a backup). Then I would lose history for 1 file but at least the 2 files would be connected again.
How to do it?
Also note, since the connection is broken, I cannot mere, also, when doing a Version Tree, both files have different version trees. (It is not 2 views at different files in 1 Version Tree, like is the normal/correct case.)
Also, I assume the problem is with the folder having some kind of a reference to 2 different files, but somehow, I cannot edit the folder?!
Those are call "evil twins" (also described in that SO question)
(one less thing to worry with Git ;) )
The easiest way is to pick one branch:
remove the file from the other branch (rmname),
and to the merge.
The merge will add that same file in the other branch.
That process (rmname + merge) is illustrated in "Clearcase: How do I merge in a specific file from one view, into another, to avoid the Evil Twin scenario?"
(edit by Andreas)
Your solution worked great, I changed it for me since I noticed I have a specific case:
The file got bad since someone else renamed it... so it was not just as simple as your solution, but I had to do it "by hand", as is
Go to X:\FullyQualifiedPath (correct path in VOB)
Use:
cleartool ln FullyQualifiedName ./FileName
where FullyQualifiedName is the name as you get it e. g. from VersionTree when you say “Send To -> Copy” (something like //view, drop the file: before). This creates the link
Afterwards, you can see the desired version in the ClearCase Explorer again.
Related
I want to get list of files and directories affected by specific commit. I have no problem getting the commit itself but I rather don't know how to get affected files and directories.
Just to make it clear I need something like this:
file x - deleted
file y - added
file z - modified
Git is snapshot-based; each commit includes a full list of files and their state. Any notion of "affected" files needs another commit to compare it to. This is commonly done against its parents, which seems to be what you're asking about. You can figure out which files are different between two commits (or more exactly, their trees) by using the git_diff family of functions.
You can find an example of doing so in the examples listing for libgit2. There is also a more general annotated diff example. The second link also shows how to list individual files as well as their contents, if you need that. Check the reference for a a full listing of available function to work with diffs.
Note that this won't give you affected directorires by itself, as Git does not track directories, but only files.
You're looking for git diff.
The same function exists in libgit2, and the documentation for it is here.
If you're analyzing older commits, "git diff [commit1] [commitAfterCommit1]" will give you a list of changes that the second commit made from the first. You could prune this output to get yourself just the changed file names.
In Clearcase, I want to copy (fork, split) a file while preserving its history. Something like svn cp old.txt new.txt. How do I do it?
It isn't possible do fork a file in ClearCase.
If you refactor your code and split a file in two, one of them will appear as a new file and you will loose the information about who coded it. The annotate command will say the author of the lines are who splited it.
UCM or not, you cannot duplicate easily the full history of a file.
The best way to isolate an history is still to create a branch in order to make new versions to that file without impacting the same file in the original branch.
Thinking 'svn cp' should be available in ClearCase might come from the fact that, in SVN, branches are directories, and a tool like cc2svn will actually replicate ClearCase branches using 'svn cp'.
But since, with ClearCase, branches are first-class citizen, it is best to reason in term of branch than in term of copy/fork.
From the main page of cc2svn:
There is a difference in creating the branches in ClearCase and SVN:
SVN copies all files from parent branch to the target like: svn cp branches/main branches/dev_branch
ClearCase creates the actual branch for file upon checkout operation only.
Pretty simply done
Check out parent folder
Move element you wish to duplicate to appropriate location (not within the checked out parent folder)
Undo Checkout of parent folder
All the files get returned to the original folder with history and also the duplicate ones remain in the new location with the history too. Now each file can be checked out and changed individually
I just saw a very odd thing, I have a co-worker who has their configspec setup to look at the main branch, and earlier this morning he could see files in a certain folder, he hasn't changed that view and all of a sudden they were gone.
I took a look at the folder's node, and when I compare it with the previous version, it shows that there were like 4 files removed in the latest version of main (that was checked in probably a month ago, so long before the problem began).
So my question is why can I see them when I compare nodes, but not in the folder?
I compared the node I was looking at to previous, so it wasn't like I picked another node I wasn't looking at.
This is so confusing.
EDIT: This only happens with this one folder, the other like 10 folders in the view are all accessible and have the files visible too (and they're all branched the same).
EDIT#2: So they were able to see the files again, (And now I hear it's happened to a second person) by copying out the configspec, stopping the view, starting the view, and copying the configspec back in. Viola the files are back, but that still really doesn't explain what could cause that...
Just had the same issue. Turns out the horizontal bar dividing the file view and the "helpful text" was all the way to the top and thus hid the files. No easy indication that it's hidden. Had to look at co-worker's working view to realize that there's a horizontal bar to move.
The usual explanation is when you have the directory checked-out (unreserved) in your view:
Any change made by others (like rmname 4 files) won't be visible until you undo-checkout said directory.
The "all of a sudden" part means he was probably in a dynamic view, in which case you also have the possibility of an "eclipsed" element (a directory in this case): once the private directory (with the same name than the versionned directory, which is the definition of an eclipsed element in a dynamic view) is moved/removed, then the versionned directory takes its place (with the right content, i.e. minus 4 files).
Sounds stupid, but what is the protection of this folder? Does he has "read" access to it?
I have a big named branch with a lot of changes. Some of these changes are non-destructive so I want to pick these specific files out first, and merge them with default as soon as possible. (Then later, the destructive changes are merged as well.)
In Git I would create another branch and squash all changesets outside of the index, then I would add the specific files to the index and commit. After that, I could merge this temporary branch with master so master has a clean commit with only the non-destructive change. I don't know how to do this with Mercurial.
You can use hg cat to grab the contents of a file as it exists on any particular branch, and replace the working copy version with that.
This isn't technically a merge, but since you're replacing whole files you shouldn't have too much of a bad time merging things later:
for example, to grab myfile.c form branch somefeature, and replace the working copy version, do:
hg cat path/to/myfile.c -r somefeature > path/to/myfile.c
note that this completely replaces the working copy file so make sure you have no outstanding changes first
I think mercurialqueues is what you want. With mq you can turn any changeset into a patch and any patch into a changeset. So taking a changeset converting it to a patch deleting the chunks out of the patch that you don't want and then applying it to whatever branch you want. This is a fairly complex operation though and requires a certain amount of discipline on your part. So I would try to nail down your workflow on a test repo before trying it on code you care about.
As far as I know, Mercurial doesnt any have tools to split changesets. If youre lucky, all the changes you want are in separate changesets and then you can use the TransplantExtension. I think it can be compared to Git's cherry-pick but I havent used git much.
You can also use hg diff to manually commit the changes to a certain file to a new branch. Use the rev range to mark your entire source branch:
hg diff myfile -r startrevision:endrevision
The output can be treated as a patch. Do this for each file you want and commit them and then merge. Skipping the destructive changes. You can also, of course, do this multiple times of a destructive change is in the middle of a revision range.
Having said that what youre trying to do isnt something mercurial was built for. That hardcore history editing is more Git's area (note that its just my opinion). Keep your stable changes and destructive changes in separate changesets (and maybe even in separate branches). I use transplant, rebase and strip to move changes around. When its all done, they are merged and properly pushed.
Oh, and check MercurialQueues. I havent used it myself but Ive seen it do some crazy stuff. Maybe its capable of doing something along the lines of what you want.
Could anyone explain what is a Evil Twin and Subtractive merge in Clearcase?
Evil Twin
An Evil Twin is an element that you have removed (using rmname) and want to re-add, but it's 'evil twin' exists in previous versions of the directory.
You have to remember that each element had a unique ID, so you are attempting to add an element with the same name - but with a different UID. This is not allowed.
The best way to deal with an Evil Twin is to relink the newest version you can find of the existing element to the new version of the directory. You can then make a new version of the element and replace the data within it.
Subtractive Merge
A subtractive merge is the opposite of a selective merge.
A selective merge (the default, bog standard merge) adds the changes from another element version into your checked-out version.
A subtractive merge attempts to remove the changes made in a different version from the version you have checked out - because it's a bad version, you've made mistakes in it etc.
IBM has a nice article on substractive merge.
A subtractive merge can be performed to exclude or bypass bad versions on a branch without actually removing the bad versions.
Cleartool merge using the -delete option will allow a user to merge from the last known good version to a new version on the same branch which excludes the work done in the versions identified as bad versions.
This merge must be performed from the command line, it does not create a merge arrow, the arrow can be created manually.
This will work for file as well as directory
But you need to realize that merge is about a file or a directory, not about a directory "and everything in it".
To merge recursively, take a look at findmerge.
You can want to merge only directories (since they are always merged first, to determine the actual list of files to merge!), as in this IBM article
% cleartool setview major_vu% cleartool findmerge /vobs/vob1 /vobs/libvob2 –type d \
–fversion /main/LATEST –merge
you may also do the merge from the LATEST version of a branch or from a tag:
findmerge . –fversion /main/rel2_bugfix/LATEST –print
findmerge . –ftag rel2_bugfix_view –whynot –print
Note: the -print is always a good idea before replacing it by '-merge -gmerge', in order to get a preview of what will be merged. But if directories are involved, it will only print that 'directory X' needs to be merged, not the exact list of files.
For evil twins, check out the IBM article. Case sensitive issues can be a real pain to deal with and create some evil twins without you realizing it...