Multiple questions about Perforce - perforce

I have multiple questions about Perforce :
Is there a way to easily select all the files in your depot/workspace to modify them all at once?
In the same vein, the files in my depot are not exclusive, is there a way to modify them all at once so that their filetype is "-l" AND is there a way that all new files that will be added be exclusive by default?
Is there a way to have a sync that wipes everything you changed locally and deletes new files you currently have in your workspace that aren't in the depot?
This question is pretty much the opposite of #3. Sometimes it's hard to know which files you modified and need to submit, is there a way for Perforce to automatically detect and checkout everything you modified AND also mark for add everything you added?
Thank you so much!

p4 edit //...
p4 edit -t +l //...; p4 typemap -> +l //...
p4 clean //...
p4 reconcile //...

Related

Make the contents of a perforce directory exactly match the latest depot version

I would like to make the contents of a directory in a Perforce workspace be exactly the same as the latest depot contents. I want this to work no matter what has gone on in the workspace. (For example, editing files without opening them in perforce, creating unsubmitted changesets, etc.)
So far I have come up with running this series of commands, in order:
p4 clean ...
p4 revert ...
p4 sync ...
Will this do what I want? Is this the correct order? Is there a simpler way?
Those are the correct commands, and you do need all three:
revert is needed to discard changes to files you've opened
clean is needed to discard changes to files you haven't opened (including added files)
sync is needed to make sure you're at the very latest depot revision
You should either put clean after the revert or add -w to revert; otherwise files that were opened for add will be skipped by the clean (because they're open) and then revert will "abandon" them in the workspace (the -w option causes revert to delete/"wipe" added files instead of abandoning them). Other than that, I think the order is unimportant.

Perforce Changelist and shelve command

I am very new to Perforce and just started using it.
After syncing my code using $p4 sync command i started editing a few files.
$p4 edit file1
$p4 edit file2
$p4 edit file3
These files were getting added to my default changelist. For collaborating with my team i wanted to create a changelist. For creating a changelist i ran $p4 change and removed "file1" from the changelist description. Now when i run $p4 opened. It gives an output similar to this.
//depot/... /file1 edit default change (text)
//depot/... /file2 edit default 111 (text+k)
//depot/... /file3 edit default 111 (text+k)
Now i have the following questions in my mind:
Which changelist am i currently working on is it default or 111 ??
what is the meaning of (test + k)?
When i make changes to file2 and file3 it is getting synced to changelist 111 and when i make changes to file1 it gets synced to default changelist . I am highly confused how is this happening ?
Also one more thing i am confused about is if do $p4 shelve will my changes disappear and will be reapplied only when i run unshelve command for the changelist created ?? Is this similar to git stash and git stash apply ?
It will be great if someone can answer these questions in detail. Any tutorial suggestions for Perforce will also be of great help.
Thanks in advance.
My recommendation for a Perforce tutorial is the Perforce User's Guide. Here's the section on changelists:
https://www.perforce.com/perforce/r15.1/manuals/intro/chapter.working_in_perforce.html#working_in_perforce.working_with_files.changelists
Which changelist am i currently working on is it default or 111 ??
Both! Both of these are pending changelists in your workspace.
what is the meaning of (text+k)?
The thing in parentheses is the "filetype". +k is a "filetype modifier" meaning that keywords (special words like $Id$ and $Revision$ and $Author$ in this file will be automatically expanded to appropriate values when you submit.
When i make changes to file2 and file3 it is getting synced to changelist 111 and when i make changes to file1 it gets synced to default changelist . I am highly confused how is this happening ?
Nothing is getting "synced" anywhere yet -- the pending changelists are just containers that reference the different files. When you shelve or submit, then the files associated with those changelists will get sent to the server and will be accessible by other clients. Since shelve and submit are changelist-level operations, only the files in those changelists are affected -- that's the point of having different pending changelists. You have all of the pending files in your workspace, but you can split up which ones get sent to the server at which times (it's a little like pushing different branches in git, but not -- you can do this on every operation in Perforce even when you aren't branching because each file is versioned individually rather than having the entire tree versioned as one atomic blob).
Also one more thing i am confused about is if do $p4 shelve will my changes disappear and will be reapplied only when i run unshelve command for the changelist created ?? Is this similar to git stash and git stash apply ?
No, p4 shelve only syncs the shelved change on the server with the local files in your workspace -- it doesn't in itself change your workspace. The equivalent of "stashing" would be to p4 shelve and then to p4 revert to wipe out the workspace changes. shelve on its own is a little more like doing a git push to a branch -- you keep your local copy but now it's also on the server (but not part of the "master" history). (It's not exactly the same though -- to be honest if you're brand new to Perforce I'd stick to regular old "submit" in a regular old branch since that's the basic workflow. Sharing work via shelves requires a lot more manual work since each shelf is like its own little mini-branch with no versioning.)

Accidental mark for delete - entire depot and reverting - perforce ..How to remove that tag(Mark for delete) from all files

Whole workspace files marked as delete in local also and depot also.
Depot contains thousands of file ..While reverting file options P4 get's hanged..
Any Solution for this ...help me...
Thanks in advance.
When P4V hangs on these mass commands, I prefer using the command-line. In this case, p4 revert //depot/path/to/the/workspace/....
Make sure you don't actually revert things you want to keep though.

Automatically deleting newly added files when shelving in Perforce

When I shelve a pending changelist, changes to existing files are reverted, but newly added files are not deleted from the filesystem. I need to manually delete these files every time I perform a shelve operation. Is there anyway to automatically delete newly added files when shelving?
in p4, if you're willing to make it two operations, you can do a normal shelve on the changelist, and then do p4 revert -w on the same changelist, which deletes added files. i'm not sure how to do this in p4v.
It looks like P4V added this in a recent release!
https://www.perforce.com/perforce/doc.current/user/p4vnotes.txt
#40757 (Changes #1619278, #1618572)
The Shelve Dialog has an option to remove the files from disk that are marked for
'Add'.
To do this in p4v, you can create a custom tool, say "revert-added-file-and-delete", adding it to applicable context menus, with application p4 and arguments revert -w %F.
Unless someone knows of a way to chain custom tools together (and I couldn't find a way to do it), to do a shelve/revert will require a separate shelve followed by a use of the custom command, revert-added-file-and-delete.
Sure, except that shelving work is a fundamentally different beast. If I create a new class that uses a new function in an existing class, and then shelve both files, the new class remains, and is now referencing a non-existent function in the existing class. Now I've got build errors and have to manually delete the new file in order to get back to a clean slate, which is exactly what shelving work should do for me.
p4 shelve -c changelist_number
p4 revert -w -c changelist_number //...
I don't think that there is a way to do this. This behavior is consistent with reverting files that have been added. If you 'p4 add' a file and then revert it, it will not be deleted on revert. Seems like it would be bad behavior if it did! Losing a file and the work that has gone into the file on a revert would be very bad. Consider this: you code up a file in your editor, you save diligently, and finally you are ready to 'p4 add' it to perforce. Then you decide you don't want to do this so you revert and then you lose your file???
So reverting adds won't delete the file.

Perforce - submit only files open for branch, not files open for edit

Quite often when I'm working in a branch in Perforce, I realise I need a file I didn't branch when I initially branched.
So, I add the file to my client, run p4 integrate -b branchname, then p4 submit.
Thing that bugs me is that I then need to go through the list of files for submit, and remove all entries that are open for edit.
I can't see any option in p4 help submit, but it seems like this might be a reasonably common use case.
First do
p4 submit
Assuming your p4 editor is vi,
type this command in command mode
g/#.*edit\|#.*add\|#.*delete/d
You can choice to submit a single file on the command-line.
p4 submit <filename>
Then it won't bug you about the other files.
If you have more than one file, then maybe you should move all of the files you are currently editing onto an numbered changelist, or branch onto a numbered changelist, which will provide the separation you want.
If you're going to do this, it's much easier to manage numbered changelists from one of the GUIs.

Resources