use of com.intellij.vcs.log.Hash in project intellij-community by JetBrains.
the class HgRepositoryReader method readBranches.
@NotNull
public Map<String, LinkedHashSet<Hash>> readBranches() {
Map<String, LinkedHashSet<Hash>> branchesWithHashes = new HashMap<>();
// Set<String> branchNames = new HashSet<String>();
if (isBranchInfoAvailable()) {
Pattern activeBranchPattern = myStatusInBranchFile ? HASH_STATUS_NAME : HASH_NAME;
String[] branchesWithHeads = DvcsUtil.tryLoadFileOrReturn(myBranchHeadsFile, "").split("\n");
// first one - is a head revision: head hash + head number;
for (int i = 1; i < branchesWithHeads.length; ++i) {
Matcher matcher = activeBranchPattern.matcher(branchesWithHeads[i]);
if (matcher.matches()) {
String name = matcher.group(2);
if (branchesWithHashes.containsKey(name)) {
branchesWithHashes.get(name).add(myVcsObjectsFactory.createHash(matcher.group(1)));
} else {
LinkedHashSet<Hash> hashes = new LinkedHashSet<>();
hashes.add(myVcsObjectsFactory.createHash(matcher.group(1)));
branchesWithHashes.put(name, hashes);
}
}
}
}
return branchesWithHashes;
}
use of com.intellij.vcs.log.Hash in project intellij-community by JetBrains.
the class HgCompareWithBranchAction method getDiffChanges.
@Override
@NotNull
protected Collection<Change> getDiffChanges(@NotNull Project project, @NotNull VirtualFile file, @NotNull String branchToCompare) throws VcsException {
HgRepository repository = getRepositoryManager(project).getRepositoryForFile(file);
if (repository == null) {
throw new VcsException("Couldn't find repository for " + file.getName());
}
final FilePath filePath = VcsUtil.getFilePath(file);
final VirtualFile repositoryRoot = repository.getRoot();
final HgFile hgFile = new HgFile(repositoryRoot, filePath);
Hash refHashToCompare = detectActiveHashByName(repository, branchToCompare);
if (refHashToCompare == null) {
throw new VcsException(String.format("Couldn't detect commit related to %s name for %s.", branchToCompare, file));
}
final HgRevisionNumber compareWithRevisionNumber = HgRevisionNumber.getInstance(branchToCompare, refHashToCompare.toString());
List<Change> changes = HgUtil.getDiff(project, repositoryRoot, filePath, compareWithRevisionNumber, null);
if (changes.isEmpty() && !existInBranch(repository, filePath, compareWithRevisionNumber)) {
throw new VcsException(fileDoesntExistInBranchError(file, branchToCompare));
}
return changes.isEmpty() && !filePath.isDirectory() ? createChangesWithCurrentContentForFile(filePath, HgContentRevision.create(project, hgFile, compareWithRevisionNumber)) : changes;
}
use of com.intellij.vcs.log.Hash in project intellij-community by JetBrains.
the class HgCompareWithBranchAction method noBranchesToCompare.
@Override
protected boolean noBranchesToCompare(@NotNull HgRepository repository) {
final Map<String, LinkedHashSet<Hash>> branches = repository.getBranches();
if (branches.size() > 1)
return false;
final Hash currentRevisionHash = getCurrentHash(repository);
final Collection<HgNameWithHashInfo> other_bookmarks = getOtherBookmarks(repository, currentRevisionHash);
if (!other_bookmarks.isEmpty())
return false;
// if only one heavy branch and no other bookmarks -> check that current revision is not "main" branch head
return currentRevisionHash.equals(getHeavyBranchMainHash(repository, repository.getCurrentBranch()));
}
use of com.intellij.vcs.log.Hash in project intellij-community by JetBrains.
the class HgQGotoFromLogAction method actionPerformed.
protected void actionPerformed(@NotNull final HgRepository repository, @NotNull final VcsFullCommitDetails commit) {
final Project project = repository.getProject();
List<Hash> parents = commit.getParents();
final Hash parentHash = parents.isEmpty() ? null : parents.get(0);
final HgNameWithHashInfo parentPatchName = ContainerUtil.find(repository.getMQAppliedPatches(), new Condition<HgNameWithHashInfo>() {
@Override
public boolean value(HgNameWithHashInfo info) {
return info.getHash().equals(parentHash);
}
});
new Task.Backgroundable(repository.getProject(), parentPatchName != null ? HgVcsMessages.message("hg4idea.mq.progress.goto", parentPatchName) : HgVcsMessages.message("hg4idea.mq.progress.pop")) {
@Override
public void run(@NotNull ProgressIndicator indicator) {
if (parentPatchName != null) {
new HgQGotoCommand(repository).executeInCurrentThread(parentPatchName.getName());
} else {
new HgQPopCommand(repository).executeInCurrentThread();
}
}
@Override
public void onSuccess() {
HgShowUnAppliedPatchesAction.showUnAppliedPatches(project, repository);
}
}.queue();
}
use of com.intellij.vcs.log.Hash in project intellij-community by JetBrains.
the class HashBuildTest method doTest.
private static void doTest(String strHash) {
Hash hash = HashImpl.build(strHash);
assertEquals(strHash, hash.asString());
}
Aggregations