How to find unresolved files using the Perforce p4java library? - java

Using the p4java library from Perforce (http://kb.perforce.com/article/1086/p4java-api), I'm trying to find out what files in a changelist are unresolved and need to be resolved before I can submit them.
IChangelist changelist = getServer().getChangelist(changelistId);
List<IFileSpec> changelistPendingFiles = changelist.getFiles(false);
In this List, I'm trying to figure out which IFileSpec still need to be resolved.
Something like this:
for (IFileSpec pendingFile : changelistPendingFiles) {
// How to find out if pendingFile needs to be resolved?
FileAction action = pendingFile.getAction();
// The above results in "FileAction.EDIT",
// but that doesn't tell me anything about the unresolved state
// The "diffStatus" variable for this pendingFile is "pending"
// The "howResolved" variable for this pendingFile is null
// The "opStatus" variable for this pendingFile is VALID
}
Thanks for anything you can provide!

The comprehensive way is to run P4Java's version of the fstat command, and check if the file needs resolving. Here's a code sample (not guaranteed to be bulletproof) that works in a simple test case.
List<IExtendedFileSpec> extfiles = server.getExtendedFiles(changelistPendingFiles,
-1,
-1,
-1,
new FileStatOutputOptions(false, false, false, false, false, true),
null);
for(IExtendedFileSpec extfile : extfiles) {
System.out.println(extfile.isUnresolved());
}
In the FileStatOutputOptions, I'm asking for information on files that are open and need resolving. The isUnresolved method should tell you what you want.
Hope that helps!

Related

not enough java heap space' r programming

I am out of my R depth. I defined a function nGrams (using RWeka) that worked fine when I tried it out, and sometimes it still does. I do not know how to figure out what environment it works in, what environment I am in when I want to use it, etc. Any quick tips or can you point me to a webpage that could help? If I have to put in a change environment command every time I use it, that is just fine. I really do not understand the issue.
here is what I see in my console.
blog2gramfreq <- nGrams(cleanblogs100000, 2)
Error in ls(envir = envir, all.names = private) :
invalid 'envir' argument
Called from: top level
Called from: top level
Browse[1]>
structure(function (this, private = FALSE, ...)
{
envir <- attr(this, ".env")
ls(envir = envir, all.names = private)
}, export = FALSE, S3class = "Object", modifiers = "public")
I do see nGrams in my Global Environment window.
This was something that came up in a Coursera class blog that i did not find an answer to, at least for R. Here is an answer that worked for me when I received the "'OutOfMemoryError : not enough java heap space" error in R programming.
options(java.parameters="-Xmx4000m")

JavaImp plugin not able to parse Java files

I have been using the JavaImp.vim script for auto importing Java statements in VIM
But trying out different directories in the JavaImpPaths, I am still unable to make JavaImp parse the Java files in the source to make auto imports possible
this is how my .vimrc looks like
let g:JavaImpPaths = "~/Documents/android-sdks/sources/android-21/android/content/"
let g:JavaImpClassList = "~/.vim/JavaImp/JavaImp.txt"
let g:JavaImpJarCache = "~/.vim/JavaImp/cache/"
This is what I get running JIG in new Vim window
:JIG
Do you want to create the directory ~/.vim/JavaImp/cache/?
Searching in path (package): ~/Documents/android-sdks/sources/android-21/android
/content/ ()
Sorting the classes, this may take a while ...
Assuring uniqueness...
Error detected while processing function <SNR>10_JavaImpGenerate:
line 75:
E37: No write since last change (add ! to override)
Done. Found 1 classes (0 unique)
Press ENTER or type command to continue
It might be late, but if anyone else comes along this might help them...
I got it working with the following changes to the script:
line 181 from
close
to
close!
And lines 207/208 from
let l:javaList = glob(a:cpath . "/**/*.java", 1, 1)
let l:clssList = glob(a:cpath . "/**/*.class", 1, 1)
to
let l:javaList = split(glob(a:cpath . "/**/*.java"), "\n")
let l:clssList = split(glob(a:cpath . "/**/*.class"), "\n")

Get the type of a FieldDeclaration in AST

I am working with a Java AST. How can I get the Type (e.g. String or MyOwnType) of a FieldDeclaration or VariableDeclaration? In ASTView I can see it under SimpleName > type binding, but with getters I cannot reach the member.
I tried the solution from FieldDeclaration to IField - Getting IBinding from FieldDeclaration but resolveBinding returns null when visiting the FieldDeclaration.
Why does resolveBinding() return null even though I setResolveBindings(true) on my ASTParser? not working either
Wow, this was tough.
The last line made it possible to resolve the bindings and retrieve the type via varDeclFrag.resolveBinding().getType().getQualifiedName(); although I already thought I did the same in setEnvironment when referring to sources:
String[] sources = { "C:\\a\\TheMightyExampleProject\\src" };
String[] classPaths = { "C:\\a\\antlr-4.1-complete.jar" };
parser.setEnvironment(classPaths, sources, new String[] { "UTF-8" }, true);
parser.setBindingsRecovery(true);
parser.setResolveBindings(true);
parser.setCompilerOptions(options);
parser.setStatementsRecovery(true);
parser.setUnitName("C:\\a\\TheMightyExampleProject\\src"); // ftw
You can also check out the answer of Ida bindings not resolving with AST processing in eclipse

Why can't I call UIComponent.setValueExpression()?

I have received a project with many lines like the following ones:
HtmlOutputText content = new HtmlOutputText();
ValueBinding vb = dashBoardBean.getApplication()
.createValueBinding(columnas[cont][1]);
content.setValueBinding("value", vb);
Eclipse, with Java 5, marks them as deprecated (both class ValueBindingand the method setValueBinding).
So I looked the API for HtmlCommandLink.setValueBinding() (it actually is at UIComponentBase) and found this:
Deprecated. This has been replaced by UIComponent.setValueExpression(java.lang.String, javax.el.ValueExpression).
So I changed the last line code to the following:
content.setValueExpression("value", null);
But now I get a compiler error.
I also tried:
UIComponent uic;
uic.setValueExpression("", null);
And get the same error:
The type javax.el.ValueExpression cannot be resolved. It is indirectly referenced from
required .class files
What's the meaning of that error? How can I solve it?
You need the JSF 1.2 (or greater) jars on your classpath.

Get history of a Deleted File from SVN using SVNKit

I am trying to access Revision History of a file that has been deleted using SVNKit.
Following is what I am doing to achieve that.
SVNClientManager manager = SVNClientManager.newInstance();
SVNLogClient logClient = manager.getLogClient();
logClient.doLog(svnURL, new String[] { fileName }, SVNRevision.create(deletedRevision),
SVNRevision.UNDEFINED, SVNRevision.UNDEFINED, false, false, true, -1, null,
new ISVNLogEntryHandler() {
public void handleLogEntry(SVNLogEntry logEntry) throws SVNException {
log.debug(" ==== " + logEntry.getChangedPaths() + " === "
+ logEntry.getRevision());
}
});
Here, deletedRevision => The SVN revision in which File was deleted.
When this code is executed I keep on getting following exceptions:
org.tmatesoft.svn.core.SVNException: svn: '<FilePath>' path not found: 404 Not Found (https://<RepositoryURL>
at org.tmatesoft.svn.core.internal.wc.SVNErrorManager.error(SVNErrorManager.java:64)
at org.tmatesoft.svn.core.internal.wc.SVNErrorManager.error(SVNErrorManager.java:51)
at org.tmatesoft.svn.core.internal.io.dav.DAVRepository.logImpl(DAVRepository.java:976)
at org.tmatesoft.svn.core.io.SVNRepository.log(SVNRepository.java:1034)
at org.tmatesoft.svn.core.wc.SVNLogClient.doLog(SVNLogClient.java:1024)
at org.tmatesoft.svn.core.wc.SVNLogClient.doLog(SVNLogClient.java:891)
at com.blueoptima.connectors.scr.SVN.getWorkingFileList(SVN.java:711)
... 4 more
Is it something that I am doing wrong here? Is there any other way to get the History of a deleted file using SVNKit
Though this question has been asked more than a year back but still thought of answering it if it could be other's help.
I didnt try for retrieving history of a deleted file but i could retrieve the history of a deleted branch using -
SVNLogClient.doLog(SVNURL.parseURIEncoded(path), new String[] { "" }, pegRevision, SVNRevision.create(0),pegRevision, stopOnCopy, discoverChangedPaths, logsLimit, logHandler);
This is similar to the call you are making but you need to supply proper values for pegRevision, startRevision and endRevision. Use of UNDEFINED may not give correct result, instead use the revision at which file was deleted as pegRevision and startRevision as 0 and it should work.
You should specify a revision where the file existed as a peg revision. Obviously it is deletedRevision-1. And maybe (I'm not sure here, just try) the file should exist in both start and end revisions.

Categories

Resources