使用p4v java

时间:2016-02-26 22:20:35

标签: java perforce p4v perforce-client-spec

这是我从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());
    }

0 个答案:

没有答案