Esempio n. 1
0
        public void CompareWithCurrentVersion(string filePath)
        {
            IDXVcsRepository repository      = DXVcsRepositoryFactory.Create(Port.VcsServer);
            string           vcsOriginalPath = Port.GetRelativePath(filePath);

            PreviewTarget(repository, vcsOriginalPath, filePath);
        }
Esempio n. 2
0
        public void CompareWithHistoryVersion(string filePath, int leftVersion = 0, int rightVersion = 0, bool compareWithCurrent = true)
        {
            IDXVcsRepository repository      = DXVcsRepositoryFactory.Create(Port.VcsServer);
            string           vcsOriginalPath = Port.GetRelativePath(filePath);

            PreviewTarget(repository, filePath, vcsOriginalPath, leftVersion, rightVersion, compareWithCurrent);
        }
Esempio n. 3
0
        public bool CheckIn(CheckInViewModel checkInViewModel, DXVcsBranch targetBranch, bool isNew)
        {
            Logger.AddInfo("CheckInCommand. Perform checkin file: " + checkInViewModel.FilePath);
            try {
                IDXVcsRepository repository      = DXVcsRepositoryFactory.Create(Port.VcsServer);
                string           filePath        = GetFilePathForBranch(checkInViewModel.FilePath, targetBranch);
                string           vcsOriginalPath = GetMergeVcsPathByTargetPath(filePath, targetBranch);

                if (isNew)
                {
                    repository.AddFile(vcsOriginalPath, File.ReadAllBytes(filePath), checkInViewModel.Comment);
                }
                else
                {
                    repository.CheckInFile(vcsOriginalPath, filePath, checkInViewModel.Comment);
                }
                if (checkInViewModel.StaysChecked)
                {
                    repository.CheckOutFile(vcsOriginalPath, filePath, checkInViewModel.Comment);
                }
            }
            catch (Exception e) {
                Logger.AddError("CheckInCommand. CheckIn failed.", e);
                return(false);
            }
            return(true);
        }
Esempio n. 4
0
        public static IDXVcsRepository Connect(string vcsService)
        {
            if (string.IsNullOrEmpty(vcsService))
            {
                throw new ArgumentException("vcsService");
            }

            return(DXVcsRepositoryFactory.Create(vcsService));
        }
Esempio n. 5
0
 public IEnumerable <string> FindWorkingFolders(List <DXVcsBranch> branches)
 {
     try {
         IDXVcsRepository repository = DXVcsRepositoryFactory.Create(Port.VcsServer);
         return(branches.Select(branch => repository.GetFileWorkingPath(branch.Path)).ToList());
     }
     catch (Exception e) {
         Logger.AddError("GetFilePathForBranch failed.", e);
     }
     return(null);
 }
Esempio n. 6
0
 public void CompareWithPortVersion(string filePath, DXVcsBranch current)
 {
     try {
         IDXVcsRepository repository    = DXVcsRepositoryFactory.Create(Port.VcsServer);
         string           vcsTargetPath = GetMergeVcsPathByOriginalPath(filePath, current);
         PreviewTarget(repository, vcsTargetPath, repository.GetFileWorkingPath(vcsTargetPath));
     }
     catch (Exception e) {
         DXMessageBox.Show(e.Message);
     }
 }
Esempio n. 7
0
        public MergeState MergeChanges(DXVcsBranch currentBranch, string filePath, string mergePath, bool showPreview)
        {
            try {
                IDXVcsRepository repository      = DXVcsRepositoryFactory.Create(Port.VcsServer);
                string           tmpOriginalFile = Path.GetTempFileName();

                string vcsOriginalPath = Port.GetRelativePath(filePath);
                string vcsTargetFile   = mergePath == null?GetMergeVcsPathByOriginalPath(filePath, currentBranch) : Port.GetRelativePath(mergePath, currentBranch);

                try {
                    repository.GetLatestVersion(vcsOriginalPath, tmpOriginalFile);
                    string tmpTargetFile = string.Empty;
                    try {
                        tmpTargetFile = repository.GetFileWorkingPath(vcsTargetFile);
                    }
                    catch (Exception e) {
                        Logger.AddError("MergeCommand. Target file error.", e);
                        return(MergeState.TargetFileError);
                    }
                    if (string.IsNullOrEmpty(tmpTargetFile))
                    {
                        Logger.AddError("MergeCommand. Target file path is empty.");
                        return(MergeState.TargetFileError);
                    }

                    try {
                        repository.CheckOutFile(vcsTargetFile, tmpTargetFile, string.Empty);
                    }
                    catch (Exception e) {
                        Logger.AddError("MergeCommand. Check out file error.", e);
                        return(MergeState.CheckOutFileError);
                    }


                    var diff = new FileDiff();
                    if (!diff.Merge(tmpOriginalFile, filePath, tmpTargetFile))
                    {
                        return(MergeState.Conflict);
                    }
                    if (showPreview)
                    {
                        PreviewTarget(repository, vcsTargetFile, tmpTargetFile);
                    }
                }
                finally {
                    File.Delete(tmpOriginalFile);
                }
            }
            catch {
                return(MergeState.UnknownError);
            }
            return(MergeState.Success);
        }
Esempio n. 8
0
 public string GetFilePathForBranch(string path, DXVcsBranch currentBranch)
 {
     try {
         string           relativePath = GetMergeVcsPathByOriginalPath(path, currentBranch);
         IDXVcsRepository repository   = DXVcsRepositoryFactory.Create(Port.VcsServer);
         return(repository.GetFileWorkingPath(relativePath));
     }
     catch (Exception e) {
         Logger.AddError("GetFilePathForBranch failed.", e);
     }
     return(string.Empty);
 }
