public override void Lock(IProgressMonitor monitor, string comment, bool stealLock, params FilePath[] paths) { SvnLockArgs args = new SvnLockArgs(); BindMonitor(args, monitor); args.Comment = comment; args.StealLock = stealLock; client.Lock(paths.ToStringArray(), args); }
public override void Lock(IProgressMonitor monitor, string comment, bool stealLock, params FilePath[] paths) { var args = new SvnLockArgs { Comment = comment, StealLock = stealLock, }; BindMonitor(monitor); lock (client) client.Lock(paths.ToStringArray(), args); }
public bool GetLockForceFully() { using (SvnClient client = new SvnClient()) { File.Delete(_excelFilePath); client.Update(_excelFilePath); var args = new SvnLockArgs(); args.StealLock = true; client.Lock(_excelFilePath, args); } return(true); }
public void Lock_BasicLock() { SvnSandBox sbox = new SvnSandBox(this); sbox.Create(SandBoxRepository.Empty); string WcPath = sbox.Wc; string filepath = Path.Combine(WcPath, "Form.cs"); TouchFile(filepath); Client.Add(filepath); Client.Commit(filepath); Client.Status(filepath, delegate(object sender, SvnStatusEventArgs e) { Assert.That(e.LocalLock, Is.Null); }); string comment = "Moo\nMa"; bool gotIn = false; SvnLockArgs la = new SvnLockArgs(); la.Comment = comment; la.Notify += delegate(object sender, SvnNotifyEventArgs e) { Assert.That(e.Action, Is.EqualTo(SvnNotifyAction.LockLocked)); gotIn = true; }; Client.Lock(new string[] { filepath }, la); Assert.That(gotIn); gotIn = false; comment = comment.Replace("\n", "\r\n"); Client.Status(filepath, delegate(object sender, SvnStatusEventArgs e) { Assert.That(e.LocalLock, Is.Not.Null); Assert.That(e.LocalLock.Owner, Is.EqualTo(Environment.UserName)); Assert.That(e.LocalLock.Token, Is.Not.Null); Assert.That(e.LocalLock.Comment, Is.EqualTo(comment)); Assert.That(e.LocalLock.CreationTime.ToLocalTime(), Is.LessThanOrEqualTo(DateTime.Now).And.GreaterThan(DateTime.Now - new TimeSpan(0, 0, 20))); gotIn = true; }); Assert.That(gotIn); }
public void Lock_BasicLock() { SvnSandBox sbox = new SvnSandBox(this); sbox.Create(SandBoxRepository.Empty); string WcPath = sbox.Wc; string filepath = Path.Combine(WcPath, "Form.cs"); TouchFile(filepath); Client.Add(filepath); Client.Commit(filepath); Client.Status(filepath, delegate(object sender, SvnStatusEventArgs e) { Assert.That(e.LocalLock, Is.Null); }); string comment = "Moo\nMa"; bool gotIn = false; SvnLockArgs la = new SvnLockArgs(); la.Comment = comment; la.Notify += delegate(object sender, SvnNotifyEventArgs e) { Assert.That(e.Action, Is.EqualTo(SvnNotifyAction.LockLocked)); gotIn = true; }; Client.Lock(new string[] { filepath }, la); Assert.That(gotIn); gotIn = false; comment = comment.Replace("\n", "\r\n"); Client.Status(filepath, delegate(object sender, SvnStatusEventArgs e) { Assert.That(e.LocalLock, Is.Not.Null); Assert.That(e.LocalLock.Owner, Is.EqualTo(Environment.UserName)); Assert.That(e.LocalLock.Token, Is.Not.Null); Assert.That(e.LocalLock.Comment, Is.EqualTo(comment)); Assert.That(e.LocalLock.CreationTime.ToLocalTime(), Is.LessThanOrEqualTo(DateTime.Now).And.GreaterThan(DateTime.Now - new TimeSpan(0,0,20))); gotIn = true; }); Assert.That(gotIn); }
public override void Lock (IProgressMonitor monitor, string comment, bool stealLock, params FilePath[] paths) { SvnLockArgs args = new SvnLockArgs (); BindMonitor (args, monitor); args.Comment = comment; args.StealLock = stealLock; lock (client) client.Lock (paths.ToStringArray (), args); }
public override void Lock (IProgressMonitor monitor, string comment, bool stealLock, params FilePath[] paths) { var args = new SvnLockArgs { Comment = comment, StealLock = stealLock, }; BindMonitor (monitor); lock (client) client.Lock (paths.ToStringArray (), args); }
public override void OnExecute(CommandEventArgs e) { IEnumerable<SvnItem> items = e.Argument as IEnumerable<SvnItem>; if (e.Command == AnkhCommand.SccLock && items == null) return; PathSelectorInfo psi = new PathSelectorInfo("Select Files to Lock", items ?? e.Selection.GetSelectedSvnItems(true)); psi.VisibleFilter += delegate(SvnItem item) { return item.IsFile && item.IsVersioned && !item.IsLocked; }; psi.CheckedFilter += delegate(SvnItem item) { return item.IsFile && item.IsVersioned && !item.IsLocked; }; PathSelectorResult psr; bool stealLocks = false; string comment = ""; IAnkhConfigurationService cs = e.GetService<IAnkhConfigurationService>(); AnkhConfig config = cs.Instance; IEnumerable<SvnItem> selectedItems = null; if (!config.SuppressLockingUI || e.PromptUser) { if (e.PromptUser || !(Shift || e.DontPrompt)) { using (LockDialog dlg = new LockDialog(psi)) { bool succeeded = (dlg.ShowDialog(e.Context) == DialogResult.OK); psr = new PathSelectorResult(succeeded, dlg.CheckedItems); stealLocks = dlg.StealLocks; comment = dlg.Message; } } else { psr = psi.DefaultResult; } if (!psr.Succeeded) { return; } selectedItems = psr.Selection; } if (selectedItems == null) selectedItems = psi.DefaultResult.Selection; List<string> files = new List<string>(); foreach (SvnItem item in selectedItems) { if (item.IsFile) // svn lock is only for files { files.Add(item.FullPath); } } if (files.Count == 0) return; SortedList<string, string> alreadyLockedFiles = new SortedList<string, string>(StringComparer.OrdinalIgnoreCase); e.GetService<IProgressRunner>().RunModal( "Locking", delegate(object sender, ProgressWorkerArgs ee) { SvnLockArgs la = new SvnLockArgs(); la.StealLock = stealLocks; la.Comment = comment; la.AddExpectedError(SvnErrorCode.SVN_ERR_FS_PATH_ALREADY_LOCKED); la.Notify += delegate(object nSender, SvnNotifyEventArgs notifyArgs) { if (notifyArgs.Action == SvnNotifyAction.LockFailedLock) { alreadyLockedFiles.Add(notifyArgs.FullPath, GuessUserFromError(notifyArgs.Error.Message)); } }; ee.Client.Lock(files, la); }); if (alreadyLockedFiles.Count == 0) return; StringBuilder msg = new StringBuilder(); msg.AppendLine(CommandStrings.ItemsAlreadyLocked); msg.AppendLine(); foreach (KeyValuePair<string, string> kv in alreadyLockedFiles) { if (!string.IsNullOrEmpty(kv.Value)) msg.AppendFormat(CommandStrings.ItemFileLocked, kv.Key, kv.Value); else msg.Append(kv.Key); msg.AppendLine(); } // TODO: Create a dialog where the user can select what locks to steal, and also what files are already locked. AnkhMessageBox box = new AnkhMessageBox(e.Context); DialogResult rslt = box.Show( msg.ToString().TrimEnd(), "", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (rslt == DialogResult.Yes) { e.GetService<IProgressRunner>().RunModal( CommandStrings.LockingTitle, delegate(object sender, ProgressWorkerArgs ee) { SvnLockArgs la = new SvnLockArgs(); la.StealLock = true; la.Comment = comment; ee.Client.Lock(files, la); }); } }
public override void OnExecute(CommandEventArgs e) { IEnumerable <SvnItem> items = e.Argument as IEnumerable <SvnItem>; if (e.Command == AnkhCommand.SccLock && items == null) { return; } if (items == null) { List <SvnItem> choices = new List <SvnItem>(); foreach (SvnItem item in e.Selection.GetSelectedSvnItems(false)) { if (item.IsFile && item.IsVersioned && !item.IsNewAddition && !item.IsLocked) { choices.Add(item); } } items = choices; } if (EnumTools.IsEmpty(items)) { return; } bool stealLocks = false; string comment = ""; AnkhConfig config = e.GetService <IAnkhConfigurationService>().Instance; if (!e.DontPrompt && (e.PromptUser || !(Shift || config.SuppressLockingUI))) { using (LockDialog dlg = new LockDialog()) { dlg.Context = e.Context; dlg.LoadItems(items); if (dlg.ShowDialog(e.Context) != DialogResult.OK) { return; } items = new List <SvnItem>(dlg.GetCheckedItems()); stealLocks = dlg.StealLocks; comment = dlg.Message; } } ICollection <string> files = SvnItem.GetPaths(items); if (files.Count == 0) { return; } SortedList <string, string> alreadyLockedFiles = new SortedList <string, string>(StringComparer.OrdinalIgnoreCase); e.GetService <IProgressRunner>().RunModal( CommandStrings.LockingTitle, delegate(object sender, ProgressWorkerArgs ee) { SvnLockArgs la = new SvnLockArgs(); la.StealLock = stealLocks; la.Comment = comment; la.AddExpectedError(SvnErrorCode.SVN_ERR_FS_PATH_ALREADY_LOCKED); la.Notify += delegate(object nSender, SvnNotifyEventArgs notifyArgs) { if (notifyArgs.Action == SvnNotifyAction.LockFailedLock) { string userName; if (notifyArgs.Lock != null && !string.IsNullOrEmpty(notifyArgs.Lock.Owner)) { userName = notifyArgs.Lock.Owner; } else { userName = GuessUserFromError(notifyArgs.Error.Message) ?? "?"; } alreadyLockedFiles.Add(notifyArgs.FullPath, userName); } }; ee.Client.Lock(files, la); }); if (alreadyLockedFiles.Count == 0) { return; } StringBuilder msg = new StringBuilder(); msg.AppendLine(CommandStrings.ItemsAlreadyLocked); msg.AppendLine(); foreach (KeyValuePair <string, string> kv in alreadyLockedFiles) { if (!string.IsNullOrEmpty(kv.Value)) { msg.AppendFormat(CommandStrings.ItemFileLocked, kv.Key, kv.Value); } else { msg.Append(kv.Key); } msg.AppendLine(); } // TODO: Create a dialog where the user can select what locks to steal, and also what files are already locked. AnkhMessageBox box = new AnkhMessageBox(e.Context); DialogResult rslt = box.Show( msg.ToString().TrimEnd(), "", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2); if (rslt == DialogResult.Yes) { e.GetService <IProgressRunner>().RunModal( CommandStrings.LockingTitle, delegate(object sender, ProgressWorkerArgs ee) { SvnLockArgs la = new SvnLockArgs(); la.StealLock = true; la.Comment = comment; ee.Client.Lock(files, la); }); } }