use of git4idea.util.StringScanner in project intellij-community by JetBrains.
the class GitOldChangesCollector method parseFiles.
private void parseFiles(String list) throws VcsException {
for (StringScanner sc = new StringScanner(list); sc.hasMoreData(); ) {
if (sc.isEol()) {
sc.nextLine();
continue;
}
char status = sc.peek();
sc.skipChars(2);
if ('?' == status) {
VirtualFile file = myVcsRoot.findFileByRelativePath(GitUtil.unescapePath(sc.line()));
if (Comparing.equal(GitUtil.gitRootOrNull(file), myVcsRoot)) {
myUnversioned.add(file);
}
} else {
//noinspection HardCodedStringLiteral
if ('M' == status) {
sc.boundedToken('\t');
String file = GitUtil.unescapePath(sc.line());
VirtualFile vFile = myVcsRoot.findFileByRelativePath(file);
if (!Comparing.equal(GitUtil.gitRootOrNull(vFile), myVcsRoot)) {
continue;
}
if (!myUnmergedNames.add(file)) {
continue;
}
// assume modify-modify conflict
ContentRevision before = GitContentRevision.createRevision(myVcsRoot, file, new GitRevisionNumber("orig_head"), myProject, false, true, true);
ContentRevision after = GitContentRevision.createRevision(myVcsRoot, file, null, myProject, false, false, true);
myChanges.add(new Change(before, after, FileStatus.MERGED_WITH_CONFLICTS));
} else {
throw new VcsException("Unsupported type of the merge conflict detected: " + status);
}
}
}
}
use of git4idea.util.StringScanner in project intellij-community by JetBrains.
the class GitTagDialog method fetchTags.
/**
* Fetch tags
*/
private void fetchTags() {
myExistingTags.clear();
GitSimpleHandler h = new GitSimpleHandler(myProject, getGitRoot(), GitCommand.TAG);
h.setSilent(true);
String output = GitHandlerUtil.doSynchronously(h, GitBundle.getString("tag.getting.existing.tags"), h.printableCommandLine());
for (StringScanner s = new StringScanner(output); s.hasMoreData(); ) {
String line = s.line();
if (line.length() == 0) {
continue;
}
myExistingTags.add(line);
}
}
use of git4idea.util.StringScanner in project intellij-community by JetBrains.
the class GitChangeUtils method getRevisionChanges.
/**
* Get list of changes. Because native Git non-linear revision tree structure is not
* supported by the current IDEA interfaces some simplifications are made in the case
* of the merge, so changes are reported as difference with the first revision
* listed on the the merge that has at least some changes.
*
*
*
* @param project the project file
* @param root the git root
* @param revisionName the name of revision (might be tag)
* @param skipDiffsForMerge
* @param local
* @param revertable
* @return change list for the respective revision
* @throws VcsException in case of problem with running git
*/
public static GitCommittedChangeList getRevisionChanges(Project project, VirtualFile root, String revisionName, boolean skipDiffsForMerge, boolean local, boolean revertable) throws VcsException {
GitSimpleHandler h = new GitSimpleHandler(project, root, GitCommand.SHOW);
h.setSilent(true);
h.addParameters("--name-status", "--first-parent", "--no-abbrev", "-M", "--pretty=format:" + COMMITTED_CHANGELIST_FORMAT, "--encoding=UTF-8", revisionName, "--");
String output = h.run();
StringScanner s = new StringScanner(output);
return parseChangeList(project, root, s, skipDiffsForMerge, h, local, revertable);
}
use of git4idea.util.StringScanner in project intellij-community by JetBrains.
the class GitChangeUtils method parseChanges.
/**
* Parse changes from lines
*
* @param project the context project
* @param vcsRoot the git root
* @param thisRevision the current revision
* @param parentRevision the parent revision for this change list
* @param s the lines to parse
* @param changes a list of changes to update
* @param ignoreNames a set of names ignored during collection of the changes
* @throws VcsException if the input format does not matches expected format
*/
public static void parseChanges(Project project, VirtualFile vcsRoot, @Nullable GitRevisionNumber thisRevision, GitRevisionNumber parentRevision, String s, Collection<Change> changes, final Set<String> ignoreNames) throws VcsException {
StringScanner sc = new StringScanner(s);
parseChanges(project, vcsRoot, thisRevision, parentRevision, sc, changes, ignoreNames);
if (sc.hasMoreData()) {
throw new IllegalStateException("Unknown file status: " + sc.line());
}
}
use of git4idea.util.StringScanner in project intellij-community by JetBrains.
the class GitUtil method getLocalCommittedChanges.
public static void getLocalCommittedChanges(final Project project, final VirtualFile root, final Consumer<GitSimpleHandler> parametersSpecifier, final Consumer<GitCommittedChangeList> consumer, boolean skipDiffsForMerge) throws VcsException {
GitSimpleHandler h = new GitSimpleHandler(project, root, GitCommand.LOG);
h.setSilent(true);
h.addParameters("--pretty=format:%x04%x01" + GitChangeUtils.COMMITTED_CHANGELIST_FORMAT, "--name-status");
parametersSpecifier.consume(h);
String output = h.run();
LOG.debug("getLocalCommittedChanges output: '" + output + "'");
StringScanner s = new StringScanner(output);
final StringBuilder sb = new StringBuilder();
boolean firstStep = true;
while (s.hasMoreData()) {
final String line = s.line();
final boolean lineIsAStart = line.startsWith("");
if ((!firstStep) && lineIsAStart) {
final StringScanner innerScanner = new StringScanner(sb.toString());
sb.setLength(0);
consumer.consume(GitChangeUtils.parseChangeList(project, root, innerScanner, skipDiffsForMerge, h, false, false));
}
sb.append(lineIsAStart ? line.substring(2) : line).append('\n');
firstStep = false;
}
if (sb.length() > 0) {
final StringScanner innerScanner = new StringScanner(sb.toString());
sb.setLength(0);
consumer.consume(GitChangeUtils.parseChangeList(project, root, innerScanner, skipDiffsForMerge, h, false, false));
}
if (s.hasMoreData()) {
throw new IllegalStateException("More input is avaialble: " + s.line());
}
}
Aggregations