use of com.intellij.dvcs.repo.RepoStateException in project intellij-community by JetBrains.
the class GitRepositoryReader method readHead.
@NotNull
private HeadInfo readHead() {
String headContent;
try {
headContent = DvcsUtil.tryLoadFile(myHeadFile, CharsetToolkit.UTF8);
} catch (RepoStateException e) {
LOG.error(e);
return new HeadInfo(false, null);
}
Hash hash = parseHash(headContent);
if (hash != null) {
return new HeadInfo(false, headContent);
}
String target = getTarget(headContent);
if (target != null) {
return new HeadInfo(true, target);
}
// including "refs/tags/v1"
LOG.error(new RepoStateException("Invalid format of the .git/HEAD file: [" + headContent + "]"));
return new HeadInfo(false, null);
}
use of com.intellij.dvcs.repo.RepoStateException in project intellij-community by JetBrains.
the class HgRepositoryReader method readCurrentTipRevision.
/**
* Finds tip revision value.
*
* @return The tip revision hash, or <b>{@code null}</b> if tip revision is unknown - it is the initial repository state.
*/
@Nullable
public String readCurrentTipRevision() {
if (!isBranchInfoAvailable())
return null;
String[] branchesWithHeads;
try {
branchesWithHeads = DvcsUtil.tryLoadFile(myBranchHeadsFile).split("\n");
} catch (RepoStateException e) {
LOG.error(e);
return null;
}
String head = branchesWithHeads[0];
Matcher matcher = HASH_NAME.matcher(head);
if (matcher.matches()) {
return (matcher.group(1));
}
return null;
}
Aggregations