protected override void Finished ()
			{
				dlg.EndCommit (success);
				dlg.Destroy ();
				FileUpdateEventArgs args = new FileUpdateEventArgs ();
				foreach (ChangeSetItem it in changeSet.Items)
					args.Add (new FileUpdateEventInfo (vc, it.LocalPath, it.IsDirectory));

				if (args.Count > 0)
					VersionControlService.NotifyFileStatusChanged (args);

				VersionControlService.NotifyAfterCommit (vc, changeSet, success);
			}
示例#2
0
        public async Task DeleteDirectoriesAsync(FilePath[] localPaths, bool force, ProgressMonitor monitor, bool keepLocal = true)
        {
            FileUpdateEventArgs args = new FileUpdateEventArgs();
            var metadata             = new DeleteMetadata(VersionControlSystem)
            {
                PathsCount = localPaths.Length, Force = force, KeepLocal = keepLocal
            };

            using (var tracker = Instrumentation.DeleteCounter.BeginTiming(metadata, monitor.CancellationToken)) {
                try {
                    await OnDeleteDirectoriesAsync(localPaths, force, monitor, keepLocal).ConfigureAwait(false);

                    foreach (var path in localPaths)
                    {
                        args.Add(new FileUpdateEventInfo(this, path, true));
                    }
                } catch (Exception e) {
                    LoggingService.LogError("Failed to delete directory", e);
                    metadata.SetFailure();
                    if (!keepLocal)
                    {
                        try {
                            foreach (var path in localPaths)
                            {
                                FileService.AssertCanDeleteDirectory(path, RootPath);
                                Directory.Delete(path, true);
                            }
                        } catch (Exception e2) {
                            LoggingService.LogInternalError(e2);
                        }
                    }
                }
            }
            ClearCachedVersionInfo(localPaths);
            if (args.Any())
            {
                VersionControlService.NotifyFileStatusChanged(args);
            }
        }
        //static void OnFileChanged (object s, ProjectFileEventArgs args)
        //{
        //	Repository repo = GetRepository (args.Project);
        //	if (repo != null)
        //		NotifyFileStatusChanged (repo, args.ProjectFile.FilePath, false);
        //}

        static void OnFileAdded(object s, ProjectFileEventArgs e)
        {
            FileUpdateEventArgs vargs   = new FileUpdateEventArgs();
            ProgressMonitor     monitor = null;

            try {
                foreach (var repoFiles in e.GroupBy(i => i.Project))
                {
                    Repository repo = GetRepository(repoFiles.Key);
                    if (repo == null)
                    {
                        continue;
                    }
                    var        filePaths    = repoFiles.Where(ShouldAddFile).Select(f => f.ProjectFile.FilePath);
                    var        versionInfos = repo.GetVersionInfo(filePaths, VersionInfoQueryFlags.IgnoreCache);
                    FilePath[] paths        = versionInfos.Where(i => i.CanAdd).Select(i => i.LocalPath).ToArray();
                    if (paths.Length > 0)
                    {
                        if (monitor == null)
                        {
                            monitor = GetStatusMonitor();
                        }
                        repo.Add(paths, false, monitor);
                    }
                    vargs.AddRange(repoFiles.Select(i => new FileUpdateEventInfo(repo, i.ProjectFile.FilePath, i.ProjectFile.Subtype == Subtype.Directory)));
                }
            }
            finally {
                if (monitor != null)
                {
                    monitor.Dispose();
                }
            }
            if (vargs.Count > 0)
            {
                NotifyFileStatusChanged(vargs);
            }
        }
示例#4
0
        public void SetStatus(IEnumerable <VersionInfo> versionInfos)
        {
            FileUpdateEventArgs args = null;

            try {
                fileLock.EnterWriteLock();
                foreach (var versionInfo in versionInfos)
                {
                    if (!versionInfo.IsInitialized)
                    {
                        versionInfo.Init(repo);
                    }
                    VersionInfo vi;
                    if (fileStatus.TryGetValue(versionInfo.LocalPath, out vi) && vi.Equals(versionInfo))
                    {
                        vi.RequiresRefresh = false;
                        continue;
                    }
                    fileStatus [versionInfo.LocalPath] = versionInfo;
                    var a = new FileUpdateEventArgs(repo, versionInfo.LocalPath, versionInfo.IsDirectory);
                    if (args == null)
                    {
                        args = a;
                    }
                    else
                    {
                        args.MergeWith(a);
                    }
                }
            } finally {
                fileLock.ExitWriteLock();
            }
            if (args != null)
            {
                //	Console.WriteLine ("Notifying Status " + string.Join (", ", args.Select (p => p.FilePath.FullPath)));
                VersionControlService.NotifyFileStatusChanged(args);
            }
        }
