コード例 #1
0
        public void Move_MultiMove()
        {
            SvnSandBox sbox = new SvnSandBox(this);

            sbox.Create(SandBoxRepository.Empty);
            string WcPath = sbox.Wc;

            using (SvnClient client = NewSvnClient(true, false))
            {
                string ren1 = Path.Combine(WcPath, "ren-1");

                using (StreamWriter sw = File.CreateText(ren1))
                {
                    sw.WriteLine("ToRename");
                }
                client.Add(ren1);
                client.Commit(WcPath);
                client.Update(WcPath);

                using (StreamWriter sw = File.AppendText(ren1))
                {
                    sw.WriteLine("AddedLine");
                }
                client.Move(ren1, ren1 + ".ren1");

                client.Commit(WcPath);

                client.Move(ren1 + ".ren1", ren1 + ".ren2");
                SvnMoveArgs ma = new SvnMoveArgs();
                ma.Force = true;
                client.Move(ren1 + ".ren2", ren1 + ".ren3", ma);
                client.Commit(WcPath);
            }
        }
コード例 #2
0
ファイル: RenameNode.cs プロジェクト: windygu/AnkhSVN
        public override void OnExecute(CommandEventArgs e)
        {
            ISvnRepositoryItem item = EnumTools.GetSingle(e.Selection.GetSelection <ISvnRepositoryItem>());

            if (item == null)
            {
                return;
            }

            string newName = item.Origin.Target.FileName;

            if (e.Argument != null)
            {
                string[] items = e.Argument as string[];

                if (items != null)
                {
                    if (items.Length == 1)
                    {
                        newName = items[0];
                    }
                    else if (items.Length > 1)
                    {
                        newName = items[1];
                    }
                }
            }

            string logMessage;

            using (RenameDialog dlg = new RenameDialog())
            {
                dlg.Context = e.Context;
                dlg.OldName = item.Origin.Target.FileName;
                dlg.NewName = newName;

                if (DialogResult.OK != dlg.ShowDialog(e.Context))
                {
                    return;
                }
                newName    = dlg.NewName;
                logMessage = dlg.LogMessage;
            }

            try
            {
                Uri itemUri = SvnTools.GetNormalizedUri(item.Origin.Uri);
                e.GetService <IProgressRunner>().RunModal(CommandStrings.RenamingNodes,
                                                          delegate(object sender, ProgressWorkerArgs we)
                {
                    SvnMoveArgs ma = new SvnMoveArgs();
                    ma.LogMessage  = logMessage;
                    we.Client.RemoteMove(itemUri, new Uri(itemUri, newName), ma);
                });
            }
            finally
            {
                item.RefreshItem(true);
            }
        }
コード例 #3
0
        public override void Move(FilePath srcPath, FilePath destPath, SvnRevision rev, bool force, IProgressMonitor monitor)
        {
            SvnMoveArgs args = new SvnMoveArgs();

            BindMonitor(args, monitor);
            args.Force = force;
            client.Move(srcPath, destPath, args);
        }
コード例 #4
0
        public void MetaMove(string oldName, string newName)
        {
            SvnMoveArgs ma = new SvnMoveArgs();

            ma.ThrowOnError = false;
            ma.MetaDataOnly = true;

            Client.Move(oldName, newName, ma);
        }
コード例 #5
0
        public override void Move(FilePath srcPath, FilePath destPath, SvnRevision rev, bool force, IProgressMonitor monitor)
        {
            var args = new SvnMoveArgs {
                Force = force,
            };

            BindMonitor(monitor);
            lock (client)
                client.Move(srcPath, destPath, args);
        }
