Example #1
0
        private void ForceProjectionChange(ITracer tracer, GVFSEnlistment enlistment)
        {
            string errorMessage = null;

            if (!this.ShowStatusWhileRunning(
                    () =>
            {
                NamedPipeMessages.PostIndexChanged.Response response = null;

                try
                {
                    using (NamedPipeClient pipeClient = new NamedPipeClient(enlistment.NamedPipeName))
                    {
                        if (!pipeClient.Connect())
                        {
                            this.ReportErrorAndExit("Unable to connect to GVFS.  Try running 'gvfs mount'");
                        }

                        NamedPipeMessages.PostIndexChanged.Request request = new NamedPipeMessages.PostIndexChanged.Request(updatedWorkingDirectory: true, updatedSkipWorktreeBits: false);
                        pipeClient.SendRequest(request.CreateMessage());
                        response = new NamedPipeMessages.PostIndexChanged.Response(NamedPipeMessages.Message.FromString(pipeClient.ReadRawResponse()).Header);
                        return(response.Result == NamedPipeMessages.PostIndexChanged.SuccessResult);
                    }
                }
                catch (BrokenPipeException e)
                {
                    this.ReportErrorAndExit("Unable to communicate with GVFS: " + e.ToString());
                    return(false);
                }
            },
                    "Forcing a projection change",
                    suppressGvfsLogMessage: true))
            {
                this.WriteMessage(tracer, "Failed to change projection: " + errorMessage);
            }
        }