Restore revision history of a copied file using Perforce - version-control

I copied a bunch of java classes into another java package outside of perforce by accident and made a bunch of changes to them. I now realised that the revision history of those files has been lost as I didn't use perforce to copy the files over.
Example:
original file - dir1/Class1.java
copied file - dir2/Class1.java
The original file still exists.
If I want to restore the revision history of the files what would be the appropriate command to run in order to do this?

You should have branched the file in Perforce rather than copied it outside of Perforce, but that can be remedied.
Copy dir2/Class1.java to another location then delete the original
Branch dir1/Class1.java to dir2/Class1.java
Check out dir2/Class1.java
Copy the backup of the file you made in step 1. to dir2/Class1.java
Check in dir2/Class1.java
You will then have your recent modifications to the file dir2/Class1.java in version control and the file will be linked to its original via the branch history.

Related

In CVS how to ignore a file which is already checked in

In our CVS (not git!) repo I have a file which I checked in a while ago. Now we have decided not to keep it in version control.
How can I keep the file in my local directory but tell CVS not to store it? Just adding it to .cvsignore (obviously) doesn't do the trick.
As #tripleee mentioned in the comments, the following works:
Move the file in question out of the repository (but don't delete it).
Check in the removal of the file.
Commit the change to CVS.
Move the file back into its location the repo.
Add it to the appropriate .cvsignore file.
Done.

Merging conflict with Unity Script Assemblies

I want to be able to merge my changes to the main repository branch. I accidentally merged all my Unity files on the last merge and I think that caused an error for my next merge . I get the following error:
% hg --repository C:\kiln\development merge --verbose --tool=internal:fail 4595
~/Assembly-CSharp-Editor.pidb: untracked file differs
~/Assembly-UnityScript-Editor.pidb: untracked file differs
~/Library/ScriptAssemblies/Assembly-CSharp-Editor.dll: untracked file differs
~/Library/ScriptAssemblies/Assembly-CSharp-Editor.dll.mdb: untracked file differs
~/Library/ScriptAssemblies/Assembly-UnityScript-Editor.dll: untracked file differs
~/Library/ScriptAssemblies/Assembly-UnityScript-Editor.dll.mdb: untracked file differs
~/Library/ScriptAssemblies/Assembly-UnityScript-firstpass.dll: untracked file differs
~/Library/ScriptAssemblies/Assembly-UnityScript-firstpass.dll.mdb: untracked file differs
abort: untracked files in working directory differ from files in requested revision
I'm not sure what to do now. I was thinking about deleting those files from my local repository and then pulling from the main repo. However, I'm afraid those files might damage my game somehow.
What should I do?
In general you should not check the Library folder into Mercurial. From the Unity Manual:
When checking the project into a version control system, you should add the Assets and the ProjectSettings directories to the system. The Library directory should be completely ignored - when using external version control, it's only a local cache of imported assets.
(see also http://docs.unity3d.com/Documentation/Manual/ExternalVersionControlSystemSupport.html)
Specific to your question: All dll and mdb-files in the Library/ScriptAssemblies folder are automatically regenerated from your code files so you can safely delete these files. Unity will regenerate them when it's recompiling the code in your project.

what happens when I copy a checked out code folder under CVS?

I am working with a CVS repository found on a remote server.
I check out the code to a local directory code_local
Then I copy code_local, into code_local_2
Do I have now two independent local copies of the repository? Can I change files, commit, update etc. on each directory independently, is if it was done form two different computers?
(this may depend on the way CVS stores information about a local copy)
Yes I do know it's not a straight forward use of CVS, just asking if it will work
Do I have now two independent local copies of the repository?
Yes you have two independent LOCAL copies.
Can I change files, commit, update etc. on each directory
independently?
No, both copies point to the same file on the same repository. so they are independent as long as you haven't committed them. when committed the last commit operation will overwrite the previous one.
in fact there is a CVS folder beside every folder of your code that keep repository information of files inside that folder. so when you copy a project or a package, the CVS folder will be copied along with, so the same repository entries will be referenced, no matter how many copies have you made.
Even if you past the copied folder to another package hierarchy, whenever you commit the files it will replace the original files in repository where it first created.
If you want to have independent copies you have to copy and place your source code (.java) files only and commit it through Eclipse for example, in this case the CVS plug-in doesn't find any existing CVS folder beside the new folder and generates a new one in the local and new entries in the repository.

Replace local file by remote file

How do I replace a local file by its latest version in the repository?
Is there also a way of replacing all local files which are conflicting with the corresponding files from the repository?
Both hg update -C and hg revert will do what you are looking for - replace a locally modified file with the clean version in the repository. Personally I prefer hg revert but hg up -C will also do the job
hg revert
Some further details from the help for hg revert
With no revision specified, revert the specified files or directories to
the contents they had in the parent of the working directory. This
restores the contents of files to an unmodified state and unschedules
adds, removes, copies, and renames. If the working directory has two
parents, you must explicitly specify a revision.
Using the -r/--rev or -d/--date options, revert the given files or
directories to their states as of a specific revision. Because revert does
not change the working directory parents, this will cause these files to
appear modified. This can be helpful to "back out" some or all of an
earlier change. See "hg backout" for a related method.
Modified files are saved with a .orig suffix before reverting. To disable
these backups, use --no-backup.
Hope that helps
Chris
svn update ?
Or delete your folder, and svn checkout...
Or try the option --force.

can't commit code after renaming a file

What I did:
renamed a file
tried to commit
cvs fails with error message
file should be removed and is still there (or back again)
What is the problem and how do I solve it so that I can commit?
Additional information:
I'm using Eclipse with the CVS plugin.
doing an ls in the directory where the file was shows that it is not there
All the other Google hits for this problem (including this question) seem to be asking what to do when a file has been removed with cvs, and then restored outside of cvs' scope. My problem is different: I just need to rename a file.
It means that the file was flagged for deletion by CVS but then appeared again. Renaming for CVS is just a deletion of the file with old name and adding the file with new name. The file must be appeared again with its old name.
You can do 2 things:
1) If you don't need this file then just delete it. (Use cvs -n update command to find its name.) Then you will be able to commit.
1) if you need this file to stay, go to the .CVS subfolder of the folder where the file is located and edit Entries file. Find a line with your file and delete it. Then rename you file (give it a temporary name), call cvs update, rename your file back overriding the new one appeared after cvs update.