diff options
Diffstat (limited to 'platform/dvcs-api/src/com')
16 files changed, 678 insertions, 0 deletions
diff --git a/platform/dvcs-api/src/com/intellij/dvcs/push/CommitLoader.java b/platform/dvcs-api/src/com/intellij/dvcs/push/CommitLoader.java new file mode 100644 index 000000000000..71ffa32d93e2 --- /dev/null +++ b/platform/dvcs-api/src/com/intellij/dvcs/push/CommitLoader.java @@ -0,0 +1,20 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.dvcs.push; + +public interface CommitLoader { + void reloadCommits(); +} diff --git a/platform/dvcs-api/src/com/intellij/dvcs/push/OutgoingCommitsProvider.java b/platform/dvcs-api/src/com/intellij/dvcs/push/OutgoingCommitsProvider.java new file mode 100644 index 000000000000..4532146f9b4a --- /dev/null +++ b/platform/dvcs-api/src/com/intellij/dvcs/push/OutgoingCommitsProvider.java @@ -0,0 +1,35 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.dvcs.push; + +import com.intellij.dvcs.repo.Repository; +import org.jetbrains.annotations.NotNull; + +/** + * Provider for outgoing commits + */ +public abstract class OutgoingCommitsProvider { + + /** + * Collect outgoing commits or errors for selected repo for specified {@link PushSpec} and store to {@link OutgoingResult} + * + * @param initial true for first commits loading, which identify that all inside actions should be silent + * and do not ask user about smth, a.e authorization request + */ + @NotNull + public abstract OutgoingResult getOutgoingCommits(@NotNull Repository repository, + @NotNull PushSpec pushSpec, boolean initial); +} diff --git a/platform/dvcs-api/src/com/intellij/dvcs/push/OutgoingResult.java b/platform/dvcs-api/src/com/intellij/dvcs/push/OutgoingResult.java new file mode 100644 index 000000000000..7b4b0a7b4a81 --- /dev/null +++ b/platform/dvcs-api/src/com/intellij/dvcs/push/OutgoingResult.java @@ -0,0 +1,41 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.dvcs.push; + +import com.intellij.vcs.log.VcsFullCommitDetails; +import org.jetbrains.annotations.NotNull; + +import java.util.List; + +public class OutgoingResult { + @NotNull private final List<VcsError> myErrors; + @NotNull private final List<? extends VcsFullCommitDetails> myCommits; + + public OutgoingResult(@NotNull List<? extends VcsFullCommitDetails> commits, @NotNull List<VcsError> errors) { + myCommits = commits; + myErrors = errors; + } + + @NotNull + public List<VcsError> getErrors() { + return myErrors; + } + + @NotNull + public List<? extends VcsFullCommitDetails> getCommits() { + return myCommits; + } +} diff --git a/platform/dvcs-api/src/com/intellij/dvcs/push/PushSource.java b/platform/dvcs-api/src/com/intellij/dvcs/push/PushSource.java new file mode 100644 index 000000000000..7ae7a33dd6e2 --- /dev/null +++ b/platform/dvcs-api/src/com/intellij/dvcs/push/PushSource.java @@ -0,0 +1,26 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.dvcs.push; + +import org.jetbrains.annotations.NotNull; + +/** + * Source to push from. For example, local branch for git or branch/bookmark for mercurial. + */ +public interface PushSource { + @NotNull + String getPresentation(); +} diff --git a/platform/dvcs-api/src/com/intellij/dvcs/push/PushSpec.java b/platform/dvcs-api/src/com/intellij/dvcs/push/PushSpec.java new file mode 100644 index 000000000000..81ff874979bd --- /dev/null +++ b/platform/dvcs-api/src/com/intellij/dvcs/push/PushSpec.java @@ -0,0 +1,43 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.dvcs.push; + +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * Specified a push from-to settings for one repository + */ +public class PushSpec { + + @NotNull private PushSource mySource; + @Nullable private PushTarget myTarget; + + public PushSpec(@NotNull PushSource source, @Nullable PushTarget target) { + mySource = source; + myTarget = target; + } + + @NotNull + public PushSource getSource() { + return mySource; + } + + @Nullable + public PushTarget getTarget() { + return myTarget; + } +} diff --git a/platform/dvcs-api/src/com/intellij/dvcs/push/PushSupport.java b/platform/dvcs-api/src/com/intellij/dvcs/push/PushSupport.java new file mode 100644 index 000000000000..d6af8eec1088 --- /dev/null +++ b/platform/dvcs-api/src/com/intellij/dvcs/push/PushSupport.java @@ -0,0 +1,88 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.dvcs.push; + +import com.intellij.dvcs.repo.Repository; +import com.intellij.dvcs.repo.RepositoryManager; +import com.intellij.openapi.extensions.ExtensionPointName; +import com.intellij.openapi.vcs.AbstractVcs; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.util.Collection; + +/** + * Base class to provide vcs-specific info + */ + +public abstract class PushSupport<Repo extends Repository> { + + public static final ExtensionPointName<PushSupport<? extends Repository>> PUSH_SUPPORT_EP = + ExtensionPointName.create("com.intellij.pushSupport"); + + @NotNull + public abstract AbstractVcs getVcs(); + + @NotNull + public abstract Pusher getPusher(); + + @NotNull + public abstract OutgoingCommitsProvider getOutgoingCommitsProvider(); + + /** + * @return Default push destination + */ + @Nullable + public abstract PushTarget getDefaultTarget(@NotNull Repo repository); + + /** + * @return All remembered remote destinations used for completion + */ + @NotNull + public abstract Collection<String> getTargetNames(@NotNull Repo repository); + + /** + * @return current source(branch) for repository + */ + @NotNull + public abstract PushSource getSource(@NotNull Repo repository); + + /** + * Parse user input string, and create the valid target for push, + * or return <code><b>null</b></code> if the target name is not valid. + * + * @see #validateSpec(Repository, PushSpec) + */ + @Nullable + public abstract PushTarget createTarget(@NotNull Repo repository, @NotNull String targetName); + + /** + * @return RepositoryManager for vcs + */ + @NotNull + public abstract RepositoryManager<Repo> getRepositoryManager(); + + @Nullable + public VcsPushOptionsPanel getVcsPushOptionsPanel() { + return null; + } + + /** + * @return null if target is valid for selected repository + */ + @Nullable + public abstract VcsError validate(@NotNull Repository repository, @Nullable String targetToValidate); +} diff --git a/platform/dvcs-api/src/com/intellij/dvcs/push/PushTarget.java b/platform/dvcs-api/src/com/intellij/dvcs/push/PushTarget.java new file mode 100644 index 000000000000..87c7244bd77c --- /dev/null +++ b/platform/dvcs-api/src/com/intellij/dvcs/push/PushTarget.java @@ -0,0 +1,28 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.dvcs.push; + +import org.jetbrains.annotations.NotNull; + + +/** + * Destination for push action. (Remote for git or push-path for mercurial). + */ +public interface PushTarget { + + @NotNull + String getPresentation(); +} diff --git a/platform/dvcs-api/src/com/intellij/dvcs/push/Pusher.java b/platform/dvcs-api/src/com/intellij/dvcs/push/Pusher.java new file mode 100644 index 000000000000..6d5fc1611030 --- /dev/null +++ b/platform/dvcs-api/src/com/intellij/dvcs/push/Pusher.java @@ -0,0 +1,39 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.dvcs.push; + +import com.intellij.dvcs.repo.Repository; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.util.Map; + +/** + * Base class to execute push command. + */ +public abstract class Pusher { + /** + * Perform push command for all repositories belonged to one vcs. + * + * @param pushSpecs specify push from and to params + * @param vcsPushOptionValue specify additional options to push, null if not supported + * @param force if true then execute force push + */ + public abstract void push(@NotNull Map<Repository, PushSpec> pushSpecs, + @Nullable VcsPushOptionValue vcsPushOptionValue, + boolean force); +} + diff --git a/platform/dvcs-api/src/com/intellij/dvcs/push/TreeNodeLinkListener.java b/platform/dvcs-api/src/com/intellij/dvcs/push/TreeNodeLinkListener.java new file mode 100644 index 000000000000..8ce03d299b29 --- /dev/null +++ b/platform/dvcs-api/src/com/intellij/dvcs/push/TreeNodeLinkListener.java @@ -0,0 +1,24 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.dvcs.push; + +import org.jetbrains.annotations.NotNull; + +import javax.swing.tree.DefaultMutableTreeNode; + +public interface TreeNodeLinkListener { + void onClick(@NotNull DefaultMutableTreeNode source); +} diff --git a/platform/dvcs-api/src/com/intellij/dvcs/push/VcsError.java b/platform/dvcs-api/src/com/intellij/dvcs/push/VcsError.java new file mode 100644 index 000000000000..de2c640d12b1 --- /dev/null +++ b/platform/dvcs-api/src/com/intellij/dvcs/push/VcsError.java @@ -0,0 +1,43 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.dvcs.push; + +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +public class VcsError { + @NotNull String myErrorText; + @Nullable private final VcsErrorHandler myErrorHandleListener; + + public VcsError(@NotNull String text) { + this(text, null); + } + + public VcsError(@NotNull String text, @Nullable VcsErrorHandler listener) { + myErrorText = text; + myErrorHandleListener = listener; + } + + public String getText() { + return myErrorText; + } + + public void handleError(@NotNull CommitLoader loader) { + if (myErrorHandleListener != null) { + myErrorHandleListener.handleError(loader); + } + } +} diff --git a/platform/dvcs-api/src/com/intellij/dvcs/push/VcsErrorHandler.java b/platform/dvcs-api/src/com/intellij/dvcs/push/VcsErrorHandler.java new file mode 100644 index 000000000000..c27e4c7e99d9 --- /dev/null +++ b/platform/dvcs-api/src/com/intellij/dvcs/push/VcsErrorHandler.java @@ -0,0 +1,22 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.dvcs.push; + +import org.jetbrains.annotations.NotNull; + +public interface VcsErrorHandler { + void handleError(@NotNull CommitLoader loader); +} diff --git a/platform/dvcs-api/src/com/intellij/dvcs/push/VcsPushOptionValue.java b/platform/dvcs-api/src/com/intellij/dvcs/push/VcsPushOptionValue.java new file mode 100644 index 000000000000..61a50eb09d73 --- /dev/null +++ b/platform/dvcs-api/src/com/intellij/dvcs/push/VcsPushOptionValue.java @@ -0,0 +1,19 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.dvcs.push; + +public interface VcsPushOptionValue { +} diff --git a/platform/dvcs-api/src/com/intellij/dvcs/push/VcsPushOptionsPanel.java b/platform/dvcs-api/src/com/intellij/dvcs/push/VcsPushOptionsPanel.java new file mode 100644 index 000000000000..5ecd9af0d182 --- /dev/null +++ b/platform/dvcs-api/src/com/intellij/dvcs/push/VcsPushOptionsPanel.java @@ -0,0 +1,29 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.dvcs.push; + +import javax.swing.*; +import java.awt.event.ActionListener; + +public abstract class VcsPushOptionsPanel extends JPanel { + + public abstract VcsPushOptionValue getValue(); + + /** + * @param listener handle valueChange event + */ + public abstract void addValueChangeListener(ActionListener listener); +} diff --git a/platform/dvcs-api/src/com/intellij/dvcs/push/VcsPushReferenceStrategy.java b/platform/dvcs-api/src/com/intellij/dvcs/push/VcsPushReferenceStrategy.java new file mode 100644 index 000000000000..7e4cbecb796b --- /dev/null +++ b/platform/dvcs-api/src/com/intellij/dvcs/push/VcsPushReferenceStrategy.java @@ -0,0 +1,26 @@ +/* + * Copyright 2000-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.dvcs.push; + +/** + * Specify which references(tags) should be pushed + */ + +public enum VcsPushReferenceStrategy { + none, // do not push references/tags + follow, // push references only for selected sources + all // push all references for all repositories +} diff --git a/platform/dvcs-api/src/com/intellij/dvcs/repo/Repository.java b/platform/dvcs-api/src/com/intellij/dvcs/repo/Repository.java new file mode 100644 index 000000000000..47cc17866c08 --- /dev/null +++ b/platform/dvcs-api/src/com/intellij/dvcs/repo/Repository.java @@ -0,0 +1,126 @@ +/* + * Copyright 2000-2013 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.dvcs.repo; + +import com.intellij.openapi.Disposable; +import com.intellij.openapi.project.Project; +import com.intellij.openapi.vcs.AbstractVcs; +import com.intellij.openapi.vfs.VirtualFile; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * <p> + * Repository is a representation of a Git repository stored under the specified directory. + * It stores the information about the repository, which is frequently requested by other plugin components. + * All get-methods (like {@link #getCurrentRevision()}) are just getters of the correspondent fields and thus are very fast. + * </p> + * <p> + * The Repository is updated "externally" by the appropriate Updater class}, when correspondent {@code .git/ or .hg/} service files + * change. + * </p> + * <p> + * To force asynchronous update, it is enough to call {@link VirtualFile#refresh(boolean, boolean) refresh} on the root directory. + * </p> + * <p> + * To make a synchronous update of the repository call {@link #update()}. + * Updating requires reading from disk, so it may take some time, however, updating the whole community repository took ~10 ms at the time + * of measurement, so must be fast enough. Better not to be called in AWT though. + * <p/> + * <p> + * Getters and setters (update...()-methods) are not synchronized intentionally - to avoid live- and deadlocks. + * GitRepository is updated asynchronously, + * so even if the getters would have been synchronized, it wouldn't guarantee that they return actual values (as they are in .git). + * <br/> + * If one needs a really 100 % up-to-date value, one should call {@link #update()} and then get...(). + * update() is a synchronous read from repository file (.git or .hg), so it is guaranteed to query the real value. + * </p> + * + * @author Nadya Zabrodina + */ +public interface Repository extends Disposable { + + + /** + * Current state of the repository. + */ + enum State { + /** + * HEAD is on branch, no merge process is in progress (and no rebase as well). + */ + NORMAL, + /** + * During merge (for instance, merge failed with conflicts that weren't immediately resolved). + */ + MERGING { + @Override + public String toString() { + return "Merging"; + } + }, + /** + * During rebase. + */ + REBASING { + @Override + public String toString() { + return "Rebasing"; + } + }, + /** + * Detached HEAD state, but not during rebase (for example, manual checkout of a commit hash). + */ + DETACHED + } + + @NotNull + VirtualFile getRoot(); + + @NotNull + String getPresentableUrl(); + + @NotNull + Project getProject(); + + @NotNull + State getState(); + + @Nullable + AbstractVcs getVcs(); + + /** + * Returns the hash of the revision, which HEAD currently points to. + * Returns null only in the case of a fresh repository, when no commit have been made. + */ + @Nullable + String getCurrentRevision(); + + /** + * @return true if current repository is "fresh", i.e. if no commits have been made yet. + */ + boolean isFresh(); + + /** + * Synchronously updates the Repository by reading information about it from disk (e.g. for Git: from .git/config and .git/refs/...) + */ + void update(); + + /** + * Returns a detailed String representation suitable for logging purposes. + */ + @NotNull + String toLogString(); +} diff --git a/platform/dvcs-api/src/com/intellij/dvcs/repo/RepositoryManager.java b/platform/dvcs-api/src/com/intellij/dvcs/repo/RepositoryManager.java new file mode 100644 index 000000000000..d27694cd05d0 --- /dev/null +++ b/platform/dvcs-api/src/com/intellij/dvcs/repo/RepositoryManager.java @@ -0,0 +1,69 @@ +/* + * Copyright 2000-2011 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.dvcs.repo; + +import com.intellij.openapi.vcs.FilePath; +import com.intellij.openapi.vfs.VirtualFile; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.util.List; + +/** + * RepositoryManager initializes and stores {@link Repository repositories} for Git or Hgroots defined in the project. + * + * @author Kirill Likhodedov + */ +public interface RepositoryManager<T extends Repository> { + + /** + * Returns the {@link Repository} which tracks the Git or Hg repository located in the given directory, + * or {@code null} if the given file is not a vcs root known to this {@link com.intellij.openapi.project.Project}. + */ + @Nullable + T getRepositoryForRoot(@Nullable VirtualFile root); + + /** + * Returns the {@link Repository} which the given file belongs to, or {@code null} if the file is not under any Git or Hg repository. + */ + @Nullable + T getRepositoryForFile(@NotNull VirtualFile file); + + /** + * Returns the {@link Repository} which the given file belongs to, or {@code null} if the file is not under any Git ot Hg repository. + */ + @Nullable + T getRepositoryForFile(@NotNull FilePath file); + + /** + * @return all repositories tracked by the manager. + */ + @NotNull + List<T> getRepositories(); + + boolean moreThanOneRoot(); + + /** + * Synchronously updates the specified information about repository under the given root. + * + * @param root root directory of the vcs repository. + */ + void updateRepository(VirtualFile root); + + void updateAllRepositories(); + + void waitUntilInitialized(); +} |