com.intellij.openapi.vcs.RepositoryLocation Java Examples

The following examples show how to use com.intellij.openapi.vcs.RepositoryLocation. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: P4CommittedChangesProvider.java    From p4ic4idea with Apache License 2.0 6 votes vote down vote up
@Nullable
@Override
public VcsCommittedListsZipper getZipper() {
    LOG.debug("Creating the zipper");
    return new VcsCommittedListsZipperAdapter(new VcsCommittedListsZipperAdapter.GroupCreator() {
        @Override
        public Object createKey(RepositoryLocation repositoryLocation) {
            return repositoryLocation;
        }

        @Override
        public RepositoryLocationGroup createGroup(Object o, Collection<RepositoryLocation> collection) {
            return new RepositoryLocationGroup(o.toString());
        }
    }){};
}
 
Example #2
Source File: TFSCommittedChangesProviderTest.java    From azure-devops-intellij with MIT License 5 votes vote down vote up
@Test
public void testLoadCommittedChanges_FoundChanges() throws Exception {
    final List<ChangeSet> changeSetList = ImmutableList.of(mockChangeSet1, mockChangeSet2, mockChangeSet3);
    when(CommandUtils.getHistoryCommand(any(ServerContext.class), eq(LOCAL_ROOT_PATH), eq("C30~C50"),
            eq(20), eq(true), eq(USER_ME))).thenReturn(changeSetList);
    final RepositoryLocation repositoryLocation = new TFSRepositoryLocation(mockWorkspace, mockVirtualFile);
    committedChangesProvider.loadCommittedChanges(mockChangeBrowserSettings, repositoryLocation, 20, mockAsynchConsumer);
    verify(mockAsynchConsumer, times(3)).consume(any(TFSChangeList.class));
    verify(mockTFSChangeListBuilder).createChangeList(eq(mockChangeSet1), eq(40), eq("2016-07-11T12:00:00.000-0400"));
    verify(mockTFSChangeListBuilder).createChangeList(eq(mockChangeSet2), eq(31), eq("2016-06-23T04:30:00.00-0400"));
    verify(mockTFSChangeListBuilder).createChangeList(eq(mockChangeSet3), eq(0), eq(StringUtils.EMPTY));
    verify(mockAsynchConsumer).finished();
    verifyNoMoreInteractions(mockAsynchConsumer);
}
 
Example #3
Source File: P4CommittedChangesProvider.java    From p4ic4idea with Apache License 2.0 5 votes vote down vote up
@Nullable
@Override
public Collection<FilePath> getIncomingFiles(RepositoryLocation repositoryLocation)
        throws VcsException {
    // No real concept of incoming files.
    return null;
}
 
Example #4
Source File: ClearCommittedAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
public void update(final AnActionEvent e) {
  Project project = e.getData(CommonDataKeys.PROJECT);
  if (project != null) {
    CommittedChangesPanel panel = ChangesViewContentManager.getInstance(project).getActiveComponent(CommittedChangesPanel.class);
    RepositoryLocation rl = panel == null ? null : panel.getRepositoryLocation();
    e.getPresentation().setVisible(rl == null);
    e.getPresentation().setEnabled(panel != null && (! panel.isInLoad()));
  }
  else {
    e.getPresentation().setVisible(false);
    e.getPresentation().setEnabled(false);
  }
}
 
Example #5
Source File: RepositoryLocationFactory.java    From p4ic4idea with Apache License 2.0 5 votes vote down vote up
@NotNull
public static RepositoryLocation getLocationFor(@NotNull FilePath root, @NotNull ClientConfigRoot clientRoot,
        @NotNull ListFilesDetailsResult details) {
    if (details.getFiles().isEmpty()) {
        String clientName = clientRoot.getClientConfig().getClientname();
        if (clientName == null) {
            // TODO bundle string
            clientName = "<unknown>";
        }
        return new LocalRepositoryLocation(clientRoot.getClientConfig().getClientServerRef(), clientName, root);
    }
    return new P4RepositoryLocationImpl(clientRoot.getClientConfig().getClientServerRef(), details.getFiles().get(0));
}
 
Example #6
Source File: P4CommittedChangesProvider.java    From p4ic4idea with Apache License 2.0 5 votes vote down vote up
@Nullable
@Override
public VcsCommittedViewAuxiliary createActions(DecoratorManager manager, RepositoryLocation location) {
    LOG.debug("Creating actions");
    List<AnAction> allActions =
            Collections.singletonList(new ChangelistDescriptionAction());
    return new VcsCommittedViewAuxiliary(
            allActions,
            () -> {
                // on dispose - do nothing
                LOG.debug("Disposing view");
            },
            allActions
    );
}
 
