Domanda

i need to build some treeview pretty much similar to the one in P4V, where pending changelists are listed;

I could add the pending changelists to the treeview, and could add child nodes if i use GetFileName(), however i want the file's LocalPath, and if i try it, i get "Object reference not set to an instance of object".

IList<Changelist> lista;
Options opcoes = new Options(ChangesCmdFlags.FullDescription, con.Cliente.Name, 100,     ChangeListStatus.Pending, con.Usuario);

lista = new List<Changelist>();
lista = con.Repositorio.GetChangelists(opcoes);

for (int i = 0; i < lista.Count; i++ )
{
   Changelist change = new Changelist();
   TreeNode node = new TreeNode();

   change = lista[i];
   change.initialize(con.conexao);

   node = tre.Nodes.Add(change.Id.ToString());
   FileSpec arquivoSpec = new FileSpec(new LocalPath(PathSpec.UnescapePath("")), Revision.Have);



   for (int arquivoAtual = 0; arquivoAtual < change.Files.Count; arquivoAtual++)
   {
       node.Nodes.Add(change.Files[arquivoAtual].LocalPath.Path);
   }

}

Any help will be appreciated.

È stato utile?

Soluzione

You'll want to use Repository.GetFileMetaData() with 'byChangelist' of GetFileMetaDataOptions() set to the pending change and with the 'GetFileMetaDataCmdFlag' set to 'Opened' and 'LocalPath'. Here's a link to the relevant docs:

http://www.perforce.com/perforce/doc.current/manuals/p4api.net/p4api.net_reference/html/M_Perforce_P4_Repository_GetFileMetaData_1.htm

http://www.perforce.com/perforce/doc.current/manuals/p4api.net/p4api.net_reference/html/M_Perforce_P4_GetFileMetaDataCmdOptions__ctor.htm

I suspect the method you are calling calls 'p4 describe' which does not get the local path. GetFileMetaData() calls 'p4 fstat' which does.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top