I am trying to rename a file. I typed in the following command
p4 rename file1 file2
but I get the error "file1 is open; rename would ignore changes". What am I doing incorrectly?
You need to make sure the file is not checked out in any workspace including other users workspaces before you rename it.
Related
In Perforce, I'm trying to do the merge, it has some conflicts and and created pending change list. Pending has more than 10000 files. Because of the long list of files they are are not visible in GUI. How to see the conflict files in GUI or command line?
To resolve non-conflicting files from the command line, do:
p4 resolve -am
After you've done that, you can resolve remaining files with:
p4 resolve
Or just get a list of the remaining (conflicted) files with:
p4 resolve -n
http://forums.perforce.com/index.php?/topic/5125-how-to-see-the-conflits-on-pending-change-list-during-merge/#entry20967
find . -type f -print | p4 -x - add
This adds all files from $PWD and its sub directories, but it prints the message can't add existing file for files already in perforce.
How do I add only new files which are not in P4?
For Perforce versions 12.1 and above, you can use the command p4 reconcile, which will reconcile any added, deleted, or edited files outside of Perforce. To use it specifically to add files, type p4 reconcile -a.
Just a note though, it doesn't do any harm to do the command you are doing. It issues a warning for any files already existing, but that's it. It will still add the files that don't currently exist in Perforce. Your command is the way I have done it until the p4 reconcile command was created.
I need to find out if file/folder is under specific source control.
The easiest way of doing this is to find some hidden folders. (this does not guaranty that partifical file is under source control, but with some probality says that this source control was used )
It's quite straightforward with SVN, GIT, as they have hidden folders.
But I can not find the same things for Perforce and ClearCase. Are there any universal way to understand what VSC is used in those paricular cases?
Perforce does not litter the drive, but keeps the info on the server. Also, files can be mapped in different structures, and mixed with non-controlled files, so it's not something you can determine by looking at the file itself.
However you can simply ask Perforce. For example, at the CLI:
P4 fstat FILENAME
Will give you info about a file if it is under source control.
If you need to script it for Perforce, there is an option (-s) that makes things easier (since the exit code of p4 doesn't indicate success or failure of the Perforce command). So, for bourne-like shells something like this should work:
if p4 -s fstat FILENAME | grep 'exit: 0' >/dev/null 2>&1 ; then
echo "Perforce knows this file"
else
echo "Perforce don't care"
fi
For ClearCase, you will find a hidden file named view.dat at the root directory of a (snapshot) view .
If the file is under M:\ (Windows) or /view/vobs (Unix), no need to look for an hidden file or directory: you know it is a dynamic view.
Another way is to execute, in the parent directory of a file:
cleartool lsview -cview.
If that directory is in a view, that command will return its name.
Similarly, i you can run a command like p4 reconcile or p4 status, and it doesn't return an error, chances are you are in a Perforce workspace.
I am new to Perforce. Could you add a new folder under the branch in the depot? I also tried to add one in my workplace but how could I get it to the depot? Do I have to do a merge/integrate or something?
Thanks.
p4 add doesn't support recursive add .
Here's a unix shell work-around to run from within the root folder you want to add:
find . -type f -print | p4 -x - add
If your server version is 2012.1 or later, you can use the reconcile command to do this, with full wildcard support:
p4 reconcile //depot/path/to/folder/...
From your local workspace, create your folder and a file you want to go inside it. Then either mark it as add from the visual client, or go into the folder from the command line, and type...
p4 add ./new_folder/new_file_name.ext
When you submit, the new file and folder will be in your repository. This assumes that new_folder is a subfolder of your existing workspace. Please let me know if it isn't and I'll update my answer.
Above command will add files under default changelist. And later if you want to see the if files are really added in default changelist
p4 opened
And for the submission of opened files, under the default changelist, to depot
p4 submit
Use command
p4 add directory_to_be_added/...
This will recursively add all contents starting drom "directory_to_be_added"
To add files from a directory in perforce
p4 reconcile -f -c [changeList] -a <dir_path_to add>
I had a situation that I need to add entire folder with files having wildcard name, so had to do it through command line using -f (force), I used "dir /b /s /a-d | p4 -x - add -f"
If you are using p4v to add a folder recursively, you need to click on:
"Connection" -> "Edit Current Workspace"
then manually add the mapping of the new folder to your depot.
Then go to your "Workspace" view and right click on the root folder, click "Mark for Add" and comment. All the files under it should show up in the new pending change list.
I have 10k perforce files mentioned in my file.txt.
I need to open them using p4 edit command.
I expect some command like "p4 edit ?????file.txt". Can you help me to check these files out?
You can use the -x flag on p4. This is assuming a UNIX shell.
cat file.txt | p4 -x - edit
I assume you have some copy of directories structure where you have changes, and now you need to add those files to a change list. Which is impossible to do without checking them out. Am I right?
If I needed to change that much amount of files, I would do like this:
Copy all files I wanted to check in replacing read-only files (Wondows Explorer can do that)
In P4V go to a directory you need to check out files in, and then call "Reconcile offline work".
In appeared dialog choose all files.
Get new changelist with changed files being checked out.
I used this solution a couple of times - it works for added, changed and deleted files.
Just use below command to edit all files present in file.txt
p4 -x file.txt edit