示例#5
0
        public async Task SetStatusAsync(IEnumerable <VersionInfo> versionInfos, CancellationToken cancellationToken = default)
        {
            FileUpdateEventArgs args = null;

            foreach (var versionInfo in versionInfos)
            {
                if (!versionInfo.IsInitialized)
                {
                    await versionInfo.InitAsync(repo, cancellationToken);
                }

                if (fileStatus.TryGetValue(versionInfo.LocalPath, out var vi) && vi.Equals(versionInfo))
                {
                    vi.RequiresRefresh = false;
                    continue;
                }

                fileStatus [versionInfo.LocalPath] = versionInfo;

                var a = new FileUpdateEventArgs(repo, versionInfo.LocalPath, versionInfo.IsDirectory);
                if (args == null)
                {
                    args = a;
                }
                else
                {
                    args.MergeWith(a);
                }
            }

            if (args != null)
            {
                //	Console.WriteLine ("Notifying Status " + string.Join (", ", args.Select (p => p.FilePath.FullPath)));
                VersionControlService.NotifyFileStatusChanged(args);
            }
        }
示例#6
0
            protected override void Finished()
            {
                dlg.EndCommit(success);
                dlg.Dispose();
                VersionControlService.NotifyAfterCommit(vc, changeSet, success);
                ArrayList dirs  = new ArrayList();
                ArrayList files = new ArrayList();

                foreach (ChangeSetItem it in changeSet.Items)
                {
                    if (it.IsDirectory)
                    {
                        dirs.Add(it.LocalPath);
                    }
                    else
                    {
                        files.Add(it.LocalPath);
                    }
                }

                FileUpdateEventArgs args = new FileUpdateEventArgs();

                foreach (FilePath path in dirs)
                {
                    args.Add(new FileUpdateEventInfo(vc, path, true));
                }
                foreach (FilePath path in files)
                {
                    args.Add(new FileUpdateEventInfo(vc, path, false));
                }

                if (args.Count > 0)
                {
                    VersionControlService.NotifyFileStatusChanged(args);
                }
            }
		void ClearAllCaches (FileUpdateEventArgs args)
		{
			foreach (var dir in args.GroupByDirectory ()) {
				if (dir.Count () > 3 || dir.Any (f => f.IsDirectory)) {
					ClearDirCache (dir.Key.CanonicalPath);
					continue;
				} else {
					// All files, clear the cached version info for each file, if exists
					foreach (FileUpdateEventInfo uinfo in dir) {
						FilePath path = uinfo.FilePath.ParentDirectory;
						if (path.IsNullOrEmpty)
							continue;
							
						DirData dd;
						if (filePaths.TryGetValue (path.CanonicalPath, out dd) && dd.FileData != null)
							dd.FileData.Remove (uinfo.FilePath.CanonicalPath);
					}
				}
			}
		}
		//static void OnFileChanged (object s, ProjectFileEventArgs args)
		//{
		//	Repository repo = GetRepository (args.Project);
		//	if (repo != null)
		//		NotifyFileStatusChanged (repo, args.ProjectFile.FilePath, false);
		//}

		static void OnFileAdded (object s, ProjectFileEventArgs e)
		{
			FileUpdateEventArgs vargs = new FileUpdateEventArgs ();
			IProgressMonitor monitor = null;
			try {
				foreach (var repoFiles in e.GroupBy (i => i.Project)) {
					Repository repo = GetRepository (repoFiles.Key);
					if (repo == null)
						continue;
					var versionInfos = repo.GetVersionInfo (repoFiles.Select (f => f.ProjectFile.FilePath));
					FilePath[] paths = versionInfos.Where (i => i.CanAdd).Select (i => i.LocalPath).ToArray ();
					if (paths.Length > 0) {
						if (monitor == null)
							monitor = GetStatusMonitor ();
						repo.Add (paths, false, monitor);
					}
					vargs.AddRange (repoFiles.Select (i => new FileUpdateEventInfo (repo, i.ProjectFile.FilePath, i.ProjectFile.Subtype == Subtype.Directory)));
				}
			}
			finally {
				if (monitor != null)
					monitor.Dispose ();
			}
			if (vargs.Count > 0)
				NotifyFileStatusChanged (vargs);
		}
		public static void NotifyFileStatusChanged (FileUpdateEventArgs args) 
		{
			if (!DispatchService.IsGuiThread)
				Gtk.Application.Invoke (delegate {
					NotifyFileStatusChanged (args);
				});
			else {
				if (FileStatusChanged != null)
					FileStatusChanged (null, args);
			}
		}
		public static void NotifyFileStatusChanged (IEnumerable<VersionControlItem> items) 
		{
			FileUpdateEventArgs vargs = new FileUpdateEventArgs ();
			vargs.AddRange (items.Select (i => new FileUpdateEventInfo (i.Repository, i.Path, i.IsDirectory)));
			NotifyFileStatusChanged (vargs);
		}
		void Monitor (object sender, FileUpdateEventArgs args)
		{
			foreach (FileUpdateEventInfo uinfo in args) {
				foreach (var ob in GetObjectsForPath (uinfo.FilePath)) {
					ITreeBuilder builder = Context.GetTreeBuilder (ob);
					if (builder != null)
						builder.Update();
				}
			}
		}