コード例 #6
0
ファイル: RenameNode.cs プロジェクト: necora/ank_git
        public override void OnExecute(CommandEventArgs e)
        {
            ISvnRepositoryItem item = EnumTools.GetSingle(e.Selection.GetSelection<ISvnRepositoryItem>());

            if (item == null)
                return;

            string newName = item.Origin.Target.FileName;

            if (e.Argument != null)
            {
                string[] items = e.Argument as string[];

                if (items != null)
                {
                    if (items.Length == 1)
                        newName = items[0];
                    else if (items.Length > 1)
                        newName = items[1];
                }
            }

            string logMessage;
            using (RenameDialog dlg = new RenameDialog())
            {
                dlg.Context = e.Context;
                dlg.OldName = item.Origin.Target.FileName;
                dlg.NewName = newName;

                if (DialogResult.OK != dlg.ShowDialog(e.Context))
                {
                    return;
                }
                newName = dlg.NewName;
                logMessage = dlg.LogMessage;
            }

            try
            {
                Uri itemUri = SvnTools.GetNormalizedUri(item.Origin.Uri);
                e.GetService<IProgressRunner>().RunModal(CommandStrings.RenamingNodes,
                    delegate(object sender, ProgressWorkerArgs we)
                    {
                        SvnMoveArgs ma = new SvnMoveArgs();
                        ma.LogMessage = logMessage;
                        we.Client.RemoteMove(itemUri, new Uri(itemUri, newName), ma);
                    });
            }
            finally
            {
                item.RefreshItem(true);
            }
        }
コード例 #7
0
        public void MoveServerSide(string oldPath, string newPath, int changeset, string committer, DateTime commitDate)
        {
            string oldUrl = this.repositoryPath + this.ToUrlPath(oldPath.Remove(0, this.workingCopyPath.Length));
            string newUrl = this.repositoryPath + this.ToUrlPath(newPath.Remove(0, this.workingCopyPath.Length));

            // when only casing is different, we need a server-side move/rename (because windows is case unsensitive!)
            SvnMoveArgs moveArgs = new SvnMoveArgs();

            moveArgs.LogMessage = string.Format("[TFS Changeset #{0}]\ntfs2svn: server-side rename", changeset);
            this.svnClient.RemoteMove(new Uri(oldUrl), new Uri(newPath), moveArgs);

            this.Update(); // todo: only update common rootpath of oldPath and newPath?

            this.SetCommitAuthorAndDate(commitDate, committer);
        }
コード例 #8
0
        /// <summary>
        /// Mueve un archivo a la carpeta eliminados, preservando la historia del SVN.
        /// </summary>
        /// <param name="rutaOrigen"></param>
        /// <param name="rutaEliminado"></param>
        /// <returns></returns>
        public static string EliminarArchivo(string rutaOrigen, string rutaEliminado, string nombre, string usuario)
        {
            var msj = "";

            try
            {
                string rutaCopiaTrabajo = ObtenerRutaCopiaTrabajo();

                // Argumentos del movido.
                var aa = new SvnMoveArgs();
                aa.Force = true;

                // Argumentos del commit.
                var args = new SvnCommitArgs();
                args.LogMessage = "Mover " + nombre + " a la carpeta Eliminados.\nUsuario: " + usuario + ".\nFecha: " + DateTime.Now;
                args.Depth      = SvnDepth.Infinity;

                using (var client = new SvnClient())
                {
                    // Agregar archivo a la copia de trabajo SVN.
                    client.Move(rutaOrigen, rutaEliminado, aa);

                    // Hacer commit repositorio SVN.
                    client.Commit(rutaCopiaTrabajo, args);
                }

                msj = "Exito";
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.ToString());
                msj += "Error al eliminar el archivo: " + ex.Message;

                if (ex.InnerException != null)
                {
                    msj += " " + ex.InnerException.Message;
                }
            }

            return(msj);
        }
コード例 #9
0
ファイル: MoveTests.cs プロジェクト: riiiqpl/sharpsvn
        public void Move_MultiMove()
        {
            SvnSandBox sbox = new SvnSandBox(this);
            sbox.Create(SandBoxRepository.Empty);
            string WcPath = sbox.Wc;

            using (SvnClient client = NewSvnClient(true, false))
            {
                string ren1 = Path.Combine(WcPath, "ren-1");

                using (StreamWriter sw = File.CreateText(ren1))
                {
                    sw.WriteLine("ToRename");
                }
                client.Add(ren1);
                client.Commit(WcPath);
                client.Update(WcPath);

                using (StreamWriter sw = File.AppendText(ren1))
                {
                    sw.WriteLine("AddedLine");
                }
                client.Move(ren1, ren1 + ".ren1");

                client.Commit(WcPath);

                client.Move(ren1 + ".ren1", ren1 + ".ren2");
                SvnMoveArgs ma = new SvnMoveArgs();
                ma.Force = true;
                client.Move(ren1 + ".ren2", ren1 + ".ren3", ma);
                client.Commit(WcPath);
            }
        }