Example #7
Source File: P4CommittedChangesProvider.java    From p4ic4idea with Apache License 2.0 5 votes vote down vote up
@NotNull
private P4CommandRunner.QueryAnswer<List<P4CommittedChangelist>> asyncLoadCommittedChanges(
        P4ChangeBrowserSettings settings, RepositoryLocation location, int maxCount) {
    if (LOG.isDebugEnabled()) {
        LOG.debug("Loading committed changes for " + location);
    }
    ProjectConfigRegistry registry = ProjectConfigRegistry.getInstance(project);
    if (location == null || registry == null) {
        return new DoneQueryAnswer<>(Collections.emptyList());
    }
    if (location instanceof P4RepositoryLocation) {
        P4RepositoryLocation repo = (P4RepositoryLocation) location;
        ClientConfig clientConfig = registry.getRegisteredClientConfigState(repo.getClientServerRef());
        if (clientConfig == null) {
            LOG.warn("Could not find configuration for " + repo.getClientServerRef());
            return new DoneQueryAnswer<>(Collections.emptyList());
        }

        P4Vcs vcs = P4Vcs.getInstance(project);
        return P4ServerComponent
                .query(project, clientConfig,
                        new ListSubmittedChangelistsQuery(repo, settings.getQueryFilter(), maxCount))
                .mapQuery((c) -> c.getChangesForVcs(vcs));
    }
    LOG.warn("Cannot load changes for non-perforce repository location " + location);
    return new DoneQueryAnswer<>(Collections.emptyList());
}
 
Example #8
Source File: P4CommittedChangesProvider.java    From p4ic4idea with Apache License 2.0 5 votes vote down vote up
@Override
public void loadCommittedChanges(P4ChangeBrowserSettings settings, RepositoryLocation location, int maxCount,
        AsynchConsumer consumer) throws VcsException {
    if (LOG.isDebugEnabled()) {
        LOG.debug("Loading committed changes for location " + location);
    }
    if (consumer == null) {
        LOG.debug("Attempted to load committed changes with null consumer");
        return;
    }
    asyncLoadCommittedChanges(settings, location, maxCount)
            .whenCompleted((c) -> c.forEach(consumer::consume))
            .whenAnyState(consumer::finished)
            .whenServerError((e) -> LOG.warn("Problem loading committed changes", e));
}
 
Example #9
Source File: P4CommittedChangesProvider.java    From p4ic4idea with Apache License 2.0 5 votes vote down vote up
@Deprecated
@Nullable
//@Override
public RepositoryLocation getLocationFor(FilePath root, String repositoryPath) {
    // TODO should this use repository path?
    if (LOG.isDebugEnabled()) {
        LOG.debug("Finding location for root [" + root + "], path [" + repositoryPath + "]");
    }
    return getLocationFor(root);
}
 
Example #10
Source File: TFSCommittedChangesProviderTest.java    From azure-devops-intellij with MIT License 5 votes vote down vote up
@Test
public void testLoadCommittedChanges_NoChanges() throws Exception {
    final List<ChangeSet> changeSetList = Collections.EMPTY_LIST;
    when(CommandUtils.getHistoryCommand(any(ServerContext.class), eq(LOCAL_ROOT_PATH), eq("C30~C50"),
            eq(20), eq(true), eq(USER_ME))).thenReturn(changeSetList);
    final RepositoryLocation repositoryLocation = new TFSRepositoryLocation(mockWorkspace, mockVirtualFile);
    committedChangesProvider.loadCommittedChanges(mockChangeBrowserSettings, repositoryLocation, 20, mockAsynchConsumer);
    verify(mockAsynchConsumer).finished();
    verifyNoMoreInteractions(mockAsynchConsumer);
}
 
Example #11
Source File: TFSCommittedChangesProviderTest.java    From azure-devops-intellij with MIT License 5 votes vote down vote up
@Test
public void testGetLocationFor() {
    final RepositoryLocation repositoryLocation = committedChangesProvider.getLocationFor(mockRoot);
    assertEquals(SERVER_URL, repositoryLocation.getKey());
    assertEquals(mockWorkspace, ((TFSRepositoryLocation) repositoryLocation).getWorkspace());
    assertEquals(mockVirtualFile, ((TFSRepositoryLocation) repositoryLocation).getRoot());
}
 
Example #12
Source File: RepositoryLocationGroup.java    From consulo with Apache License 2.0 5 votes vote down vote up
public void add(@Nonnull final RepositoryLocation location) {
  for (int i = 0; i < myLocations.size(); i++) {
    final RepositoryLocation t = myLocations.get(i);
    if (t.getKey().compareTo(location.getKey()) >= 0) {
      myLocations.add(i, location);
      return;
    }
  }
  myLocations.add(location);
}
 
Example #13
Source File: TFSCommittedChangesProvider.java    From azure-devops-intellij with MIT License 5 votes vote down vote up
@Override
public List<TFSChangeList> getCommittedChanges(final ChangeBrowserSettings settings,
                                               final RepositoryLocation location,
                                               final int maxCount) throws VcsException {
    final List<TFSChangeList> result = new ArrayList<TFSChangeList>();
    loadCommittedChanges(settings, location, maxCount, new AsynchConsumer<CommittedChangeList>() {
        public void finished() {
        }

        public void consume(final CommittedChangeList committedChangeList) {
            result.add((TFSChangeList) committedChangeList);
        }
    });
    return result;
}
 
