nucm-logo

NUCM-2.0 Documentation
Interface: Collection: nc_copy


[Versioning | Collection | Query]

[nc_add | nc_remove | nc_rename | nc_replaceversion | nc_copy]

Signature

int  nc_copy(const char*  path,
             const char*  p_cwd,
	     const char*  prefix_target,
             const char*  t_cwd,
	     const t_server*  server)

Functionality

Copies the history of the artifact determined by the parameters path and p_cwd to the NUCM server determined by the parameter server, and then adds this newly created artifact to the collection determined by the path prefix_target and t_cwd. The new artifact is opened in the workspace. The collection has to be initiated.

Return Values

0: everything went ok
-1: an error occurred

NdbErrno Codes

NdbOk :everything went ok
NdbUnknown :the path does not represent a NUCM artifact
NdbNotOpen :the NUCM artifact has not been opened in the workspace
NdbLonely : no collection present in the workspace to which the artifact can be added
NdbNotInit: the collection to which to add the artifact is not initiated
NdbExist : a different artifact with the same name already exists in the workspace
NdbConnect :the server is down or not reachable
NdbComm :a communication error occurred
NdbProtocol:a failure occurred in the NUCM protocol
NdbNotAvail:service is not available

Example

Assuming a repository is filled with projects, and in particular contains a project "my_project" that contains the artifacts ".login" and ".cshrc". In addition, it contains an empty project "his_project". Furthermore, a workspace has been created earlier in which "my_project" and its artifacts, as well as "his_project", have been opened:
   /home/bigtime/andre/workspace/my_project/.login
					    .cshrc
				 his_project/
To populate "his_project" with ".login" and ".cshrc" as separate objects with a separate version history, the following code fragment can be used:
   #include "nc.h"

   t_server  server;
   
   strcpy(server.host, "anchor.cs.colorado.edu");
   sprintf(server.port, "%d", NUCM_PORT):
   nc_initiatechange("his_project",
		     "/home/bigtime/andre/workspace");
   nc_copy(".login",
	   "/home/bigtime/andre/workspace/my_project",
	   "/home/bigtime/andre/workspace/his_project",
	   "",
	   &server);
   nc_copy("//serl.cs.colorado.edu:1234/nucm_root/my_project/.cshrc",
           "",
	   "/home/bigtime/andre/workspace/his_project",
	   "",
	   &server);
   nc_commitchangeandreplace("his_project",
	                     "/home/bigtime/andre/workspace");
The workspace now looks as follows:
   /home/bigtime/andre/workspace/my_project/autoexec.bat
					    config.sys
It should be noted that ".login" and ".cshrc" did not need to have been opened to be renamed.

[Top | Quick Index] [Concepts | Interface]

SERL <serl.cs.colorado.edu>