Esempio n. 9
0
 public bool IsItemUnderVss(string filePath, DXVcsBranch current)
 {
     try {
         string           vcsTargetPath = GetMergeVcsPathByOriginalPath(filePath, current);
         IDXVcsRepository repository    = DXVcsRepositoryFactory.Create(Port.VcsServer);
         return(repository.IsUnderVss(vcsTargetPath));
     }
     catch (Exception e) {
         Logger.AddError("IsItemUnderVss failed.", e);
     }
     return(true);
 }
Esempio n. 10
0
        string GetProjectPath(DXVcsBranch currentBranch)
        {
            if (currentBranch == MasterBranch)
            {
                return(ProjectFilePath);
            }
            string           vcsPath = GetRelativePath(ProjectFilePath);
            string           vcsTargetProjectPath = vcsPath.Replace(MasterBranch.Path, currentBranch.Path);
            IDXVcsRepository repository           = DXVcsRepositoryFactory.Create(VcsServer);

            //bug - project file path returns as directory path
            return(FindRootProject(repository, repository.GetFileWorkingPath(vcsTargetProjectPath)));
        }
Esempio n. 11
0
 public void NavigateToSolution(DXVcsBranch currentBranch, IDteWrapper dte)
 {
     try {
         string           filePath    = Port.ProjectFilePath;
         string           vcsFilePath = GetMergeVcsPathByOriginalPath(filePath, currentBranch);
         IDXVcsRepository repository  = DXVcsRepositoryFactory.Create(Port.VcsServer);
         string           targetPath  = repository.GetFileWorkingPath(vcsFilePath);
         dte.OpenSolution(targetPath);
     }
     catch {
         MessageBox.Show("Can`t navigate to solution");
     }
 }
Esempio n. 12
0
        public MergeState ManualMerge(DXVcsBranch currentBranch, ManualMergeViewModel mergeModel, Func <bool> showManualMergeUIHandler)
        {
            try {
                string           filePath   = mergeModel.OriginalFilePath;
                string           mergePath  = mergeModel.TargetFilePath;
                IDXVcsRepository repository = DXVcsRepositoryFactory.Create(Port.VcsServer);

                string vcsTargetFile = mergePath == null?GetMergeVcsPathByOriginalPath(filePath, currentBranch) : GetMergeVcsPathByTargetPath(mergePath, currentBranch);

                string tmpTargetFile = repository.GetFileWorkingPath(vcsTargetFile);
                mergeModel.TargetFilePath = tmpTargetFile;

                if (!showManualMergeUIHandler())
                {
                    Logger.AddInfo("ManualMergeCommand. Result = MergeState.None.");
                    return(MergeState.None);
                }

                vcsTargetFile = GetMergeVcsPathByTargetPath(mergeModel.TargetFilePath, currentBranch);
                string tmpOriginalFile = mergeModel.OriginalFilePath;
                tmpTargetFile = repository.GetFileWorkingPath(vcsTargetFile);
                if (string.IsNullOrEmpty(tmpTargetFile))
                {
                    Logger.AddInfo("ManualMergeCommand. Result = MergeState.TargetFileError.");
                    return(MergeState.TargetFileError);
                }

                repository.CheckOutFile(vcsTargetFile, tmpTargetFile, string.Empty);
                if (MergeFileHelper.IsBinaryFile(tmpTargetFile))
                {
                    if (OverwriteFile.Write(tmpOriginalFile, tmpTargetFile))
                    {
                        return(MergeState.Success);
                    }
                    else
                    {
                        return(MergeState.Conflict);
                    }
                }
                LaunchDiffTool(tmpOriginalFile, tmpTargetFile);
            }
            catch (Exception e) {
                Logger.AddError("ManualMergeCommand. Unknown error.", e);
                Logger.AddInfo("ManualMergeCommand. Result = MergeState.UnknownError.");
                return(MergeState.UnknownError);
            }
            Logger.AddInfo("ManualMergeCommand. Result = MergeState.Success");
            return(MergeState.Success);
        }
Esempio n. 13
0
        public bool UndoCheckout(string filePath)
        {
            string vcsFilePath = Port.GetRelativePath(filePath);

            try {
                IDXVcsRepository repository = DXVcsRepositoryFactory.Create(Port.VcsServer);
                repository.UndoCheckout(vcsFilePath, filePath);
                repository.GetLatestVersion(vcsFilePath, filePath);
                FileInfo info = new FileInfo(filePath);
                info.IsReadOnly = true;
            }
            catch {
                return(true);
            }
            return(false);
        }
Esempio n. 14
0
 public void CompareCurrentWithPortVersion(string filePath, DXVcsBranch current)
 {
     try {
         IDXVcsRepository repository    = DXVcsRepositoryFactory.Create(Port.VcsServer);
         string           vcsTargetPath = GetMergeVcsPathByOriginalPath(filePath, current);
         if (!repository.IsUnderVss(vcsTargetPath))
         {
             DXMessageBox.Show("Target is not under vss");
             return;
         }
         string fileTargetPath = repository.GetFileWorkingPath(vcsTargetPath);
         PreviewTarget(repository, fileTargetPath, vcsTargetPath, filePath, false);
     }
     catch (Exception e) {
         DXMessageBox.Show(e.Message);
     }
 }