Example #1
0
 public bool Update(int revision, IEnumerable <string> assets = null)
 {
     return(HandleExceptions(() =>
     {
         var beforeStatus = StoreCurrentStatus(assets);
         if (!OnOperationStarting(OperationType.Update, beforeStatus))
         {
             return false;
         }
         updating = true;
         bool updateResult = vcc.Update(revision, assets);
         updating = false;
         if (updateResult)
         {
             AssetDatabaseRefreshManager.RequestAssetDatabaseRefresh();
         }
         var afterStatus = StoreCurrentStatus(assets);
         OnOperationCompleted(OperationType.Update, beforeStatus, afterStatus, updateResult);
         if (updateResult)
         {
             Status(StatusLevel.Local, DetailLevel.Normal);
         }
         return updateResult;
     }, () => OnOperationCompleted(OperationType.Update, null, null, false)));
 }
Example #2
0
 public bool Delete(IEnumerable <string> assets, OperationMode mode = OperationMode.Force)
 {
     return(HandleExceptions(() =>
     {
         var beforeStatus = StoreCurrentStatus(assets);
         if (!OnOperationStarting(OperationType.Delete, beforeStatus))
         {
             return false;
         }
         bool filesOSDeleted = false;
         var deleteAssets = new List <string>();
         foreach (string assetIt in assets)
         {
             var metaAsset = assetIt + VCCAddMetaFiles.metaStr;
             if (GetAssetStatus(assetIt).fileStatus != VCFileStatus.Unversioned)
             {
                 deleteAssets.Add(metaAsset);
                 deleteAssets.Add(assetIt);
             }
             else
             {
                 if (File.Exists(metaAsset))
                 {
                     File.SetAttributes(metaAsset, FileAttributes.Normal);
                     File.Delete(metaAsset);
                     filesOSDeleted = true;
                 }
                 if (File.Exists(assetIt))
                 {
                     File.SetAttributes(assetIt, FileAttributes.Normal);
                     File.Delete(assetIt);
                     filesOSDeleted = true;
                 }
                 if (Directory.Exists(assetIt))
                 {
                     foreach (var subDirFile in Directory.GetFiles(assetIt, "*", SearchOption.AllDirectories))
                     {
                         File.SetAttributes(subDirFile, FileAttributes.Normal);
                         File.Delete(subDirFile);
                     }
                     Directory.Delete(assetIt, true);
                     filesOSDeleted = true;
                 }
             }
         }
         bool result = vcc.Delete(deleteAssets, mode);
         AssetDatabaseRefreshManager.RequestAssetDatabaseRefresh();
         if (filesOSDeleted)
         {
             AssetDatabaseRefreshManager.RefreshAssetDatabase();
         }
         var afterStatus = StoreCurrentStatus(assets);
         OnOperationCompleted(OperationType.Delete, beforeStatus, afterStatus, result || filesOSDeleted);
         return result;
     }));
 }
Example #3
0
 public bool Move(string from, string to)
 {
     return(HandleExceptions(() =>
     {
         FlushFiles();
         var beforeStatus = new[] { GetAssetStatus(from) };
         if (!OnOperationStarting(OperationType.Move, beforeStatus))
         {
             return false;
         }
         bool moveSuccess = vcc.Move(from, to);
         AssetDatabaseRefreshManager.RequestAssetDatabaseRefresh();
         OnOperationCompleted(OperationType.Move, beforeStatus, new[] { GetAssetStatus(to) }, moveSuccess);
         return moveSuccess;
     }));
 }
Example #4
0
 public bool Resolve(IEnumerable <string> assets, ConflictResolution conflictResolution)
 {
     return(HandleExceptions(() =>
     {
         var beforeStatus = StoreCurrentStatus(assets);
         if (!OnOperationStarting(OperationType.Resolve, beforeStatus))
         {
             return false;
         }
         bool resolveSuccess = vcc.Resolve(assets, conflictResolution);
         if (conflictResolution == ConflictResolution.Mine)
         {
             vcc.SetLocalOnly(assets.Where(asset => !MergeHandler.IsMergableAsset(asset)));
         }
         var afterStatus = StoreCurrentStatus(assets);
         AssetDatabaseRefreshManager.RequestAssetDatabaseRefresh();
         OnOperationCompleted(OperationType.Resolve, beforeStatus, afterStatus, resolveSuccess);
         return resolveSuccess;
     }));
 }
Example #5
0
 public bool Revert(IEnumerable <string> assets)
 {
     return(HandleExceptions(() =>
     {
         FlushFiles();
         //assets = assets.Concat(assets.Select(vcc.GetAssetStatus).Where(status => !ComposedString.IsNullOrEmpty(status.movedFrom)).Select(status => status.movedFrom.Compose()) ).ToArray();
         Status(assets, StatusLevel.Local);
         var beforeStatus = StoreCurrentStatus(assets);
         if (!OnOperationStarting(OperationType.Revert, beforeStatus))
         {
             return false;
         }
         bool revertSuccess = vcc.Revert(assets);
         Status(assets, StatusLevel.Local);
         AssetDatabaseRefreshManager.RequestAssetDatabaseRefresh();
         if (revertSuccess)
         {
             AssetDatabaseRefreshManager.RefreshAssetDatabase();
         }
         var afterStatus = StoreCurrentStatus(assets);
         OnOperationCompleted(OperationType.Revert, beforeStatus, afterStatus, revertSuccess);
         return revertSuccess;
     }));
 }