Jump to content


Bypass dialog during p4vc diff

p4vc p4v diff

  • Please log in to reply
9 replies to this topic

#1 bhuvan

bhuvan

    Newbie

  • Members
  • Pip
  • 5 posts

Posted 05 March 2019 - 05:08 PM

Hi,

I recently started using perforce. I want to open p4v diff window from command line and I use p4vc diff <file#1> <file2#1>. This opens a dialog box showing the files and revisions. Is there a way to skip/bypass the dialog box straight to differences?

Thanks!

#2 P4Reg

P4Reg

    Advanced Member

  • Staff Moderators
  • 98 posts

Posted 06 March 2019 - 10:51 AM

I don't believe you can. While the Invoking P4V from the command line article concerns invoking p4v directly rather than using p4vc, it does state the following for the diffdialogue:

Only the diff dialog is displayed -- the diff is not performed until the user clicks the "Diff" button

#3 Sambwise

Sambwise

    Advanced Member

  • Members
  • PipPipPip
  • 917 posts

Posted 06 March 2019 - 03:58 PM

You should be able to invoke P4Merge (the diff tool) directly from the command line on two local files:

p4merge file1 file2

If they're two depot revisions that you don't have locally, you'll need to write a small script, something like:

p4 print -o file1 //depot/file1#1
p4 print -o file2 //depot/file2#1
p4merge file1 file2
rm file1 file2

#4 bhuvan

bhuvan

    Newbie

  • Members
  • Pip
  • 5 posts

Posted 06 March 2019 - 05:06 PM

View PostSambwise, on 06 March 2019 - 03:58 PM, said:

You should be able to invoke P4Merge (the diff tool) directly from the command line on two local files:

p4merge file1 file2

If they're two depot revisions that you don't have locally, you'll need to write a small script, something like:

p4 print -o file1 //depot/file1#1
p4 print -o file2 //depot/file2#1
p4merge file1 file2
rm file1 file2


Thank you, this is a good utility. p4merge gets the job done but this is not very efficient since I want to run it on ton of perforce files. Running additional p4 commands, converting to local files and them removing will increase the run time of my tool. Is there any other way I can get the job done with only one p4 command?

#5 Sambwise

Sambwise

    Advanced Member

  • Members
  • PipPipPip
  • 917 posts

Posted 06 March 2019 - 05:49 PM

Are the P4Merge dialogs meant for human (i.e. interactive) use?  If so the runtime of "p4 print" should be completely negligible compared to the time it'll take the user to read the diffs.  :)  This is the same exact thing that P4V does "behind the scenes" so if you're trying to emulate that behavior this is what you want to do.

If you're trying to do something more programmatic, like just determine which files from amongst a huge set differ, or get a diff line count, the "p4 diff2" command is much faster since it does the diff server-side (and you can do a large set of files in one shot).

#6 bhuvan

bhuvan

    Newbie

  • Members
  • Pip
  • 5 posts

Posted 06 March 2019 - 09:06 PM

I do want it to be interactive and I see your point. I tested it in our slowest server and it takes about 3 sec to do p4 print and p4merge compared to <1 sec with direct p4merge. It's not bad. Is there a way we can use just one p4 print command to write each file to respective output file? I want it to be fast :) Thanks for your response!

#7 Sambwise

Sambwise

    Advanced Member

  • Members
  • PipPipPip
  • 917 posts

Posted 06 March 2019 - 09:46 PM

If you're using one of the client APIs, you can get a boost in performance by opening a single connection and running both commands on it (you'll save at least a tenth of a second or so by not having to negotiate the connection twice).  If it takes 3 seconds to run those print commands, though, the bottleneck is probably some combination of the network bandwidth and the local disk's write speed, and you're not going to be able to optimize that away very easily.

#8 bhuvan

bhuvan

    Newbie

  • Members
  • Pip
  • 5 posts

Posted 06 March 2019 - 10:11 PM

Yes the network bandwidth is the problem which is why I want to use as less p4 commands as possible. I'm not using any APIs currently.

#9 Sambwise

Sambwise

    Advanced Member

  • Members
  • PipPipPip
  • 917 posts

Posted 06 March 2019 - 10:39 PM

Being as bandwidth is the problem, the number of commands you run isn't an issue so much as the quantity of data you need -- if you need to locally diff 10MB worth of text and it takes 3 seconds to transfer 10MB across the network, that's the lower bound on your runtime.  :)  (The "p4 diff2" command is way faster because the diff is done remotely and only the diffs are sent over!  But then you don't get the local diff tool's graphic output.)

But like I said earlier, the amount of time the user spends looking at all that text will be much greater; you could write your tool to fetch the rest of the files in the background while the user is looking at the diff for the first two...

#10 bhuvan

bhuvan

    Newbie

  • Members
  • Pip
  • 5 posts

Posted 07 March 2019 - 02:27 PM

Thank you for your inputs :)





Also tagged with one or more of these keywords: p4vc, p4v, diff

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users