How to get C function name in code diff using "P4 diff" command? - diff

Is there any equivalent option of in perforce (P4) command-line to get function name in code diff?
I need to have function name corresponding to each code diff segment in generated diff file.
This will help me navigate to function call from code-diff using CTAGS.

Note this excerpt from p4 help diff:
If the environment variable $P4DIFF is set, the specified diff
program is launched in place of the default Perforce client diff.
It happens that if P4DIFF includes spaces, p4 treats it as an executable name with arguments, so you can do:
export P4DIFF="diff --show-c-function"
(or an equivalent for whatever console shell you're using) then when you run p4 diff, you should see function names for C-based code.

Related

accurev merge doesn't pass file titles to external merge tool

I'm using p4merge as external merge tool for Accurev. I created a wrapper for p4merge and set the command "p4m -dw -tw 8 -nb %3% -nl %4% -nr %5% %a% %1% %2% %o%" for both acgui (Tools-Preferences-Diff/merge) and CLI (AC_MERGE_CLI variable).
It successfully works in acgui, but when I use CLI version (accurev merge <filename>), Accurev doesn't pass file titles for %3, %4 and %5.
What's wrong with it? How can I get file titles for CLI?
UPD: I'm using Accurev 6.0.1
The commands for diff and merge will need to be different asAccuRev does not pass the same parameters for both. You will need to refer to the AccuRev User CLI Guide for the list of valid parameters for both commands.
I was able to get the diff to work using the following:
c:\Program Files\Perforce\p4merge.exe -dw -tw 4 -nl "%3%" -nr "%4%" %1% %2%
Notice the double quotes around the left and right titles and the omission of the base/ancestor parameters. Also, in a diff, there is no output file expected.
The merge command did not work due to how P4Merge is handling the output file name given by AccuRev. I received an error stating the output temp file is invalid. However, AccuRev expects the merge tool to create the file upon completion so this is an shortcoming of P4Merge. The following may be a good starting point for discussion with the Perforce folks:
c:\Program Files\Perforce\p4merge.exe -dw -tw 4 -nb "%3%" -nl "%4%" -nr "%5%" %a% %1% %2% %o%

Perforce: Prevent keywords from being expanded when syncing files out of the depot?

I have a situation where I'd like to diff two branches in Perforce. Normally I'd use diff2 to do a server-side diff but in this case the files on the branches are so large that the diff2 call ends up filling up /tmp on my server trying to diff them and the diff fails.
I can't bring down my server to rectify this so I'm looking at checking out the the content to disk and using diff on the command line to inspect and compare the content.
The trouble is: most of the files have RCS keywords in them that are being expanded.
I know can remove keyword expansion from a file by opening the files for edit and removing the -k attribute from the files in the process, but that seems a bit brute force. I was hoping I could just tell the p4 sync command not to expand the keywords on checkout. I can't seem to find a way to do this? Is it possible?
As a possible alternative solution, does anyone know if you can tell p4 diff2 which directory to use for temporary space when you call it? If I could tell it to use abundant NAS space instead of /tmp on the Perforce server I might be able to make it work.
I'm using 2010.x version of Perforce if that changes the answer in any way.
There's no way I know of to disable keyword expansion on sync. Here's what I would try:
1) Create a branch spec between the two sets of files
2) Run "p4 files //path/to/files/... | cut -d '#' -f 1 > tmp"
Path to files above should be the right hand side of the branch spec you created
3) p4 -x tmp diff2 -b
This tells p4 to iterate over the lines of text in 'tmp' and treat them as arguments to the command. I think /tmp on your server will get cleared in-between each file this way, preventing it from filling up.
I unfortunately don't have files large enough to test that it works, so this is entirely theoretical.
To change the temp directory that p4d uses just TEMP or TMP to a different path and restart p4d. If you're on Windows make sure to call 'p4 set -S perforce TMP=' to set variable for the Perforce service; without the -S perforce you'll just set it for the current user.

