这是我从 perforce 获取文件(步骤 1)并在 perforce 中签入文件的代码(步骤 2)
我能够成功获取文件。但是当将文件签入回仓库时,我收到一条消息: 没有要提交的文件。
有人可以帮我找到我在这里可能缺少的东西吗?
String serverUri = "p4java://my-perforce:1666";
IServer server;
try {
//getting server
server = ServerFactory.getServer(serverUri, null);
//connecting to server
server.connect();
server.setUserName("username");
server.login("password");
//Step 1 -- GETTING FILE FROM PERFORCE.
//getting client (local workspace name)
IClient client = server.getClient("myPerforce");
//setting it as current workspace
server.setCurrentClient(client);
//getting the file from perforce depot
List<IFileSpec> fileList = server.getDepotFiles(FileSpecBuilder.makeFileSpecList("//myLocalWorkspaceLocation/up.json"), false);
//sync workspace with perforce depot
client.sync(fileList, null);
//STEP 2 -- CHECKING IN FILE IN PERFORCE
//creating a changelist
Changelist changeListImpl = new Changelist(
IChangelist.UNKNOWN,
client.getName(),
"username",
ChangelistStatus.NEW,
new Date(),
"Testing checking in file from JAVA",
false,
(Server) server);
IChangelist changelist = client.createChangelist(changeListImpl);
//Edit file options
EditFilesOptions editFilesOptions = new EditFilesOptions().setChangelistId(changelist.getId());
List<IFileSpec> editList = client.editFiles(FileSpecBuilder.makeFileSpecList("//myLocalWorkspaceLocation/up.json"), editFilesOptions);
//updating the changelist and submitting the changes.
changelist.update();
List<IFileSpec> submitFiles = changelist.submit(false);
//disconnecting
server.disconnect();
} catch (Exception e) {
System.out.println("ERROR!!!>> " + e.getMessage());
}