public InternalBlameViewModel(string filePath, int?lineNumber, IToolWindowViewModel tool) { this.blameHelper = new BlameHelper(tool); this.mergeHelper = new MergeHelper(tool); FilePath = filePath; PreviousRevisionCommand = new DelegateCommand(NavigateToPreviousRevision, CanNavigateToPreviousRevision); NextRevisionCommand = new DelegateCommand(NavigateToNextRevision, CanNavigateToNextRevision); SpecifiedRevisionCommand = new DelegateCommand(NavigateToSpecifiedRevision, CanNavigateToSpecifiedRevision); LastRevisionCommand = new DelegateCommand(NavigateToLastRevision, CanNavigateToLastRevision); CompareWithPreviousCommand = new DelegateCommand(CompareWithPrevious, CanCompareWithPrevious); CompareCurrentFileCommand = new DelegateCommand(CompareCurrentFile, CanCompareCurrentFile); CopyCommentCommand = new DelegateCommand(CopyComment, CanCopyComment); int line = lineNumber - 1 ?? 0; InitializeFileDiffInfo(); Blame = fileDiffInfo.BlameAtRevision(LastRevision); CurrentRevision = LastRevision; CurrentLine = Blame.ElementAtOrDefault(line); }
//void ShowExternalBlameInternal(Uri svnFile, int? lineNumber) { // if (string.IsNullOrEmpty(svnFile.ToString())) // throw new ArgumentException("svnFile"); // var startInfo = new ProcessStartInfo(); // startInfo.FileName = GetTortoiseProcPath(); // startInfo.Arguments = string.Format("/command:blame /path:{0} /startrev:0 /endrev:-1", svnFile.AbsoluteUri); // if (lineNumber.HasValue) // startInfo.Arguments += string.Format(" /line:{0}", lineNumber); // using (Process process = Process.Start(startInfo)) { // process.WaitForExit(); // } //} void PrepareBlameFileAndShowBlameUI(string filePath, int?lineNumber) { string blameFile = null; string logFile = null; try { IDXVcsRepository dxRepository = DXVcsConnectionHelper.Connect(portOptions.VcsServer); MergeHelper helper = new MergeHelper(options, portOptions); string vcsFile = helper.GetMergeVcsPathByOriginalPath(filePath, portOptions.MasterBranch); FileDiffInfo diffInfo = dxRepository.GetFileDiffInfo(vcsFile); int revision = diffInfo.LastRevision; IList <IBlameLine> blame = diffInfo.BlameAtRevision(revision); blameFile = MakeBlameFile(vcsFile, blame); logFile = MakeLog(blame); ShowExternalBlameInternal(filePath, vcsFile, blameFile, logFile, revision, lineNumber); } finally { blameFile.Do(File.Delete); logFile.Do(File.Delete); } }