示例#12
0
			protected override void Finished ()
			{
				dlg.EndCommit (success);
				dlg.Dispose ();
				VersionControlService.NotifyAfterCommit (vc, changeSet, success);
				ArrayList dirs = new ArrayList ();
				ArrayList files = new ArrayList ();
				foreach (ChangeSetItem it in changeSet.Items)
					if (it.IsDirectory) dirs.Add (it.LocalPath);
					else files.Add (it.LocalPath);
				
				FileUpdateEventArgs args = new FileUpdateEventArgs ();
				
				foreach (FilePath path in dirs)
					args.Add (new FileUpdateEventInfo (vc, path, true));
				foreach (FilePath path in files)
					args.Add (new FileUpdateEventInfo (vc, path, false));
				
				if (args.Count > 0)
					VersionControlService.NotifyFileStatusChanged (args);
			}
示例#13
0
 void Monitor(object sender, FileUpdateEventArgs args)
 {
     ClearAllCaches(args);
     UpdateAll(args);
 }
		void Monitor (object sender, FileUpdateEventArgs args)
		{
			if (args.IsDirectory) {
				FilePath path = args.FilePath.CanonicalPath;
				DirData dd;
				if (filePaths.TryGetValue (path, out dd)) {
					dd.FileData = null; // Clear the status cache
					ITreeBuilder builder = Context.GetTreeBuilder (dd.Object);
					if (builder != null)
						builder.UpdateAll();
				}
			} else {
				// If it's a file, clear the cached version info for the file, if exists
				FilePath path = args.FilePath.ParentDirectory;
				DirData dd;
				if (filePaths.TryGetValue (path.CanonicalPath, out dd) && dd.FileData != null) {
					dd.FileData.Remove (args.FilePath.CanonicalPath);
				}
				if (filePaths.TryGetValue (args.FilePath.CanonicalPath, out dd)) {
					ITreeBuilder builder = Context.GetTreeBuilder (dd.Object);
					if (builder != null)
						builder.UpdateAll();
				}
			}
		}
		public override void NotifyFilesChanged (IEnumerable<FilePath> files)
		{
			FileUpdateEventArgs args = new FileUpdateEventArgs ();
			args.AddRange (files.Select (f => {
				var rep = GetRepository (f);
				rep.ClearCachedVersionInfo (f);
				return new FileUpdateEventInfo (rep, f, false);
			}));
			VersionControlService.NotifyFileStatusChanged (args);
		}
		public override void NotifyFilesChanged (IEnumerable<FilePath> files)
		{
			FileUpdateEventArgs args = new FileUpdateEventArgs ();
			args.AddRange (files.Select (f => new FileUpdateEventInfo (GetRepository (f), f, false)));
			VersionControlService.NotifyFileStatusChanged (args);
		}
		public override void NotifyFilesChanged (IEnumerable<FilePath> files)
		{
			FileUpdateEventArgs args = new FileUpdateEventArgs ();
			foreach (var file in files) {
				var rep = GetRepository (file);
				if (rep != null) {
					rep.ClearCachedVersionInfo (file);
					args.Add (new FileUpdateEventInfo (rep, file, false));
				}
			}
			VersionControlService.NotifyFileStatusChanged (args);
		}
		void UpdateAll (FileUpdateEventArgs args)
		{
			foreach (var dir in args.GroupByDirectory ()) {
				if (dir.Count () > 3 || dir.Any (f => f.IsDirectory)) {
					UpdatePath (dir.Key.CanonicalPath);
					continue;
				}
				else
					foreach (FileUpdateEventInfo uinfo in dir)
						UpdatePath (uinfo.FilePath.CanonicalPath);
			}
		}
		void Monitor (object sender, FileUpdateEventArgs args)
		{
			ClearAllCaches (args);
			UpdateAll (args);
		}
		public static void NotifyFileStatusChanged (FileUpdateEventArgs args) 
		{
			if (!Runtime.IsMainThread)
				Gtk.Application.Invoke (delegate {
					NotifyFileStatusChanged (args);
				});
			else {
				if (FileStatusChanged != null)
					FileStatusChanged (null, args);
			}
		}
		public void SetStatus (IEnumerable<VersionInfo> versionInfos)
		{
			FileUpdateEventArgs args = null;
			lock (fileStatus) {
				foreach (var versionInfo in versionInfos) {
					VersionInfo vi;
					if (fileStatus.TryGetValue (versionInfo.LocalPath, out vi) && vi.Equals (versionInfo)) {
						vi.RequiresRefresh = false;
						continue;
					}
					versionInfo.Init (repo);
					fileStatus [versionInfo.LocalPath] = versionInfo;
					var a = new FileUpdateEventArgs (repo, versionInfo.LocalPath, versionInfo.IsDirectory);
					if (args == null)
						args = a;
					else
						args.MergeWith (a);
				}
			}
			if (args != null) {
			//	Console.WriteLine ("Notifying Status " + string.Join (", ", args.Select (p => p.FilePath.FullPath)));
				VersionControlService.NotifyFileStatusChanged (args);
			}
		}
		void Monitor (object sender, FileUpdateEventArgs args)
		{
			foreach (var dir in args.GroupByDirectory ()) {
				if (dir.Count () > 3 || dir.Any (f => f.IsDirectory)) {
					FilePath path = dir.Key.CanonicalPath;
					DirData dd;
					if (filePaths.TryGetValue (path, out dd)) {
						dd.FileData = null; // Clear the status cache
						ITreeBuilder builder = Context.GetTreeBuilder (dd.Object);
						if (builder != null)
							builder.UpdateAll();
					}
					continue;
				}
				else {
					// All files, clear the cached version info for each file, if exists
					foreach (FileUpdateEventInfo uinfo in dir) {
						FilePath path = uinfo.FilePath.ParentDirectory;
						DirData dd;
						if (filePaths.TryGetValue (path.CanonicalPath, out dd) && dd.FileData != null) {
							dd.FileData.Remove (uinfo.FilePath.CanonicalPath);
						}
						if (filePaths.TryGetValue (uinfo.FilePath.CanonicalPath, out dd)) {
							ITreeBuilder builder = Context.GetTreeBuilder (dd.Object);
							if (builder != null)
								builder.UpdateAll();
						}
					}
				}
			}
		}
		void Monitor (object sender, FileUpdateEventArgs args)
		{
			object obj;
			if (filePaths.TryGetValue (args.FilePath, out obj)) {
				ITreeBuilder builder = Context.GetTreeBuilder (obj);
				if (builder != null)
					builder.UpdateAll();
			}
		}