use of org.zmlx.hg4idea.repo.HgRepository in project intellij-community by JetBrains.
the class HgActionFromMqPatches method actionPerformed.
@Override
public void actionPerformed(AnActionEvent e) {
final HgMqUnAppliedPatchesPanel patchInfo = e.getRequiredData(HgMqUnAppliedPatchesPanel.MQ_PATCHES);
final List<String> names = patchInfo.getSelectedPatchNames();
final HgRepository repository = patchInfo.getRepository();
Runnable task = new Runnable() {
@Override
public void run() {
ProgressManager.getInstance().getProgressIndicator().setText(getTitle());
executeInCurrentThread(repository, names);
}
};
patchInfo.updatePatchSeriesInBackground(task);
}
use of org.zmlx.hg4idea.repo.HgRepository in project intellij-community by JetBrains.
the class HgCheckinEnvironment method getFilesByRepository.
@NotNull
private Map<HgRepository, Set<HgFile>> getFilesByRepository(List<Change> changes) {
Map<HgRepository, Set<HgFile>> result = new HashMap<>();
for (Change change : changes) {
ContentRevision afterRevision = change.getAfterRevision();
ContentRevision beforeRevision = change.getBeforeRevision();
if (afterRevision != null) {
addFile(result, afterRevision);
}
if (beforeRevision != null) {
addFile(result, beforeRevision);
}
}
return result;
}
use of org.zmlx.hg4idea.repo.HgRepository in project intellij-community by JetBrains.
the class HgCheckinEnvironment method addFile.
private void addFile(Map<HgRepository, Set<HgFile>> result, ContentRevision contentRevision) {
FilePath filePath = contentRevision.getFile();
// try to find repository from hgFile from change: to be able commit sub repositories as expected
HgRepository repo = HgUtil.getRepositoryForFile(myProject, contentRevision instanceof HgCurrentBinaryContentRevision ? ((HgCurrentBinaryContentRevision) contentRevision).getRepositoryRoot() : ChangesUtil.findValidParentAccurately(filePath));
if (repo == null) {
return;
}
Set<HgFile> hgFiles = result.get(repo);
if (hgFiles == null) {
hgFiles = new HashSet<>();
result.put(repo, hgFiles);
}
hgFiles.add(new HgFile(repo.getRoot(), filePath));
}
use of org.zmlx.hg4idea.repo.HgRepository in project intellij-community by JetBrains.
the class HgLogProvider method getCommitsMatchingFilter.
@NotNull
@Override
public List<TimedVcsCommit> getCommitsMatchingFilter(@NotNull final VirtualFile root, @NotNull VcsLogFilterCollection filterCollection, int maxCount) throws VcsException {
List<String> filterParameters = ContainerUtil.newArrayList();
// branch filter and user filter may be used several times without delimiter
VcsLogBranchFilter branchFilter = filterCollection.getBranchFilter();
if (branchFilter != null) {
HgRepository repository = myRepositoryManager.getRepositoryForRoot(root);
if (repository == null) {
LOG.error("Repository not found for root " + root);
return Collections.emptyList();
}
Collection<String> branchNames = repository.getBranches().keySet();
Collection<String> bookmarkNames = HgUtil.getNamesWithoutHashes(repository.getBookmarks());
Collection<String> predefinedNames = ContainerUtil.list(TIP_REFERENCE);
boolean atLeastOneBranchExists = false;
for (String branchName : ContainerUtil.concat(branchNames, bookmarkNames, predefinedNames)) {
if (branchFilter.matches(branchName)) {
filterParameters.add(HgHistoryUtil.prepareParameter("branch", branchName));
atLeastOneBranchExists = true;
}
}
if (branchFilter.matches(HEAD_REFERENCE)) {
filterParameters.add(HgHistoryUtil.prepareParameter("branch", "."));
filterParameters.add("-r");
//all ancestors for current revision;
filterParameters.add("::.");
atLeastOneBranchExists = true;
}
if (!atLeastOneBranchExists) {
// no such branches => filter matches nothing
return Collections.emptyList();
}
}
if (filterCollection.getUserFilter() != null) {
filterParameters.add("-r");
String authorFilter = StringUtil.join(ContainerUtil.map(ContainerUtil.map(filterCollection.getUserFilter().getUsers(root), VcsUserUtil::toExactString), UserNameRegex.EXTENDED_INSTANCE), "|");
filterParameters.add("user('re:" + authorFilter + "')");
}
if (filterCollection.getDateFilter() != null) {
StringBuilder args = new StringBuilder();
final SimpleDateFormat dateFormatter = new SimpleDateFormat("yyyy-MM-dd HH:mm");
filterParameters.add("-d");
VcsLogDateFilter filter = filterCollection.getDateFilter();
if (filter.getAfter() != null) {
if (filter.getBefore() != null) {
args.append(dateFormatter.format(filter.getAfter())).append(" to ").append(dateFormatter.format(filter.getBefore()));
} else {
args.append('>').append(dateFormatter.format(filter.getAfter()));
}
} else if (filter.getBefore() != null) {
args.append('<').append(dateFormatter.format(filter.getBefore()));
}
filterParameters.add(args.toString());
}
if (filterCollection.getTextFilter() != null) {
String textFilter = filterCollection.getTextFilter().getText();
if (filterCollection.getTextFilter().isRegex()) {
filterParameters.add("-r");
filterParameters.add("grep(r'" + textFilter + "')");
} else if (filterCollection.getTextFilter().matchesCase()) {
filterParameters.add("-r");
filterParameters.add("grep(r'" + StringUtil.escapeChars(textFilter, UserNameRegex.EXTENDED_REGEX_CHARS) + "')");
} else {
filterParameters.add(HgHistoryUtil.prepareParameter("keyword", textFilter));
}
}
if (filterCollection.getStructureFilter() != null) {
for (FilePath file : filterCollection.getStructureFilter().getFiles()) {
filterParameters.add(file.getPath());
}
}
return HgHistoryUtil.readAllHashes(myProject, root, Consumer.EMPTY_CONSUMER, filterParameters);
}
use of org.zmlx.hg4idea.repo.HgRepository in project intellij-community by JetBrains.
the class HgUpdateCommand method updateTo.
public static void updateTo(@NotNull final String targetRevision, @NotNull List<HgRepository> repos, @Nullable final Runnable callInAwtLater) {
FileDocumentManager.getInstance().saveAllDocuments();
for (HgRepository repo : repos) {
final VirtualFile repository = repo.getRoot();
Project project = repo.getProject();
updateRepoTo(project, repository, targetRevision, callInAwtLater);
}
}
Aggregations