how to list files which are deleted in depot but opened in edit locally? - version-control

I am using p4 in linux. I was doing some changes to a file which was opened under edit in my local. When i tried submitting it, i found that the file has been deleted from the depot.
Is there some command in perforce which i can run and check if a file opened under edit in local has been deleted in the depot? Even some fancy one-liner would do.
Please note i am using an old version of perforce, so all the new fancy commands might not be available to me.
Thanks in advance.

Run p4 fstat my-file.
If it says headAction delete, then the file is currently deleted in the depot.
If it says action edit, then you have the file open for edit.

This worked for me, hope it would be helpful for others
( find . -maxdepth 1 -type f -print0 | xargs -0 p4 fstat > /dev/null ) | & awk '{print $1}'

Related

How can I revert all open files in perforce?

I know how to revert a single opened file. However sometimes I hit some issues where I have to revert all files attached in a single changelist or revert all open pending files (default CL or assigned CL) in a client. Is there any way to do that? I tried p4 revert -c <changelist> where has multiple pending files. It didn't work for me. It works if I mention ALL the file names.
For me the following worked as well
p4 revert //... : Revert every file you have open, in every one of your pending changelists, to its pre-opened state.
or
p4 revert -c default //... : Revert every file open in the default changelist to its pre-opened state
Taken from : p4 revert documentation
I bet you just need to provide a filespec, try p4 revert -c <changelist> //...
On linux
p4 opened | sed 's/#.*//g' | xargs -n 1 p4 revert
Slight updated in the answer of #Talespin_Kit
Below one takes care of files that have spaces in their name
$p4 opened | sed 's/#.*//g' | xargs -n 1 p4 -d '\n' revert
When I try to run the command from the accepted answer
p4 revert -c <<changelist>>
I get the error:
Usage: revert [ -a -n -k -w -c changelist# -C client ] [--remote=rmt]
files... Missing/wrong number of arguments.
What I had to do was add the file name at the end of the command like so
p4 revert -c <<changelist>> //depot/folder/folder/file.txt

Where is the CVS log file stored?

I am using winCVS and I want to access the log file for commits in a repository so That I can search for a certain comment but i cant find the log file anywhere.
Where is it stored?
You could also use the cvs command directly, as in this answer:
cvs log -r BRANCHNAME | grep acomment
(you have grep command on Windows through Gow Gnu On Windows)

p4 CLI: How to find new files not yet "added" to perforce control

I have looked at different ways of doing this using diff. The first option I tried is:
p4 diff -sa
Opened files that are different from the revision in the depot, or missing.
Initially I figured that this was a file with write permission bit set that did not exist in the depot. However, I have since learned p4 doesn't use mode bits to track opened/unopened states as I first thought.
Next I figured this option would work:
p4 diff -sl
Every unopened file, along with the status of 'same', 'diff' or 'missin' as compared to its revision in the depot.
This would be okay, except "unopened" is not inclusive of "untracked" files. Although, when I ran this, it produced something quite different that contradicts the documentation; it output pretty much everything that was tracked, but also output everything that wasn't tracked, but flagged them as 'same'. Maybe this means that it hasn't been added and doesn't exist in the depot, so the client is the same as the depot...? In my SVN biased opinion, a rather pointless option.
Then there is the 'opened' option. But this does exactly that. It lists all the files in the depot that have been opened on the client; so not the files modified on the client not yet added.
So is there an option I am missing somewhere, that will provide some valuable answer, like SVN and CVS are able to do with one simple command?
$ svn status
A added
M modified
R deleted
? untracked
L locked
C conflict
Or:
$ cvs -q up -Pd
Okay, looking around and playing with the 'add' command, it seems that a read-only add will output successful message if the file is not currently controlled:
$ p4 add -n -f somefile
//source/somefile#1 - opened for add
I applied this to the following command and pretty much get what I need:
$ find . -type f | while read f ; do p4 add -f -n "$f" | grep -e '- opened for add' >/dev/null && echo "A $f"; done
A ./somefile
Or if you're not bothered about local paths:
$ find . -type f | xargs -l1 p4 add -f -n | grep -e '- opened for add'
//source/somefile#1 - opened for add
Well, there exists "p4 status", which is very similar in both purpose and behavior to "svn status".
For more ideas, see: http://answers.perforce.com/articles/KB_Article/Working-Disconnected-From-The-Perforce-Server

bash script problem, find , mv tilde files created by gedit

im using linux with gedit which has the wonderful habit of creating a temp file with a tilde at the end for every file I edit.
im trying to move all of these files at once to a different folder using the following:
find . -iname “*.php~” -exec mv {} /mydir \;
However, its now giving me syntax errors, as if it were searching through each file and trying to move the piece of text. I just want to move all of the files ending in .php~ to another directory. Any idea how I do that?
Cheers Ke
Try this one-liner:
for D in `find . -iname "*.php~"`; do mv ${D} /mydir; done
For future reference, if you go into Edit > Preferences > Editor Tab, there is checkbox for "Create a backup copy of files before saving" That is the guy responsible for creating the tilde version.
GNU find
find . -iname "*.php~" -exec mv "{}" /mydir +;
or
for file in *.php~
do
echo mv "$file" /mydir
done

Is there an easy way to revert an entire P4 changelist?

Let's say I checked in a changelist (in Perforce) with lots of files and I'd like to revert the entire changelist. Is there an easy way to "revert" the entire changelist in one fell swoop?
Currently I do something like this for each file in the changelist:
p4 sync //path/to/file#n (where "n" is the previous version of the file)
cp file file#n
p4 sync //path/to/file
p4 edit //path/to/file
cp file#n file
rm file#n
As you can imagine, this is quite cumbersome for a large changelist.
The posted answers provide correct answers, but note also that there is an actual menu option in P4V to do this for you now. It's in the latest 2008.2 Beta, and so should be officially released the the next week or three.
This link gives details.
It should be a lot simpler to use than the earlier answers, but I've not had the opportunity to try it myself yet.
Update This has now been fully released. See Perforce downloads.
This looks interesting. I haven't tried it personally.
The official answer from Perforce is at http://kb.perforce.com/UserTasks/ManagingFile..Changelists/RevertingSub..Changelists but the procedure is not all that much easier than the one you suggest. The script suggested by #ya23 looks better.
For some reason, the awk step does not work for me. I'm running from a Windows environment with emulated Unix command line tools. However, the following does work:
p4 describe -s [changelist_number] | grep // | sed "s/\.\.\. //" | sed "s/#.*//" | p4 -ztag -x - where | grep "... path " | sed "s/\.\.\. path //"
Here are possible locations to get Unix command line tools in a Windows environment:
http://sourceforge.net/projects/getgnuwin32/?source=typ_redirect
http://unxutils.sourceforge.net/
I have the same problem when I want to delete an entire changelist. so I use the following script (notice that it also deletes the changelist's shelve and the changelist itself. if you only want to revert, copy the relevant lines).
Also, make sure the sed applies to your version of p4.
#!/bin/bash
set -e
if [[ $# -ne 1 ]]; then
echo "usage: $(basename $0) changelist"
exit 1
fi
CHANGELIST=$1
#make sure changelist exist.
p4 describe -s $CHANGELIST > /dev/null # set -e will exit automatically if fails
p4 shelve -d -c $CHANGELIST 2> /dev/null || true # changelist can be shelveless
files_to_revert=$(p4 opened 2> /dev/null | grep "change $CHANGELIST" | sed "s/#.*//g")
if [[ -n "$files_to_revert" ]]; then
p4 revert $files_to_revert
fi
p4 change -d $CHANGELIST
The problem starts when you want to revert an entire changelist ( as a bulk ) that you've just submitted, and you need to start reverting files of #n-1 one by one fast ( because it's production ) ...
Wanted to support ya23's answer- the link of a Python script - it's really really easy to use ( and really easy to miss his comment )
You give it the revision you want to rollback, and it prepares everything automatically ( each file's #n-1 & merging and everything ) ... you just submit.