コード例 #10
0
		public override void Move (FilePath srcPath, FilePath destPath, SvnRevision rev, bool force, IProgressMonitor monitor)
		{
			SvnMoveArgs args = new SvnMoveArgs ();
			BindMonitor (args, monitor);
			args.Force = force;
			lock (client) 
				client.Move (srcPath, destPath, args);
		}
コード例 #11
0
        public override void OnExecute(CommandEventArgs e)
        {
            Uri  target = null;
            Uri  root   = null;
            bool up     = false;

            List <SvnUriTarget> copyFrom = new List <SvnUriTarget>();

            foreach (ISvnRepositoryItem item in e.Selection.GetSelection <ISvnRepositoryItem>())
            {
                SvnUriTarget utt = item.Origin.Target as SvnUriTarget;

                if (utt == null)
                {
                    utt = new SvnUriTarget(item.Origin.Uri, item.Origin.Target.Revision);
                }

                copyFrom.Add(utt);

                if (root == null)
                {
                    root = item.Origin.RepositoryRoot;
                }

                if (target == null)
                {
                    target = item.Origin.Uri;
                }
                else
                {
                    Uri itemUri = SvnTools.GetNormalizedUri(item.Origin.Uri);

                    Uri r = item.Origin.Uri.MakeRelativeUri(target);

                    if (r.IsAbsoluteUri)
                    {
                        target = null;
                        break;
                    }

                    string rs = r.ToString();

                    if (r.ToString().StartsWith("/", StringComparison.Ordinal))
                    {
                        target = new Uri(target, "/");
                        break;
                    }

                    if (!up && r.ToString().StartsWith("../"))
                    {
                        target = new Uri(target, "../");
                        up     = true;
                    }
                }
            }

            bool   isMove = e.Command == AnkhCommand.ReposMoveTo;
            Uri    toUri;
            string logMessage;

            using (CopyToDialog dlg = new CopyToDialog())
            {
                dlg.RootUri     = root;
                dlg.SelectedUri = target;

                dlg.Text = isMove ? "Move to Url" : "Copy to Url";

                if (dlg.ShowDialog(e.Context) != System.Windows.Forms.DialogResult.OK)
                {
                    return;
                }

                toUri      = dlg.SelectedUri;
                logMessage = dlg.LogMessage;
            }

            // TODO: BH: Make sure the 2 attempts actually make sense

            e.GetService <IProgressRunner>().RunModal(isMove ? CommandStrings.Moving : CommandStrings.Copying,
                                                      delegate(object snd, ProgressWorkerArgs a)
            {
                if (isMove)
                {
                    List <Uri> uris = new List <Uri>();
                    foreach (SvnUriTarget ut in copyFrom)
                    {
                        uris.Add(ut.Uri);
                    }

                    SvnMoveArgs ma   = new SvnMoveArgs();
                    ma.LogMessage    = logMessage;
                    ma.CreateParents = true;

                    try
                    {
                        // First try with the full new name
                        a.Client.RemoteMove(uris, toUri, ma);
                    }
                    catch (SvnFileSystemException fs)
                    {
                        if (fs.SvnErrorCode != SvnErrorCode.SVN_ERR_FS_ALREADY_EXISTS)
                        {
                            throw;
                        }

                        // If exists retry below this directory with the existing name
                        ma.AlwaysMoveAsChild = true;
                        a.Client.RemoteMove(uris, toUri, ma);
                    }
                }
                else
                {
                    SvnCopyArgs ca   = new SvnCopyArgs();
                    ca.LogMessage    = logMessage;
                    ca.CreateParents = true;

                    try
                    {
                        // First try with the full new name
                        a.Client.RemoteCopy(copyFrom, toUri, ca);
                    }
                    catch (SvnFileSystemException fs)
                    {
                        if (fs.SvnErrorCode != SvnErrorCode.SVN_ERR_FS_ALREADY_EXISTS)
                        {
                            throw;
                        }

                        // If exists retry below this directory with the existing name
                        ca.AlwaysCopyAsChild = true;
                        a.Client.RemoteCopy(copyFrom, toUri, ca);
                    }
                }
            });

            // TODO: Send some notification to the repository explorer on this change?
        }