p4 sync Perforce command line to sync multiple trees to one changelist by entering the changelist only once

How can I sync 2 completely separate trees at a given changelist by entering the changelist only once, e.g. giving the same result as
p4 sync //tree1/a/b/c/...#1234 //tree2/d/e/...#1234
which works, but requires entering 1234 twice?
This gives "syntax error near unexpected token `('":
p4 sync (//tree1/a/b/c/... //tree2/d/e/...)#1234
This syncs //tree1/a/b/c/... to head instead:
p4 sync //tree1/a/b/c/... //tree2/d/e/...#1234
The main reason is that I want to make a shell alias but the 1234 part is user-entered, so it must be entered only once. I know I can use a shell script or function but for various reasons, I must use an alias.
From the comments, the (bash, at least) shell syntax of
p4 sync {//tree1/a/b/c/...,//tree2/d/e/...}#1234
should work. For more explanation, see the brace expansion section of the bash reference.

Running a perl script on windows without extension

I am trying to find a way to register the files with extension .pl as executables.
I spent some time on the web looking for a solution, but I couldn't find anything.
What I can do:
I made a script, let's call it myscript.pl
I can run it like this :
perl myscript.pl [my_script_parameters]
Now since the file is associated with perl, I can also run it as:
myscript.pl [my_script_parameters]
Now, I know that there is somewhere a list of extensions that are considered as executables (.exe, .bat, etc…). I would like to add .pl to this list so that I can run my script like this:
myscript [my_script_parameters]
Does anyone know how to do this?
Yes, there is built-in support for this. If you check the help for command FTYPE you will see a perl example.
C:>help ftype
Displays or modifies file types used
in file extension associations
FTYPE [fileType[=[openCommandString]]]
fileType Specifies the file type to
examine or change openCommandString
Specifies the open command to use when
launching files
of this type.
Type FTYPE without parameters to
display the current file types that
have open command strings defined.
FTYPE is invoked with just a file
type, it displays the current open
command string for that file type.
Specify nothing for the open command
string and the FTYPE command will
delete the open command string for the
file type. Within an open command
string %0 or %1 are substituted with
the file name being launched through
the assocation. %* gets all the
parameters and %2 gets the 1st
parameter, %3 the second, etc. %~n
gets all the remaining parameters
starting with the nth parameter, where
n may be between 2 and 9, inclusive.
For example:
ASSOC .pl=PerlScript
FTYPE PerlScript=perl.exe %1 %*
would allow you to invoke a Perl
script as follows:
script.pl 1 2 3
If you want to eliminate the need to
type the extensions, then do the
following:
set PATHEXT=.pl;%PATHEXT%
and the script could be invoked as
follows:
script 1 2 3
You can simply add ";.PL" to the PATHEXT environment variable. Right-click "My computer" > Properties > Advanced > Environment variables > System variables.
Your best approach would be to write a batch file called myscript.bat, place it in your path, and have it run your script.. e.g.
#echo off
c:\perl\bin\perl.exe c:\scripts\myscript.pl %*

diffstrings.py : how do you specify path arguments?

I am trying to use diffstrings.py from Three20 on my iPhone project, and I can't find the proper format for the path arguments (as in "Usage: diffstrings.py [options] path1 path2 ...").
For example, when I run the script in my Xcode project directory like this
~/py/diffstrings.py -b
it analyzes just the main.m and finds 0 strings to localize,
then it diffs against existing fr.lproj and others, and finds that thes contain "obsolete strings".
Can anyone post examples of successful comand line invocations of diffstrings.py, for options -b, -d and -m?
Taking a quick look at the code here http://github.com/facebook/three20/blob/master/diffstrings.py I see that if you don't specify any command line options, it assumes you mean the directory wherever the script lives in. So the option is to either copy .py file to where your .m files are, or simple use the command
~py/diffstrings.py -b .
That is, give the current directory (.) as the path argument.