Example #1
0
        public override bool RequestFileWritePermission(FilePath path)
        {
            if (!File.Exists(path))
            {
                return(true);
            }
            if ((File.GetAttributes(path) & FileAttributes.ReadOnly) == 0)
            {
                return(true);
            }
            AlertButton but = new AlertButton("Lock File");

            if (!MessageService.Confirm(GettextCatalog.GetString("File locking required"), GettextCatalog.GetString("The file '{0}' must be locked before editing.", path), but))
            {
                return(false);
            }
            try {
                Svn.Lock(null, "", false, path);
            } catch (SubversionException ex) {
                MessageService.ShowError(GettextCatalog.GetString("The file '{0}' could not be unlocked", path), ex.Message);
                return(false);
            }
            VersionControlService.NotifyFileStatusChanged(new FileUpdateEventArgs(this, path, false));
            return(true);
        }
 public void Resolve(FilePath[] localPaths, bool recurse, IProgressMonitor monitor)
 {
     Svn.Resolve(localPaths, recurse, monitor);
     foreach (string path in localPaths)
     {
         VersionControlService.NotifyFileStatusChanged(this, path, Directory.Exists(path));
     }
 }
Example #3
0
        public void Resolve(FilePath[] localPaths, bool recurse, IProgressMonitor monitor)
        {
            Svn.Resolve(localPaths, recurse, monitor);
            FileUpdateEventArgs args = new FileUpdateEventArgs();

            foreach (var path in localPaths)
            {
                args.Add(new FileUpdateEventInfo(this, path, Directory.Exists(path)));
            }
            VersionControlService.NotifyFileStatusChanged(args);
        }
Example #4
0
            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);
            }
        public override bool RequestFileWritePermission(params FilePath [] paths)
        {
            var toLock = new List <FilePath>();

            foreach (var path in paths)
            {
                if (!File.Exists(path))
                {
                    continue;
                }
                if (!TryGetVersionInfo(path, out var info))
                {
                    continue;
                }
                if (!info.IsVersioned || !Svn.HasNeedLock(path) || (File.GetAttributes(path) & FileAttributes.ReadOnly) == 0)
                {
                    continue;
                }
                toLock.Add(path);
            }

            if (toLock.Count == 0)
            {
                return(true);
            }

            AlertButton but = new AlertButton(GettextCatalog.GetString("Lock File"));

            if (!MessageService.Confirm(GettextCatalog.GetString("The following files must be locked before editing."),
                                        String.Join("\n", toLock.Select(u => u.ToString())), but))
            {
                return(false);
            }

            try {
                Svn.Lock(null, "", false, toLock.ToArray());
            } catch (SubversionException ex) {
                MessageService.ShowError(GettextCatalog.GetString("File could not be unlocked."), ex.Message);
                return(false);
            }

            VersionControlService.NotifyFileStatusChanged(new FileUpdateEventArgs(this, toLock.ToArray()));
            return(true);
        }
