public PathSelectorResult ShowPathSelector(PathSelectorInfo info) { using (PathSelector selector = new PathSelector(info)) { selector.Context = Context; bool succeeded = selector.ShowDialog(Context) == DialogResult.OK; PathSelectorResult result = new PathSelectorResult(succeeded, selector.CheckedItems); result.Depth = selector.Recursive ? SvnDepth.Infinity : SvnDepth.Empty; result.RevisionStart = selector.RevisionStart; result.RevisionEnd = selector.RevisionEnd; return result; } }
private static string DoExternalDiff(IAnkhServiceProvider context, PathSelectorResult info) { foreach (SvnItem item in info.Selection) { // skip unmodified for a diff against the textbase if (info.RevisionStart == SvnRevision.Base && info.RevisionEnd == SvnRevision.Working && !item.IsModified) continue; string tempDir = context.GetService<IAnkhTempDirManager>().GetTempDir(); AnkhDiffArgs da = new AnkhDiffArgs(); da.BaseFile = GetPath(context, info.RevisionStart, item, tempDir); da.MineFile = GetPath(context, info.RevisionEnd, item, tempDir); context.GetService<IAnkhDiffHandler>().RunDiff(da); } return null; }
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); }); } }