Jump to content


p4 revert files not working with -a option using p4api.net method

p4api.net p4v

  • Please log in to reply
1 reply to this topic

#1 PerfQuery

PerfQuery

    Newbie

  • Members
  • Pip
  • 4 posts

Posted 15 March 2015 - 03:39 AM


Trying to revert files in a changelist using -a option in p4api.net method. It used to work for me but now am getting exception with below message.

Also p4 edit and p4 revert with -c option works fine but p4 revert with -a option throws below exception. I don't know why its picking below test project location in p4 workspace location.

Exception:

Path 'd:\cftt\Dev\source\BRF\BRF.Business.Test\bin\Debug\19402547' is not under client's root 'D:\p4'.

Please help as i am blocked because of this issue.

// to open files for edit in a given changelist at certain loc with particular file format
          public IList<FileSpec> EditChangeList(string clNumber, string fileFormat, string destinationPath)
    {
        try
        {
            var rep = Connect();
            var opts = new Options(ChangeCmdFlags.None, ChangeListType.None);
            opts["-c"] = clNumber;
            var fs = new FileSpec(new DepotPath(destinationPath + "/..." + fileFormat));
            IList<FileSpec> editedFileSpec = rep.Connection.Client.EditFiles(new List<FileSpec> {fs}, opts);
            return editedFileSpec;
        }
        catch (Exception exc)
        {
            Logger.LogError(exc.Message);
            throw;
        }
    }

    // to revert files in a changelist that are unchanged using -a option
           public IList<FileSpec> RevertChangeList(string clNumber, string destinationPath)
    {
        try
        {
            var rep = Connect();
            var opts = new Options(ChangeCmdFlags.None, ChangeListType.None);
            opts["-a"] = clNumber;
            var fs = new FileSpec(new DepotPath(destinationPath + "/..."));
            IList<FileSpec> revertedFiles = rep.Connection.Client.RevertFiles(new List<FileSpec> {fs}, opts);
            return revertedFiles;
        }
        catch (Exception exc)
        {
            Logger.LogError(exc.Message);
            throw;
        }

#2 P4Matt

P4Matt

    Advanced Member

  • Members
  • PipPipPip
  • 1383 posts

Posted 16 March 2015 - 05:35 AM

Code looks good; based on your error message the problem is the file you are trying to revert is not under the workspace root.

Quote

Path 'd:\cftt\Dev\source\BRF\BRF.Business.Test\bin\Debug\19402547' is not under client's root 'D:\p4'.

All of the files this tool is operating on need to be under the directory D:\p4. Try it on a file under that p4 directory and let me know how it goes.





Also tagged with one or more of these keywords: p4api.net, p4v

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users