GitRepositoryUpdater(GitRepository repository) {
    VirtualFile gitDir = repository.getGitDir();
    myWatchRequest = LocalFileSystem.getInstance().addRootToWatch(gitDir.getPath(), true);

    myRepositoryFiles = GitRepositoryFiles.getInstance(gitDir);
    visitGitDirVfs(gitDir);
    myHeadsDir = VcsUtil.getVirtualFile(myRepositoryFiles.getRefsHeadsPath());
    myRemotesDir = VcsUtil.getVirtualFile(myRepositoryFiles.getRefsRemotesPath());

    Project project = repository.getProject();
    myUpdateQueue =
        new QueueProcessor<GitRepository.TrackedTopic>(
            new Updater(repository), project.getDisposed());
    if (!project.isDisposed()) {
      myMessageBusConnection = project.getMessageBus().connect();
      myMessageBusConnection.subscribe(VirtualFileManager.VFS_CHANGES, this);
    } else {
      myMessageBusConnection = null;
    }
  }
  private void updateChangesBrowser(final ChangeInfo changeDetails, final Project project) {
    myRepositoryChangesBrowser.getViewer().setEmptyText("Loading...");
    myRepositoryChangesBrowser.setChangesToDisplay(Collections.<Change>emptyList());
    final GitRepository gitRepository = GerritGitUtil.getFirstGitRepository(project);
    final VirtualFile virtualFile = gitRepository.getGitDir();
    final FilePathImpl filePath = new FilePathImpl(virtualFile);

    String ref = GerritUtil.getRef(changeDetails);

    GerritGitUtil.fetchChange(
        project,
        ref,
        new Callable<Void>() {
          @Override
          public Void call() throws Exception {
            final List<GitCommit> gitCommits;
            try {
              gitCommits =
                  GitHistoryUtils.commitsDetails(
                      project,
                      filePath,
                      new SymbolicRefs(),
                      Collections.singletonList(changeDetails.getCurrentRevision()));
            } catch (VcsException e) {
              throw new RuntimeException(e);
            }
            final GitCommit gitCommit = Iterables.get(gitCommits, 0);

            ApplicationManager.getApplication()
                .invokeLater(
                    new Runnable() {
                      @Override
                      public void run() {
                        myRepositoryChangesBrowser.setChangesToDisplay(gitCommit.getChanges());
                      }
                    });
            return null;
          }
        });
  }