ServerHelperApi::CloneFromRemote(int,const StrPtr*,ClientUser*,Error*)

Populates a personal server based on a remote specification.

Virtual?

No

 

Class

ServerHelperApi

 

Arguments

int depth

specifies the number of revisions to fetch of each file

 

const StrPtr *df

optional debug flag; set to 0 to leave it unset

 

ClientUser *ui

a pointer to ClientUser object

 

Error *e

a pointer to an Error object

Returns

int

indicates success of command

Notes

This method stores the remote generated by either PrepareToCloneFilepath() or PrepareToCloneRemote() as origin and then runs p4 fetch to populate the local server. This method should be run against the instance of ServerHelperApi class configured as the personal server.

A return value of 1 indicates a successful clone. If the method returns 0, check the Error object to see what occurred.

See also

ServerHelperApi::PrepareToCloneFilepath()ServerHelperApi::PrepareToCloneRemote()

Example

// Basic "p4 clone" flow:
ClientUser ui;
Error e;
ServerHelperApi personalServer( &e );

if( e.Test() )
    return 0;

personalServer.SetDvcsDir( "/path/to/root", &e );
personalServer.SetProg( "MyApp" ); // optional
personalServer.SetVersion( "version" ); // optional

if( personalServer.Exists() )
    return 0;

ServerHelperApi sharedServer( &e );
sharedServer.SetPort( "1666" );
sharedServer.SetProg( "MyApp" ); // optional
sharedServer.SetVersion( "version" ); // optional

// Fetch the remote spec
if( !personalServer.PrepareToCloneRemote( &sharedServer, remote, &ui ) )
   return 0;

// Create the personal server
// This returns the exit code from p4d, so 0 is success
if( personalServer.InitLocalServer( &ui ) )
    return 0;

// Fetch from the remote
if( !personalServer.CloneFromRemote( 0, 0, &ui ) )
    return 0;