Example #6
0
        public override void Add(FilePath[] paths, bool recurse, IProgressMonitor monitor)
        {
            foreach (FilePath path in paths)
            {
                if (IsVersioned(path) && File.Exists(path) && !Directory.Exists(path))
                {
                    if (rootPath == null)
                    {
                        throw new UserException(GettextCatalog.GetString("Project publishing failed. There is a stale .svn folder in the path '{0}'", path.ParentDirectory));
                    }
                    VersionInfo srcInfo = GetVersionInfo(path, false);
                    if (srcInfo.HasLocalChange(VersionStatus.ScheduledDelete))
                    {
                        // It is a file that was deleted. It can be restored now since it's going
                        // to be added again.
                        // First of all, make a copy of the file
                        string tmp = Path.GetTempFileName();
                        File.Copy(path, tmp, true);

                        // Now revert the status of the file
                        Revert(path, false, monitor);

                        // Copy the file over the old one and clean up
                        File.Copy(tmp, path, true);
                        File.Delete(tmp);
                    }
                }
                else
                {
                    if (File.Exists(path) && !IsVersioned(path.ParentDirectory))
                    {
                        // The file belongs to an unversioned folder. We can add it by versioning the parent
                        // folders up to the root of the repository

                        if (!path.IsChildPathOf(rootPath))
                        {
                            throw new InvalidOperationException("File outside the repository directory");
                        }

                        List <FilePath> dirChain  = new List <FilePath> ();
                        FilePath        parentDir = path.CanonicalPath;
                        do
                        {
                            parentDir = parentDir.ParentDirectory;
                            if (Directory.Exists(SubversionVersionControl.GetDirectoryDotSvn(parentDir)))
                            {
                                break;
                            }
                            dirChain.Add(parentDir);
                        }while (parentDir != rootPath);

                        // Found all parent unversioned dirs. Versin them now.
                        dirChain.Reverse();
                        FileUpdateEventArgs args = new FileUpdateEventArgs();
                        foreach (var d in dirChain)
                        {
                            Svn.Add(d, false, monitor);
                            args.Add(new FileUpdateEventInfo(this, dirChain [0], true));
                        }
                        VersionControlService.NotifyFileStatusChanged(args);
                    }
                    Svn.Add(path, recurse, monitor);
                }
            }
        }
        protected override async Task OnAddAsync(FilePath[] localPaths, bool recurse, ProgressMonitor monitor)
        {
            foreach (FilePath path in localPaths)
            {
                if (await IsVersionedAsync(path, monitor.CancellationToken).ConfigureAwait(false) && File.Exists(path) && !Directory.Exists(path))
                {
                    if (RootPath.IsNull)
                    {
                        throw new UserException(GettextCatalog.GetString("Project publishing failed. There is a stale .svn folder in the path '{0}'", path.ParentDirectory));
                    }
                    VersionInfo srcInfo = await GetVersionInfoAsync(path, VersionInfoQueryFlags.IgnoreCache).ConfigureAwait(false);

                    if (srcInfo.HasLocalChange(VersionStatus.ScheduledDelete))
                    {
                        // It is a file that was deleted. It can be restored now since it's going
                        // to be added again.
                        // First of all, make a copy of the file
                        string tmp = Path.GetTempFileName();
                        File.Copy(path, tmp, true);

                        // Now revert the status of the file
                        await RevertAsync(path, false, monitor).ConfigureAwait(false);

                        // Copy the file over the old one and clean up
                        File.Copy(tmp, path, true);
                        File.Delete(tmp);
                        continue;
                    }
                }
                else
                {
                    if (!await IsVersionedAsync(path.ParentDirectory, monitor.CancellationToken).ConfigureAwait(false))
                    {
                        // The file/folder belongs to an unversioned folder. We can add it by versioning the parent
                        // folders up to the root of the repository

                        if (!path.IsChildPathOf(RootPath))
                        {
                            throw new InvalidOperationException("File outside the repository directory");
                        }

                        List <FilePath> dirChain  = new List <FilePath> ();
                        FilePath        parentDir = path.CanonicalPath;
                        do
                        {
                            parentDir = parentDir.ParentDirectory;
                            if (await IsVersionedAsync(parentDir, monitor.CancellationToken).ConfigureAwait(false))
                            {
                                break;
                            }
                            dirChain.Add(parentDir);
                        }while (parentDir != RootPath);

                        // Found all parent unversioned dirs. Versin them now.
                        dirChain.Reverse();
                        FileUpdateEventArgs args = new FileUpdateEventArgs();
                        foreach (var d in dirChain)
                        {
                            Svn.Add(d, false, monitor);
                            args.Add(new FileUpdateEventInfo(this, d, true));
                        }
                        VersionControlService.NotifyFileStatusChanged(args);
                    }
                }
                Svn.Add(path, recurse, monitor);
            }
        }