Jump to content


P4Java - Get shelved file content

p4java

  • Please log in to reply
5 replies to this topic

#1 eranb

eranb

    Advanced Member

  • Members
  • PipPipPip
  • 55 posts

Posted 23 March 2015 - 10:33 AM

Hi
I'm looking for a way to get the content of a shelved file.
I have the changelist ID.

What is the best way to make sure I get the shelved content and not the one on the server.

Thanks

#2 P4Shimada

P4Shimada

    Advanced Member

  • Members
  • PipPipPip
  • 831 posts

Posted 25 March 2015 - 12:32 AM

Hi Eran,

The command to use is:  p4 print //depot/shelved/file@=<shelvedchangelistnumber>

For example:

$ p4 changes -s shelved -u admin
Change 12152 on 2015/03/24 by admin@admin2014.1 *pending* 'Make an edit to test with shelv'

$ p4 print //depot/test/foo@=12152
//depot/test/foo#5 - edit change 12152 (text)
text
newline
shelvethisedit


#3 eranb

eranb

    Advanced Member

  • Members
  • PipPipPip
  • 55 posts

Posted 25 March 2015 - 08:25 AM

Thanks for the reply but as mentioned in the title, I'm using Java API...

Is there support for this action in P4Java (couldn't find it in the docs)?

Thanks

#4 P4Shimada

P4Shimada

    Advanced Member

  • Members
  • PipPipPip
  • 831 posts

Posted 25 March 2015 - 06:02 PM

I will double check to see if the 'p4 print' command is supported with P4Java.

REFERENCES

- Get Shelved Files with P4Java
http://answers.perfo...rticles/KB/8281

#5 Tubah

Tubah

    Advanced Member

  • Staff
  • 45 posts

Posted 25 March 2015 - 08:03 PM

Note the "@=shelvedChange" revision specifier in the filespec:

final List<IFileSpec> checkSpecList = FileSpecBuilder.makeFileSpecList(
"//depot/tst/src/README@=10");


final GetFileContentsOptions gfco = new GetFileContentsOptions();
gfco.setNoHeaderLine(true);
gfco.setDontAnnotateFiles(false); // must set this!


InputStream inStream = server.getFileContents(checkSpecList, gfco);

Then read your file from the inStream and close() it.

#6 eranb

eranb

    Advanced Member

  • Members
  • PipPipPip
  • 55 posts

Posted 26 March 2015 - 09:03 AM

Super!
Thanks.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users