Jump to content


P4java - unshelve files to the same changelist fail

p4java unshelve

  • Please log in to reply
6 replies to this topic

#1 eranb

eranb

    Advanced Member

  • Members
  • PipPipPip
  • 55 posts

Posted 15 March 2015 - 11:38 AM

When the source changelist and the destination changelist are the same, I cannot unshelve files.

This is the command I run:
List<IFileSpec> fileList = client.unshelveChangelist(sourceChangelist.getId(), new ArrayList<IFileSpec>(), destinationchangelist.getId(), false, false);

All objects are valid (when the source and the destination are different it's OK).

What I get as returned value is array with one IFileSpec.
opStatus = "ERROR".
StatusMessage = Client 'noclient' unknown - use 'client' command to create it.

Any idea what is wrong?

Thanks

#2 P4Matt

P4Matt

    Advanced Member

  • Members
  • PipPipPip
  • 1383 posts

Posted 16 March 2015 - 05:27 AM

Looks like the client object hasn't been initialized with the client name you want to use. 'noclient' is the default value.  I suspect there are a lot of 'noclient' clients in the world. =)

Checkout the highlighted line of code in this example. I think it's what you want.

https://swarm.worksh...geDemo.java#L46

#3 eranb

eranb

    Advanced Member

  • Members
  • PipPipPip
  • 55 posts

Posted 16 March 2015 - 05:53 AM

I debugged the script, the Client's data is correct (name, owner, description, root...)
I get the same error with client.submitsShelvedChangelist()

The only thing I noticed is that the client has a server variable which is null. even if I call setServer(), it remains null.

#4 P4Matt

P4Matt

    Advanced Member

  • Members
  • PipPipPip
  • 1383 posts

Posted 16 March 2015 - 06:01 AM

That's definitely suspicious. Can you post the code? I'd be happy to try to run it, or slap it in one of my Java test apps.

#5 eranb

eranb

    Advanced Member

  • Members
  • PipPipPip
  • 55 posts

Posted 16 March 2015 - 07:50 AM

This is the minimal flow to reproduce the issue I have:
  try
  {
   IOptionsServer server = ServerFactory.getOptionsServer( fullServerAddr, null);
   server.addTrust(new TrustOptions().setAutoAccept(true));
   server.connect();
   server.setUserName(userName);
   server.login(pass);
   IChangelist changelist = server.getChangelist(newChangelistInt);
   IClient client = server.getClient(changelist.getClientId());
   List<IFileSpec> fileList = client.unshelveChangelist(newChangelistInt, null, newChangelistInt, false, false);
   System.out.println("Op Status = " + fileList.get(0).getOpStatus());
   System.out.println("Status Message = " + fileList.get(0).getStatusMessage());
   changelist = server.getChangelist(newChangelistInt);
   server.logout();
  }
  catch (Exception e){
   System.out.println(e.getMessage());
  }

The changelist I use has 6 shelved files. no checked out files at all.
Notice that the changelist and the client exist and valid. with debugging I can see that the objects are not empty / get the default values.
Unshelve using P4V works fine.

Thanks

#6 eranb

eranb

    Advanced Member

  • Members
  • PipPipPip
  • 55 posts

Posted 16 March 2015 - 09:03 AM

Found the issue.

Forgot to call server.setCurrentClient()
Still, since I call unshelve from the client I would expect it to work...

Thanks

#7 P4Matt

P4Matt

    Advanced Member

  • Members
  • PipPipPip
  • 1383 posts

Posted 16 March 2015 - 08:50 PM

The P4Java API is.... pedantic is probably the best word. The good news is it doesn't assume anything. The bad news is it doesn't assume anything. Glad you got it sorted out!





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

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users