Jump to content

P4Java - set file mapping

mapping p4java

  • Please log in to reply
6 replies to this topic

#1 eranb


    Advanced Member

  • Members
  • PipPipPip
  • 55 posts

Posted 17 July 2014 - 02:52 PM

I want to submit files from a shelved changelist using a different user.
I use P4Java for the task.

Since this "Submit script" can run on many different platforms (run with Jenkins),
I want to create a new client, create a new changelist, copy the changes to the new changelist and submit them.

The problems I facing is that the view mapping is incorrect and therefor, unshelving the files from the original changelist to the new one fail.

I couldn't solve it by myself (I am using P4Java documentation but still, couldn't find solution) so I'm asking for your help with that...

is there a way to submit the files without having to un-shelve them (copy the shelved files to the new changelist and keep them shelved, this way , maybe, I don't need to actually create a workspace view...

Is there a better way you can think of to implement what I descried?

Thanks in advance.

#2 P4Shimada


    Advanced Member

  • Members
  • PipPipPip
  • 831 posts

Posted 18 July 2014 - 12:04 AM

Hi Eran,

Are you trying to submit previously shelved files from one client to another? And what type of issue are you having with the view mapping - can you send an example or error message you received when it fails?

#3 eranb


    Advanced Member

  • Members
  • PipPipPip
  • 55 posts

Posted 20 July 2014 - 06:28 AM

It's about not having the files I want to un-shelve in my workspace view.

e.g. //depot/.../tmp/test3.txt - file(s) not in client view.

The problem is that I can't understand how to map files into my workspace using P4Java.
I don't want to get the files from the user. I want to take it from the original changelist.

If I can copy the mapping from one changelist to another it will be great.
If I can un-shelve and submit the files without map any file, it will be even better. I prefer not to copy files into my workspace at all.


#4 eranb


    Advanced Member

  • Members
  • PipPipPip
  • 55 posts

Posted 21 July 2014 - 08:31 AM

Never Mind.
I manged to get it to work somehow...

Just one comment,
I think that Client.unshelveChangelist() and Client.unshelveFiles() are not working correctly...
I passed source changelist and destination changelist but for some reason, the files were unshelved to the default changelist.
Doing the same using the CLI interface worked as expected.

Please check and let me know if you see the same (+open a bug if needed).


#5 P4Shimada


    Advanced Member

  • Members
  • PipPipPip
  • 831 posts

Posted 22 July 2014 - 06:13 PM

Hi Eran,

Thanks for the update.

Do you have an exact reproduction code example that you can copy and paste regarding the suspected bug? Also please send us the version of P4Java you are using, found in the name of the p4java jar file (e.g. p4java-2010.1.269249.jar).

We will need these details to file a bug.

#6 eranb


    Advanced Member

  • Members
  • PipPipPip
  • 55 posts

Posted 23 July 2014 - 08:07 AM

I'm using p4java-2013.2.788582.jar

Sorry but I cannot write the exact code.
This is the calls I tried:

List<IFileSpec> flist = newClient.unshelveFiles(null, originalChangelist.getId(), newChangelist.getId(), null);
List<IFileSpec> flist = newClient.unshelveChangelist(originalChangelist.getId(), null, newChangelist.getId(), false, false);

Instead of the calls above, I am currently using this call which works fine:
server.execInputStringStreamCmd("unshelve", new String[]{"-s", ""+originalChangelist.getId(), "-c", ""+newChangelist.getId()}, "");

I made sure that both changelists exist and valid.
When I called (from the command line) P4 unshelve -s #oldCL -c #newCL it worked fine.

#7 BeepBoopBleep



  • Members
  • Pip
  • 4 posts

Posted 29 October 2014 - 06:11 AM

I tried both above and I cannot get it to work. I am so effing sick not having any documentation or examples.

For example, I also validated the changelist too.

RetVal =  client.unshelveChangelist(iShelvedChangelist, ifs, iNewChangeList, true, false);

The return value was crap.

Then I used unshelveFiles( after calling the above function. I got something else interesting...

In my output:
PARAMS-> shelved changelist:18006116 new changelist: 18026007, forceOverwrite: true, previewonly: false

When I get the stat of it, perforce returns:
//depot/somefile/buildnum.txt#4 - unshelved, opened for edit

When I look into the new changelist: 18026007 I see the file int he changelist but the file was not unshelved with the "shelved" code. It contained the original.

I swear to god I want jto pull my hair out using this API


Also tagged with one or more of these keywords: mapping, p4java

1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users