コード例 #12
0
ファイル: SvnSharpClient.cs プロジェクト: gAdrev/monodevelop
		public override void Move (FilePath srcPath, FilePath destPath, SvnRevision rev, bool force, ProgressMonitor monitor)
		{
			var args = new SvnMoveArgs {
				Force = force,
			};
			BindMonitor (monitor);
			lock (client) 
				client.Move (srcPath, destPath, args);
		}
コード例 #13
0
ファイル: CopyToOrMove.cs プロジェクト: necora/ank_git
        public override void OnExecute(CommandEventArgs e)
        {
            Uri target = null;
            Uri root = null;

            List<SvnUriTarget> copyFrom = new List<SvnUriTarget>();
            foreach (ISvnRepositoryItem item in e.Selection.GetSelection<ISvnRepositoryItem>())
            {
                SvnUriTarget utt = item.Origin.Target as SvnUriTarget;

                if(utt == null)
                    utt = new SvnUriTarget(item.Origin.Uri, item.Origin.Target.Revision);

                copyFrom.Add(utt);

                if(root == null)
                    root = item.Origin.RepositoryRoot;

                if (target == null)
                    target = item.Origin.Uri;
                else
                {
                    Uri itemUri = SvnTools.GetNormalizedUri(item.Origin.Uri);

                    Uri r = item.Origin.Uri.MakeRelativeUri(target);

                    if(r.IsAbsoluteUri)
                    {
                        target = null;
                        break;
                    }

                    string rs = r.ToString();

                    if(r.ToString().StartsWith("/", StringComparison.Ordinal))
                    {
                        target = new Uri(target, "/");
                        break;
                    }

                    while(r.ToString().StartsWith("../"))
                    {
                        target = new Uri(target, "../");
                        r = item.Origin.Uri.MakeRelativeUri(target);
                    }
                }
            }

            bool isMove = e.Command == AnkhCommand.ReposMoveTo;
            Uri toUri;
            string logMessage;
            using (CopyToDialog dlg = new CopyToDialog())
            {
                dlg.RootUri = root;
                dlg.SelectedUri = target;

                dlg.Text = isMove ? "Move to Url" : "Copy to Url";

                if (dlg.ShowDialog(e.Context) != System.Windows.Forms.DialogResult.OK)
                    return;

                toUri = dlg.SelectedUri;
                logMessage = dlg.LogMessage;
            }

            // TODO: BH: Make sure the 2 attempts actually make sense

            e.GetService<IProgressRunner>().RunModal(isMove ? "Moving" : "Copying",
                delegate(object snd, ProgressWorkerArgs a)
                {
                    if (isMove)
                    {
                        List<Uri> uris = new List<Uri>();
                        foreach (SvnUriTarget ut in copyFrom)
                            uris.Add(ut.Uri);

                        SvnMoveArgs ma = new SvnMoveArgs();
                        ma.LogMessage = logMessage;
                        ma.CreateParents = true;

                        try
                        {
                            // First try with the full new name
                            a.Client.RemoteMove(uris, toUri, ma);
                        }
                        catch (SvnFileSystemException fs)
                        {
                            if (fs.SvnErrorCode != SvnErrorCode.SVN_ERR_FS_ALREADY_EXISTS)
                                throw;

                            // If exists retry below this directory with the existing name
                            ma.AlwaysMoveAsChild = true;
                            a.Client.RemoteMove(uris, toUri, ma);
                        }
                    }
                    else
                    {
                        SvnCopyArgs ca = new SvnCopyArgs();
                        ca.LogMessage = logMessage;
                        ca.CreateParents = true;

                        try
                        {
                            // First try with the full new name
                            a.Client.RemoteCopy(copyFrom, toUri, ca);
                        }
                        catch (SvnFileSystemException fs)
                        {
                            if (fs.SvnErrorCode != SvnErrorCode.SVN_ERR_FS_ALREADY_EXISTS)
                                throw;

                            // If exists retry below this directory with the existing name
                            ca.AlwaysCopyAsChild = true;
                            a.Client.RemoteCopy(copyFrom, toUri, ca);
                        }
                    }
                });

            // TODO: Send some notification to the repository explorer on this change?
        }