예제 #1
0
        public bool CheckIn(SyncItem item, string comment)
        {
            if (item.State == ProcessState.Ignored)
                return true;

            switch (item.SyncAction) {
                case SyncAction.New:
                    return CheckInNewFile(item.VcsPath, item.LocalPath, comment);
                case SyncAction.Modify:
                    return CheckInChangedFile(item.VcsPath, item.LocalPath, comment);
                case SyncAction.Delete:
                    return CheckInDeletedFile(item.VcsPath, item.LocalPath, comment);
                case SyncAction.Move:
                    return CheckInMovedFile(item.VcsPath, item.NewVcsPath, item.LocalPath, item.NewLocalPath, comment);
                default:
                    throw new ArgumentException("SyncAction");
            }
        }
예제 #2
0
파일: Program.cs 프로젝트: Xarlot/DXVcs2Git
 static SyncItem ProcessMergeRequestChanges(MergeRequest mergeRequest, MergeRequestFileData fileData, string localGitDir, TrackBranch branch, string token) {
     string vcsRoot = branch.RepoRoot;
     var syncItem = new SyncItem();
     if (fileData.IsNew) {
         syncItem.SyncAction = SyncAction.New;
         syncItem.LocalPath = CalcLocalPath(localGitDir, branch, fileData.OldPath);
         syncItem.VcsPath = CalcVcsPath(branch, fileData.OldPath);
     }
     else if (fileData.IsDeleted) {
         syncItem.SyncAction = SyncAction.Delete;
         syncItem.LocalPath = CalcLocalPath(localGitDir, branch, fileData.OldPath);
         syncItem.VcsPath = CalcVcsPath(branch, fileData.OldPath);
     }
     else if (fileData.IsRenamed) {
         syncItem.SyncAction = SyncAction.Move;
         syncItem.LocalPath = CalcLocalPath(localGitDir, branch, fileData.OldPath);
         syncItem.NewLocalPath = CalcLocalPath(localGitDir, branch, fileData.NewPath);
         syncItem.VcsPath = CalcVcsPath(branch, fileData.OldPath);
         syncItem.NewVcsPath = CalcVcsPath(branch, fileData.NewPath);
     }
     else {
         syncItem.SyncAction = SyncAction.Modify;
         syncItem.LocalPath = CalcLocalPath(localGitDir, branch, fileData.OldPath);
         syncItem.VcsPath = CalcVcsPath(branch, fileData.OldPath);
     }
     syncItem.Comment = CalcComment(mergeRequest, branch, token);
     return syncItem;
 }
예제 #3
0
 public bool CheckOut(SyncItem item, string comment)
 {
     return CheckOutFile(item.VcsPath, item.LocalPath, true, comment);
 }
예제 #4
0
        TestFileResult ProcessCheckoutItem(SyncItem item, string comment)
        {
            if (item.State == ProcessState.Ignored)
                return TestFileResult.Ignore;

            switch (item.SyncAction) {
                case SyncAction.New:
                    return CheckOutCreateFile(item.VcsPath, item.LocalPath, comment) ? TestFileResult.Ok : TestFileResult.Fail;
                case SyncAction.Modify:
                    return CheckOutModifyFile(item.VcsPath, item.LocalPath, comment) ? TestFileResult.Ok : TestFileResult.Fail;
                case SyncAction.Delete:
                    return CheckOutDeleteFile(item.VcsPath, item.LocalPath, comment) ? TestFileResult.Ok : TestFileResult.Fail;
                case SyncAction.Move:
                    return CheckOutMoveFile(item.VcsPath, item.NewVcsPath, item.LocalPath, item.NewLocalPath, comment) ? TestFileResult.Ok : TestFileResult.Fail;
                default:
                    throw new ArgumentException("SyncAction");
            }
        }
예제 #5
0
 TestFileResult ProcessBeforeCheckout(SyncItem item, bool ignoreSharedFiles, TrackBranch branch)
 {
     TestFileResult result;
     switch (item.SyncAction) {
         case SyncAction.New:
             result = BeforeCheckOutCreateFile(item.VcsPath, item.LocalPath, ignoreSharedFiles, branch);
             break;
         case SyncAction.Modify:
             result = BeforeCheckOutModifyFile(item.VcsPath, item.LocalPath, ignoreSharedFiles, item.SingleSharedFile, branch);
             break;
         case SyncAction.Delete:
             result = BeforeCheckOutDeleteFile(item.VcsPath, item.LocalPath, ignoreSharedFiles, branch);
             break;
         case SyncAction.Move:
             SyncAction newAction = SyncAction.Move;
             result = BeforeCheckOutMoveFile(item.VcsPath, item.NewVcsPath, item.LocalPath, item.NewLocalPath, ignoreSharedFiles, branch, ref newAction);
             item.SyncAction = newAction;
             break;
         default:
             throw new ArgumentException("SyncAction");
     }
     return result;
 }
예제 #6
0
 void CheckIsSingleSharedFile(IEnumerable<SyncItem> files, SyncItem sharedFile)
 {
     try {
         var repo = DXVcsConnectionHelper.Connect(server, this.user, this.password);
         var liveLinks = repo.GetLiveLinks(sharedFile.VcsPath);
         int conflicts = 0;
         foreach (var liveLink in liveLinks) {
             if (files.Any(x => x.VcsPath == liveLink.Path)) {
                 conflicts = conflicts + 1;
             }
         }
         sharedFile.SharedFile = true;
         sharedFile.SingleSharedFile = conflicts < 2;
     }
     catch (Exception ex) {
         Log.Error("Check shared file status failure.", ex);
         throw ex;
     }
 }
예제 #7
0
 public bool RollbackItem(SyncItem item)
 {
     if (item.State == ProcessState.Default)
         return true;
     return UndoCheckoutFile(item.VcsPath, item.LocalPath);
 }