Example #14
Source File: CommittedListsSequencesZipper.java    From consulo with Apache License 2.0 5 votes vote down vote up
public void add(final RepositoryLocation location, final List<CommittedChangeList> lists) {
  myInLocations.add(location);
  Collections.sort(lists, new Comparator<CommittedChangeList>() {
    public int compare(final CommittedChangeList o1, final CommittedChangeList o2) {
      final long num1 = myVcsPartner.getNumber(o1);
      final long num2 = myVcsPartner.getNumber(o2);
      return num1 == num2 ? 0 : (num1 < num2) ? -1 : 1;
    }
  });
  myInLists.put(location.toPresentableString(), lists);
}
 
Example #15
Source File: RepositoryLocationGroup.java    From consulo with Apache License 2.0 5 votes vote down vote up
public String getKey() {
  final StringBuilder sb = new StringBuilder(myPresentableString);
  // they are ordered
  for (RepositoryLocation location : myLocations) {
    sb.append(location.getKey());
  }
  return sb.toString();
}
 
Example #16
Source File: TFSCommittedChangesProvider.java    From azure-devops-intellij with MIT License 5 votes vote down vote up
@Override
@Nullable
public RepositoryLocation getLocationFor(final FilePath root) {
    if (!TFVCUtil.isFileUnderTFVCMapping(project, root)) {
        return null;
    }

    final Workspace workspace = CommandUtils.getPartialWorkspace(project);
    return new TFSRepositoryLocation(workspace, root.getVirtualFile());
}
 
Example #17
Source File: VcsFileRevision.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nullable
@Override
public RepositoryLocation getChangedRepositoryPath() {
  return null;
}
 
Example #18
Source File: CurrentRevision.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nullable
@Override
public RepositoryLocation getChangedRepositoryPath() {
  return null;  // use initial url..
}
 
Example #19
Source File: VcsFileRevision.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nullable
RepositoryLocation getChangedRepositoryPath();
 
Example #20
Source File: TreeNodeOnVcsRevision.java    From consulo with Apache License 2.0 4 votes vote down vote up
@javax.annotation.Nullable
@Override
public RepositoryLocation getChangedRepositoryPath() {
  return myRevision.getChangedRepositoryPath();
}
 
Example #21
Source File: RootsCalculator.java    From consulo with Apache License 2.0 4 votes vote down vote up
@javax.annotation.Nullable
private RepositoryLocation getLocation(@Nonnull VirtualFile file) {
  return myLocationCache.getLocation(myVcs, getFilePath(file), false);
}
 
Example #22
Source File: CommittedChangesAdapter.java    From consulo with Apache License 2.0 4 votes vote down vote up
public void changesLoaded(RepositoryLocation location, List<CommittedChangeList> changes) {
}
 
Example #23
Source File: CompositeRepositoryLocation.java    From consulo with Apache License 2.0 4 votes vote down vote up
public CompositeRepositoryLocation(final CommittedChangesProvider provider, final RepositoryLocation providerLocation) {
  myProvider = provider;
  myProviderLocation = providerLocation;
}
 
Example #24
Source File: CompositeRepositoryLocation.java    From consulo with Apache License 2.0 4 votes vote down vote up
public RepositoryLocation getProviderLocation() {
  return myProviderLocation;
}
 
Example #25
Source File: CommittedListsSequencesZipper.java    From consulo with Apache License 2.0 4 votes vote down vote up
public CommittedListsSequencesZipper(final VcsCommittedListsZipper vcsPartner) {
  myVcsPartner = vcsPartner;
  myInLocations = new ArrayList<RepositoryLocation>();
  myInLists = new HashMap<String, List<CommittedChangeList>>();
}
 
Example #26
Source File: IncomingChangesViewProvider.java    From consulo with Apache License 2.0 4 votes vote down vote up
public void changesLoaded(final RepositoryLocation location, final List<CommittedChangeList> changes) {
  updateModel(true, true);
}
 
Example #27
Source File: TfsFileRevision.java    From azure-devops-intellij with MIT License 4 votes vote down vote up
@Nullable
@Override
public RepositoryLocation getChangedRepositoryPath() {
    return null;
}
 
Example #28
Source File: RepositoryLocationGroup.java    From consulo with Apache License 2.0 4 votes vote down vote up
public List<RepositoryLocation> getLocations() {
  return myLocations;
}
 
Example #29
Source File: RepositoryLocationGroup.java    From consulo with Apache License 2.0 4 votes vote down vote up
public RepositoryLocationGroup(final String presentableString) {
  myPresentableString = presentableString;
  myLocations = new ArrayList<RepositoryLocation>();
}
 
Example #30
Source File: P4HistoryVcsFileRevision.java    From p4ic4idea with Apache License 2.0 4 votes vote down vote up
@Nullable
@Override
public RepositoryLocation getChangedRepositoryPath() {
    return null;
}