Jump to content


p4java - copy file without changelist

p4java copyfile changelist

  • Please log in to reply
4 replies to this topic

#1 karidrgn

karidrgn

    Newbie

  • Members
  • Pip
  • 9 posts

Posted 29 August 2013 - 04:19 PM

I want to copy a file without creating a change list. How do I do this? I've looked at copyfile(s) but can't quite see how to implement them. My basic process is: find zip file in depot, copy it to local or to my resources dir, extract a file from the zip, change it, rename it and then perhaps check it in in my resources dir without touching the original. Since, my resource dir may already have a file of the same name, I'm guessing that I should check that out 1st and then overwite it with my changed file.

I would appreciate it if you could point me to any code snippets that would be useful.

#2 P4Matt

P4Matt

    Advanced Member

  • Members
  • PipPipPip
  • 1383 posts

Posted 29 August 2013 - 04:33 PM

Let's work out the process in command line syntax; it's pretty easy to translate once we have the right series of Perforce commands.

It sounds like you want to:

1) run 'p4 print' to get a copy of the file  (p4 print let's you dump the contents of any Perforce file to a file or stdout
2) unzip, modify the file
3) potentially p4 ddd/add the file and p4 submit it

Is that about right?

#3 karidrgn

karidrgn

    Newbie

  • Members
  • Pip
  • 9 posts

Posted 30 August 2013 - 09:55 PM

hmm. I guess the p4 copy only copies files within perforce? But the p4 print gets me the file without extra steps.
so, what;s the corresponding methods that do the p4 print?

Furthermore, do you know if it work on getting a specific jar file out of the zip file without me having to copy the entire zip?
If that's too tricky, I've got the code for unzipping the file, and I have an example that I can use of checking out a file and creating a new version of it and resubmitting it. So, i think i'm good on steps 2 & 3.

#4 P4Matt

P4Matt

    Advanced Member

  • Members
  • PipPipPip
  • 1383 posts

Posted 30 August 2013 - 11:12 PM

Exactly. P4 copy is a version of 'p4 integrate' that says "make the target look like the source no matter what". The method you are looking for is "getFileContents()"

http://www.perforce....ContentsOptions)

You'll have to 'p4 print' the entire zip file and then pull out the jar you want locally.

#5 karidrgn

karidrgn

    Newbie

  • Members
  • Pip
  • 9 posts

Posted 09 September 2013 - 04:45 PM

thanks so much





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users