use of org.zmlx.hg4idea.HgRevisionNumber in project intellij-community by JetBrains.
the class HgAnnotateCommand method parse.
private static List<HgAnnotationLine> parse(List<String> outputLines) {
List<HgAnnotationLine> annotations = new ArrayList<>(outputLines.size());
for (String line : outputLines) {
Matcher matcher = LINE_PATTERN.matcher(line);
if (matcher.matches()) {
String user = matcher.group(USER_GROUP).trim();
HgRevisionNumber rev = HgRevisionNumber.getInstance(matcher.group(REVISION_GROUP), matcher.group(CHANGESET_GROUP));
String dateGroup = matcher.group(DATE_GROUP).trim();
SimpleDateFormat dateFormat = new SimpleDateFormat("EEE MMM dd HH:mm:ss yyyy", Locale.US);
String date = "";
try {
date = DateFormatUtil.formatPrettyDate(dateFormat.parse(dateGroup));
} catch (ParseException e) {
LOG.error("Couldn't parse annotation date ", e);
}
Integer lineNumber = Integer.valueOf(matcher.group(LINE_NUMBER_GROUP));
String content = matcher.group(CONTENT_GROUP);
HgAnnotationLine annotationLine = new HgAnnotationLine(user, rev, date, lineNumber, content);
annotations.add(annotationLine);
}
}
return annotations;
}
use of org.zmlx.hg4idea.HgRevisionNumber in project intellij-community by JetBrains.
the class HgChangesetsCommand method getRevisions.
protected List<HgRevisionNumber> getRevisions(VirtualFile repo) {
List<String> args = new ArrayList<>(Arrays.asList("--template", HgChangesetUtil.makeTemplate("{rev}", "{node}", "{author}", "{desc|firstline}"), "--quiet"));
addArguments(args);
HgCommandResult result = executeCommandInCurrentThread(repo, args);
if (result == null) {
return Collections.emptyList();
}
String output = result.getRawOutput();
if (StringUtil.isEmpty(output)) {
return Collections.emptyList();
}
String[] changesets = output.split(HgChangesetUtil.CHANGESET_SEPARATOR);
List<HgRevisionNumber> revisions = new ArrayList<>(changesets.length);
for (String changeset : changesets) {
List<String> parts = StringUtil.split(changeset, HgChangesetUtil.ITEM_SEPARATOR);
if (parts.size() >= 3) {
//support zero commit message
revisions.add(HgRevisionNumber.getInstance(parts.get(0), parts.get(1), parts.get(2), parts.size() > 3 ? parts.get(3) : ""));
} else {
LOG.warn("Could not parse changeset [" + changeset + "]");
}
}
return revisions;
}
use of org.zmlx.hg4idea.HgRevisionNumber in project intellij-community by JetBrains.
the class HgRollbackEnvironment method revert.
private void revert(@NotNull List<FilePath> filePaths) {
for (Map.Entry<VirtualFile, Collection<FilePath>> entry : HgUtil.groupFilePathsByHgRoots(project, filePaths).entrySet()) {
final VirtualFile repo = entry.getKey();
final Collection<FilePath> files = entry.getValue();
HgRevisionNumber revisionNumber = new HgWorkingCopyRevisionsCommand(project).firstParent(repo);
for (List<String> chunk : VcsFileUtil.chunkPaths(repo, files)) {
HgCommandResult revertResult = new HgRevertCommand(project).execute(repo, chunk, revisionNumber, false);
if (HgErrorUtil.hasUncommittedChangesConflict(revertResult)) {
String message = String.format("<html>Revert failed due to uncommitted merge.<br>" + "Would you like to discard all changes for repository <it><b>%s</b></it>?</html>", repo.getPresentableName());
int exitCode = HgUpdateCommand.showDiscardChangesConfirmation(project, message);
if (exitCode == Messages.OK) {
//discard all changes for this repository//
HgUpdateCommand updateCommand = new HgUpdateCommand(project, repo);
updateCommand.setClean(true);
updateCommand.setRevision(".");
updateCommand.execute();
}
break;
}
new HgResolveCommand(project).markResolved(repo, files);
}
}
}
use of org.zmlx.hg4idea.HgRevisionNumber in project intellij-community by JetBrains.
the class HgDiffProvider method createFileContent.
public ContentRevision createFileContent(VcsRevisionNumber revisionNumber, VirtualFile file) {
if (file == null) {
return null;
}
VirtualFile vcsRoot = VcsUtil.getVcsRootFor(project, file);
if (vcsRoot == null) {
return null;
}
HgRevisionNumber hgRevisionNumber = (HgRevisionNumber) revisionNumber;
if (hgRevisionNumber.isWorkingVersion()) {
throw new IllegalStateException("Should not compare against working copy");
}
HgFile hgFile = new HgFile(vcsRoot, HgUtil.getOriginalFileName(VcsUtil.getFilePath(file), ChangeListManager.getInstance(project)));
return HgContentRevision.create(project, hgFile, hgRevisionNumber);
}
use of org.zmlx.hg4idea.HgRevisionNumber in project intellij-community by JetBrains.
the class HgDiffProvider method getLastRevision.
public ItemLatestState getLastRevision(FilePath filePath) {
VirtualFile vcsRoot = VcsUtil.getVcsRootFor(project, filePath);
if (vcsRoot == null) {
return null;
}
HgWorkingCopyRevisionsCommand command = new HgWorkingCopyRevisionsCommand(project);
HgRevisionNumber currentRevision = command.identify(vcsRoot).getFirst();
if (currentRevision == null) {
return null;
}
boolean fileExists = filePath.getIOFile().exists();
if (currentRevision.isWorkingVersion()) {
return new ItemLatestState(command.firstParent(vcsRoot), fileExists, true);
}
return new ItemLatestState(currentRevision, fileExists, true);
}
Aggregations