protected override bool RunInternal(object options) { FileBaseCommandVerbOptions localOptions = options as FileBaseCommandVerbOptions; Printer.EnableDiagnostics = localOptions.Verbose; if (localOptions.Objects != null) { if (SupportsTags) { TagList = localOptions.Objects.Where(x => x.StartsWith("#")).Select(x => x.Substring(1)).ToList(); localOptions.Objects = localOptions.Objects.Where(x => !x.StartsWith("#")).ToList(); } } FilterOptions = localOptions; Start(); if (FilterOptions.Objects != null && FilterOptions.Objects.Count == 1) { try { System.IO.DirectoryInfo info = new System.IO.DirectoryInfo(FilterOptions.Objects[0]); if (info.Exists) { ActiveDirectory = info; FilterOptions.Objects.RemoveAt(0); RemovedOnlyTarget = true; } } catch { } } Versionr.Status status = null; List <Versionr.Status.StatusEntry> targets = null; if (ComputeTargets(localOptions)) { status = Workspace.GetStatus(ActiveDirectory); GetInitialList(status, localOptions, out targets); if (localOptions.Recursive) { status.AddRecursiveElements(targets); } ApplyFilters(status, localOptions, ref targets); } if ((targets != null && targets.Count > 0) || !RequiresTargets) { return(RunInternal(Workspace, status, targets, localOptions)); } Printer.PrintWarning("No files selected for {0}", localOptions.Verb); return(false); }
protected override bool ComputeTargets(FileBaseCommandVerbOptions options) { if (!base.ComputeTargets(options)) { RecordVerbOptions localOptions = options as RecordVerbOptions; return(localOptions.All || localOptions.Tracked); } return(true); }
protected virtual void ApplyFilters(Versionr.Status status, FileBaseCommandVerbOptions localOptions, ref List <Versionr.Status.StatusEntry> targets) { IEnumerable <Versionr.Status.StatusEntry> entries = targets; if (!localOptions.Ignored) { entries = entries.Where(x => x.Staged == true || !(x.Code == StatusCode.Ignored && x.VersionControlRecord == null)); } if (localOptions.Tracked) { entries = entries.Where(x => x.Staged == true || (x.VersionControlRecord != null && x.Code != StatusCode.Copied && x.Code != StatusCode.Renamed)); } if (localOptions.Recorded) { entries = entries.Where(x => x.Staged == true); } if (localOptions.SkipEmpty) { Dictionary <Versionr.Status.StatusEntry, bool> allow = new Dictionary <Versionr.Status.StatusEntry, bool>(); Dictionary <string, Versionr.Status.StatusEntry> mapper = new Dictionary <string, Versionr.Status.StatusEntry>(); entries = entries.ToList(); foreach (var x in entries) { if (x.IsDirectory) { allow[x] = false; mapper[x.CanonicalName] = x; } } foreach (var x in entries) { if (x.IsDirectory) { continue; } string s = x.CanonicalName; int index = s.LastIndexOf('/'); if (index != -1) { string dir = s.Substring(0, index + 1); // Sometimes files in ignored directories show up here, so check to make sure the directory exists first if (mapper.TryGetValue(dir, out var value)) { allow[value] = true; } } } entries = entries.Where(x => !x.IsDirectory || allow[x]).ToList(); } if (!ReferenceEquals(targets, entries)) { targets = entries.ToList(); } }
protected virtual void GetInitialList(Versionr.Status status, FileBaseCommandVerbOptions localOptions, out List <Versionr.Status.StatusEntry> targets) { if (localOptions.Objects != null && localOptions.Objects.Count > 0) { targets = status.GetElements(localOptions.Objects, localOptions.Regex, localOptions.Filename, localOptions.Insensitive); } else { targets = status.Elements; } }
protected override void ApplyFilters(Versionr.Status status, FileBaseCommandVerbOptions localOptions, ref List <Versionr.Status.StatusEntry> targets) { base.ApplyFilters(status, localOptions, ref targets); if (localOptions.Ignored) { targets = targets.Where(x => x.Code != StatusCode.Excluded).ToList(); } else { targets = targets.Where(x => (x.Code != StatusCode.Excluded && (x.Staged || !(x.Code == StatusCode.Ignored && x.VersionControlRecord == null)))).ToList(); } }
protected override void GetInitialList(Versionr.Status status, FileBaseCommandVerbOptions options, out List <Versionr.Status.StatusEntry> targets) { FileCommandVerbOptions localOptions = options as FileCommandVerbOptions; if (localOptions.All) { targets = status.Elements; } else { base.GetInitialList(status, options, out targets); } }
protected override bool RunInternal(Area ws, Versionr.Status status, IList <Versionr.Status.StatusEntry> targets, FileBaseCommandVerbOptions options) { RecordVerbOptions localOptions = options as RecordVerbOptions; return(ws.RecordChanges(status, targets, localOptions.Missing, localOptions.Interactive, new Action <Versionr.Status.StatusEntry, StatusCode, bool>(RecordFeedback))); }
protected override bool RunInternal(Area ws, Versionr.Status status, IList <Versionr.Status.StatusEntry> targets, FileBaseCommandVerbOptions options) { LogVerbOptions localOptions = options as LogVerbOptions; if (JruntingMode) { localOptions.Detail = LogVerbOptions.DetailMode.Jrunting; } if (localOptions.ShowAutoMerges) { localOptions.ShowMerges = true; } if (localOptions.FollowBranches || localOptions.ShowMerges) { if (!localOptions.Logical) { Printer.PrintError("#e#Error:## Following branches and specifically enabling display or merges are only valid options when showing the #b#--logical## history."); return(false); } } Printer.EnableDiagnostics = localOptions.Verbose; bool targetedBranch = false; Objects.Version version = null; if (!string.IsNullOrEmpty(localOptions.Branch)) { bool multipleBranches = false; var branch = ws.GetBranchByPartialName(localOptions.Branch, out multipleBranches); if (branch == null || multipleBranches) { Printer.PrintError("No unique branch found for {0}", localOptions.Branch); return(false); } version = ws.GetBranchHeadVersion(branch); targetedBranch = true; } else if (!string.IsNullOrEmpty(localOptions.Version)) { version = ws.GetPartialVersion(localOptions.Version); if (version == null) { Printer.PrintError("Couldn't find matching version for {0}", localOptions.Version); return(false); } } bool versionAutoSelected = false; bool lastResortVersionSelection = false; List <Objects.Head> targetHeadObjects = null; if (localOptions.Limit == -1) { localOptions.Limit = (version == null || targetedBranch) ? 10 : 1; } if (version == null) { versionAutoSelected = true; targetHeadObjects = ws.GetBranchHeads(ws.CurrentBranch); if (targetHeadObjects.Count == 1) { version = ws.GetVersion(targetHeadObjects[0].Version); } else { var guid = ws.Version.ID; foreach (var head in targetHeadObjects) { if (head.Version == guid) { version = ws.Version; break; } } if (version == null) { foreach (var head in targetHeadObjects) { var temphistory = ws.GetHistory(ws.GetVersion(head.Version), null); foreach (var h in temphistory) { if (h.ID == guid) { version = ws.GetVersion(head.Version); break; } } } } if (version == null) { lastResortVersionSelection = true; version = ws.Version; } } } int?nullableLimit = localOptions.Limit; if (nullableLimit.Value <= 0) { nullableLimit = null; } if (localOptions.Xml) { Printer.PrintMessage("<?xml version='1.0'?>"); Printer.PrintMessage($"<vsrlog>"); var branch = ws.GetBranch(version.Branch); Printer.PrintMessage($" <branch id='{branch.ID}' name='{XmlAttr(branch.Name)}'>"); foreach (var head in ws.GetBranchHeads(branch)) { Printer.PrintMessage($" <head version='{head.Version}' />"); } Printer.PrintMessage(" </branch>"); } var history = (localOptions.Logical ? ws.GetLogicalHistorySequenced(version, localOptions.FollowBranches, localOptions.ShowMerges, localOptions.ShowAutoMerges, nullableLimit) : ws.GetHistory(version, nullableLimit).Select(x => new Tuple <Objects.Version, int>(x, 0))).AsEnumerable(); m_Tip = Workspace.Version; Objects.Version last = null; m_Branches = new Dictionary <Guid, Objects.Branch>(); bool anything = false; ws.BeginDatabaseTransaction(); foreach (var x in ApplyHistoryFilter(history, localOptions)) { last = x.Item1.Item1; FormatLog(x.Item1, x.Item2, localOptions); anything = true; } ws.CommitDatabaseTransaction(); if (localOptions.Xml) { Printer.PrintMessage("</vsrlog>"); } else { if (!localOptions.Jrunting) { if (last != null && last.ID != m_Tip.ID) { var branch = Workspace.CurrentBranch; var heads = Workspace.GetBranchHeads(branch); bool isHead = heads.Any(x => x.Version == m_Tip.ID); bool isOnlyHead = heads.Count == 1; if (!isHead) { Printer.PrintMessage("\nCurrent version #b#{0}## is #e#not the head## of branch #b#{1}## (#b#\"{2}\"##)", m_Tip.ShortName, branch.ShortID, branch.Name); } else if (!isOnlyHead) { Printer.PrintMessage("\nCurrent version #b#{0}## is #w#not only the head## of branch #b#{1}## (#b#\"{2}\"##)", m_Tip.ShortName, branch.ShortID, branch.Name); } } if (!anything) { if (!nullableLimit.HasValue || nullableLimit.Value <= 0) { Printer.PrintMessage("\nNo versions matched your history/filter query (searched #b#all## revisions)."); } else { Printer.PrintMessage("\nNo versions matched your history/filter query (searched #b#{0}## revisions).\n\nTry setting #b#--limit## to a larger value (or #b#0## for all revisions).", nullableLimit.Value); } } } if (versionAutoSelected) { if (targetHeadObjects.Count > 1) { Printer.WriteLineMessage("\n #w#Warning:## Target branch has multiple heads."); Printer.WriteLineMessage("\n Heads of #b#\"{0}\"##:", ws.CurrentBranch.Name); foreach (var x in targetHeadObjects) { var v = Workspace.GetVersion(x.Version); Printer.WriteLineMessage(" #b#{0}##: {1} by {2}", v.ShortName, v.Timestamp.ToLocalTime(), v.Author); } } } } return(true); }
protected override bool ComputeTargets(FileBaseCommandVerbOptions localOptions) { return(false); }
protected override bool RunInternal(Area ws, Versionr.Status status, IList <Versionr.Status.StatusEntry> targets, FileBaseCommandVerbOptions options) { CommitVerbOptions localOptions = options as CommitVerbOptions; if (localOptions.Message == null && localOptions.MessageFile == null) { Printer.PrintError("#x#Error:## A commit message must be specified with the --message or --message-file options."); return(false); } if (targets != null && targets.Count > 0) { ws.RecordChanges(status, targets, localOptions.Missing, false, RecordFeedback); } string message = localOptions.Message; if (localOptions.MessageFile != null) { using (var fs = System.IO.File.OpenText(localOptions.MessageFile)) { message = fs.ReadToEnd(); } } else { message = message.Replace("\\\"", "\""); message = message.Replace("\\n", "\n"); message = message.Replace("\\t", "\t"); } if (!ws.Commit(message, localOptions.Force, TagList)) { return(false); } return(true); }
protected override bool RunInternal(Area ws, Versionr.Status status, IList <Versionr.Status.StatusEntry> targets, FileBaseCommandVerbOptions options) { RevertVerbOptions localOptions = options as RevertVerbOptions; ws.Revert(targets, true, localOptions.Interactive, localOptions.Delete, UnrecordFeedback); if (targets.Count > 0 && ws.HasPendingMerge) { Printer.PrintMessage("#b#Info:## Current vault has an outstanding pending merge that will be attached to the next commit.\nIf you wish to clear this merge information, you will need to use the #b#checkout## command."); } return(true); }
protected override bool ComputeTargets(FileBaseCommandVerbOptions localOptions) { return(base.ComputeTargets(localOptions) && (string.IsNullOrEmpty((OptionsObject as DiffVerbOptions).Version) || (OptionsObject as DiffVerbOptions).Local)); }
protected override bool RunInternal(Area ws, Versionr.Status status, IList <Versionr.Status.StatusEntry> targets, FileBaseCommandVerbOptions options) { DiffVerbOptions localOptions = options as DiffVerbOptions; Objects.Version version = null; Objects.Version parent = null; if (!string.IsNullOrEmpty(localOptions.Version)) { version = Workspace.GetPartialVersion(localOptions.Version); if (version == null) { Printer.PrintError("No version found matching {0}", localOptions.Version); return(false); } if (version.Parent.HasValue) { parent = Workspace.GetVersion(version.Parent.Value); } if (parent == null) { Printer.PrintMessage("Version {0} has no parent", version.ID); return(true); } Printer.PrintMessage("Showing changes for version #c#{0}", version.ID); } bool showUnchangedObjects = localOptions.Objects.Count != 0; List <Task> tasks = new List <Task>(); List <string> tempFiles = new List <string>(); List <System.Diagnostics.Process> diffProcesses = new List <System.Diagnostics.Process>(); try { if (version == null) { foreach (var x in targets) { if (x.VersionControlRecord != null && !x.IsDirectory && x.FilesystemEntry != null && (x.Code == StatusCode.Modified || x.Code == StatusCode.Conflict)) { if (localOptions.Recorded && x.Staged == false) { continue; } if (x.Code == StatusCode.Conflict) { Printer.PrintMessage("Object: #b#{0}## is #w#conflicted##.", x.CanonicalName); } if (Utilities.FileClassifier.Classify(x.FilesystemEntry.Info) == Utilities.FileEncoding.Binary) { Printer.PrintMessage("File: #b#{0}## is binary #w#different##.", x.CanonicalName); continue; } // Displaying local modifications string tmp = Utilities.DiffTool.GetTempFilename(); if (Workspace.ExportRecord(x.CanonicalName, Workspace.Version, tmp)) { Printer.PrintMessage("Displaying changes for file: #b#{0}", x.CanonicalName); if (localOptions.External || localOptions.ExternalNonBlocking) { tempFiles.Add(tmp); bool nonblocking = Workspace.Directives.NonBlockingDiff.HasValue && Workspace.Directives.NonBlockingDiff.Value; nonblocking |= localOptions.ExternalNonBlocking; var t = GetTaskFactory(options).StartNew(() => { var diffResult = Utilities.DiffTool.Diff(tmp, x.Name + "-base", System.IO.Path.Combine(Workspace.RootDirectory.FullName, Workspace.GetLocalCanonicalName(x.VersionControlRecord)), x.Name, ws.Directives.ExternalDiff, nonblocking); if (diffResult != null) { lock (diffProcesses) { diffProcesses.Add(diffResult); } } }); if (nonblocking) { tasks.Add(t); } else { t.Wait(); } } else { try { RunInternalDiff(tmp, System.IO.Path.Combine(Workspace.RootDirectory.FullName, Workspace.GetLocalCanonicalName(x.VersionControlRecord)), !localOptions.KeepTabs, Workspace.GetLocalCanonicalName(x.VersionControlRecord)); } finally { new System.IO.FileInfo(tmp).IsReadOnly = false; System.IO.File.Delete(tmp); } } } } else if (x.Code == StatusCode.Unchanged && showUnchangedObjects && !x.IsDirectory) { var filter = Filter(new KeyValuePair <string, Objects.Record>[] { new KeyValuePair <string, Objects.Record>(x.CanonicalName, x.VersionControlRecord) }).FirstOrDefault(); if (filter.Value != null && filter.Key == true) // check if the file was really specified { Printer.PrintMessage("Object: #b#{0}## is #s#unchanged##.", x.CanonicalName); } } else if (x.VersionControlRecord == null && showUnchangedObjects) { var filter = Filter(new KeyValuePair <string, bool>[] { new KeyValuePair <string, bool>(x.CanonicalName, true) }).FirstOrDefault(); if (filter.Value != false && filter.Key == true) // check if the file was really specified { Printer.PrintMessage("Object: #b#{0}## is #c#unversioned##.", x.CanonicalName); } } } } else { if (localOptions.Local) { var records = ws.GetRecords(version); Dictionary <string, Objects.Record> recordMap = new Dictionary <string, Objects.Record>(); foreach (var x in records) { recordMap[x.CanonicalName] = x; } foreach (var x in targets) { if (localOptions.Recorded && x.Staged == false) { continue; } Objects.Record otherRecord = null; if (recordMap.TryGetValue(x.CanonicalName, out otherRecord) && !otherRecord.IsDirectory) { if (x.VersionControlRecord != null && x.VersionControlRecord.DataIdentifier == otherRecord.DataIdentifier) { continue; } if (x.FilesystemEntry != null && otherRecord.Fingerprint == x.FilesystemEntry.Hash && otherRecord.Size == x.FilesystemEntry.Length) { continue; } if (Utilities.FileClassifier.Classify(x.FilesystemEntry.Info) == Utilities.FileEncoding.Binary) { Printer.PrintMessage("File: #b#{0}## is binary #w#different##.", x.CanonicalName); continue; } string tmp = Utilities.DiffTool.GetTempFilename(); if (Workspace.ExportRecord(x.CanonicalName, version, tmp)) { Printer.PrintMessage("Displaying changes for file: #b#{0}", x.CanonicalName); if (localOptions.External || localOptions.ExternalNonBlocking) { tempFiles.Add(tmp); bool nonblocking = Workspace.Directives.NonBlockingDiff.HasValue && Workspace.Directives.NonBlockingDiff.Value; nonblocking |= localOptions.ExternalNonBlocking; var t = GetTaskFactory(options).StartNew(() => { var diffResult = Utilities.DiffTool.Diff(tmp, x.Name + "-base", Workspace.GetLocalCanonicalName(x.VersionControlRecord), x.Name, ws.Directives.ExternalDiff, nonblocking); if (diffResult != null) { lock (diffProcesses) { diffProcesses.Add(diffResult); } } }); if (nonblocking) { tasks.Add(t); } else { t.Wait(); } } else { try { RunInternalDiff(tmp, System.IO.Path.Combine(Workspace.RootDirectory.FullName, Workspace.GetLocalCanonicalName(x.VersionControlRecord)), !localOptions.KeepTabs, Workspace.GetLocalCanonicalName(x.VersionControlRecord)); } finally { System.IO.File.Delete(tmp); } } } } else { Printer.PrintMessage("File: #b#{0}## is not in other version.", x.CanonicalName); } } } else { List <KeyValuePair <string, Objects.Record> > updates = ws.GetAlterations(version) .Where(x => x.Type == Objects.AlterationType.Update) .Select(x => ws.GetRecord(x.NewRecord.Value)) .Select(x => new KeyValuePair <string, Objects.Record>(x.CanonicalName, x)).ToList(); foreach (var pair in Filter(updates)) { Objects.Record rec = pair.Value; string tmpVersion = Utilities.DiffTool.GetTempFilename(); if (!Workspace.ExportRecord(rec.CanonicalName, version, tmpVersion)) { continue; } string tmpParent = Utilities.DiffTool.GetTempFilename(); if (!Workspace.ExportRecord(rec.CanonicalName, parent, tmpParent)) { System.IO.File.Delete(tmpVersion); continue; } Printer.PrintMessage("Displaying changes for file: #b#{0}", rec.CanonicalName); if (localOptions.External || localOptions.ExternalNonBlocking) { bool nonblocking = Workspace.Directives.NonBlockingDiff.HasValue && Workspace.Directives.NonBlockingDiff.Value; nonblocking |= localOptions.ExternalNonBlocking; tempFiles.Add(tmpVersion); tempFiles.Add(tmpParent); var t = GetTaskFactory(options).StartNew(() => { var diffResult = Utilities.DiffTool.Diff(tmpParent, rec.Name + "-" + parent.ShortName, tmpVersion, rec.Name + "-" + version.ShortName, ws.Directives.ExternalDiff, nonblocking); if (diffResult != null) { lock (diffProcesses) { diffProcesses.Add(diffResult); } } }); if (nonblocking) { tasks.Add(t); } else { t.Wait(); } } else { try { RunInternalDiff(tmpParent, tmpVersion, !localOptions.KeepTabs, rec.CanonicalName); } finally { System.IO.File.Delete(tmpVersion); System.IO.File.Delete(tmpParent); } } } } } } finally { Task.WaitAll(tasks.ToArray()); foreach (var x in diffProcesses) { x.WaitForExit(); } foreach (var x in tempFiles) { System.IO.File.Delete(x); } } return(true); }
protected override bool RunInternal(Area ws, Versionr.Status status, IList <Versionr.Status.StatusEntry> targets, FileBaseCommandVerbOptions options) { StatusVerbOptions localOptions = (StatusVerbOptions)options; LocalOptions = localOptions; if (localOptions.Objects != null && localOptions.Objects.Count > 0) { if (targets.Count == 0) { Printer.PrintError("#x#Error:##\n Could not find objects matching pattern #b#{0}##", GetPatterns(localOptions.Objects)); if (ActiveDirectory.FullName != Workspace.Root.FullName) { Printer.PrintMessage(" - Relative to folder \"#b#{0}##\"", Workspace.GetLocalPath(ActiveDirectory.FullName)); } return(false); } } var ss = status; if (!string.IsNullOrEmpty(ss.RestrictedPath)) { Printer.WriteLineMessage(" Computing status for path: #b#{0}##", ss.RestrictedPath); } int[] codeCount = new int[(int)StatusCode.Count]; if (status.MergeInputs.Count > 0) { Printer.WriteLineMessage("Workspace has #b#{0}## pending merges.", status.MergeInputs.Count); } foreach (var x in status.MergeInputs) { Printer.WriteLineMessage(" #c#{0}#q# from branch \"#b#{1}##\" (rev {2})", x.ID, Workspace.GetBranch(x.Branch).Name, x.Revision); } if (status.MergeInputs.Count > 0) { Printer.WriteLineMessage(""); } IEnumerable <Versionr.Status.StatusEntry> operands = targets.Where(x => { codeCount[(int)x.Code]++; if (x.Code == StatusCode.Excluded) { return(false); } if (x.Code == StatusCode.Ignored) { if (x.VersionControlRecord != null) { return(true); } return(localOptions.Ignored); } return(true); }); if (!localOptions.All) { operands = operands.Where(x => x.Code != StatusCode.Unchanged); } string localRestrictedPath = null; if (ss.RestrictedPath != null) { localRestrictedPath = ws.GetLocalCanonicalName(ss.RestrictedPath); } if (!localOptions.NoList) { if (localOptions.Flat) { foreach (var x in operands.OrderBy(x => x.CanonicalName)) { PrintFile(ws, localRestrictedPath, x, true); } } else { var staged = operands.OrderBy(x => x.CanonicalName).Where(y => y.Staged); if (staged.Count() > 0) { Printer.WriteLineMessage(""); Printer.WriteLineMessage(" Changes recorded for commit:"); Printer.WriteLineMessage(" (use \"vsr unrecord <file>...\" to unrecord)"); Printer.WriteLineMessage(""); foreach (var x in staged) { PrintFile(ws, localRestrictedPath, x); } } var nonstaged = operands.OrderBy(x => x.CanonicalName).Where(y => !y.Staged && y.Code != StatusCode.Unversioned); if (nonstaged.Count() > 0) { Printer.WriteLineMessage(""); Printer.WriteLineMessage(" Changes not staged:"); Printer.WriteLineMessage(" (use \"vsr record <file>...\" to add files to this record)"); Printer.WriteLineMessage(" (use \"vsr revert <file>...\" to revert changes from working directory)"); Printer.WriteLineMessage(""); foreach (var x in nonstaged) { PrintFile(ws, localRestrictedPath, x); } } var untracked = operands.OrderBy(x => x.CanonicalName).Where(y => y.Code == StatusCode.Unversioned); if (untracked.Count() > 0) { Printer.WriteLineMessage(""); Printer.WriteLineMessage(" Untracked files:"); Printer.WriteLineMessage(" (use \"vsr record <file>...\" to add files to this record)"); Printer.WriteLineMessage(""); foreach (var x in untracked) { PrintFile(ws, localRestrictedPath, x); } } } } if (localOptions.Summary) { Printer.WriteLineMessage("\n#b#Summary:##"); for (int i = 0; i < codeCount.Length; i++) { Printer.WriteLineMessage(" {0} #b#{2}## #q#{1}##", codeCount[i], codeCount[i] != 1 ? "Objects" : "Object", ((StatusCode)i).ToString()); } Printer.WriteLineMessage("\n {0}#q# files in ##{1}#q# diectories ({2} ignored)", ss.Files, ss.Directories, ss.IgnoredObjects); } foreach (var x in Workspace.Externs) { bool include = true; if (!string.IsNullOrEmpty(ss.RestrictedPath)) { include = Workspace.PathContains(ss.RestrictedPath, System.IO.Path.Combine(ws.Root.FullName, x.Value.Location)); } else { include = Filter(new KeyValuePair <string, object>[] { new KeyValuePair <string, object>(x.Value.Location, new object()) }).FirstOrDefault().Value != null; } if (include) { System.IO.DirectoryInfo directory = new System.IO.DirectoryInfo(System.IO.Path.Combine(Workspace.Root.FullName, x.Value.Location)); if (directory.Exists) { Printer.WriteLineMessage("\nExternal #c#{0}## ({1}):", x.Key, x.Value.Location); new Status() { DirectExtern = true }.Run(directory, options); } else { Printer.WriteLineMessage("\nExternal #c#{0}## ({1}): #e#missing##", x.Key, x.Value.Location); } } } var heads = Workspace.GetBranchHeads(Workspace.CurrentBranch); if (Workspace.CurrentBranch.Terminus.HasValue) { Printer.WriteLineMessage("\n #w#Warning:## Current branch \"#b#{0}##\" has been marked as deleted.", Workspace.CurrentBranch.Name); if (Workspace.CurrentBranch.Terminus.Value == Workspace.Version.ID) { Printer.PrintMessage("You are on the final revision of this branch."); } } else if (heads.Count == 0) { Printer.WriteLineMessage("\n #w#Warning:## Current branch \"#b#{0}##\" does not have a head!", Workspace.CurrentBranch.Name); } else if (heads.Count != 1 || heads[0].Version != Workspace.Version.ID) { if (heads.Count == 1) { Printer.WriteLineMessage("\n #w#Warning:## Current version is not the head of branch \"#b#{0}##\"!", Workspace.CurrentBranch.Name); } else if (heads.Count > 1 && heads.Any(x => x.Version == Workspace.Version.ID)) { Printer.WriteLineMessage("\n #w#Warning:## Branch \"#b#{0}##\" has multiple heads. Current version is one of #b#{1}## heads!", Workspace.CurrentBranch.Name, heads.Count); int mergeHeadCount = 0; var mergeInputs = Workspace.StagedMergeInputs; foreach (var mi in mergeInputs) { if (heads.Any(h => h.Version == mi)) { mergeHeadCount++; } } if (mergeHeadCount == heads.Count - 1) { Printer.WriteLineMessage(" - When the current version is committed, #s#all## heads will be reconciled."); } else if (mergeHeadCount != 0) { Printer.WriteLineMessage(" - When the current version is committed, #w#{0}# additional heads will be reconciled.", mergeHeadCount); } } else if (heads.Count > 1) { Printer.WriteLineMessage("\n #w#Warning:## Branch \"#b#{0}##\" has multiple heads. Current version is #w#not## one of the #b#{1}## heads!", Workspace.CurrentBranch.Name, heads.Count); } Printer.WriteLineMessage("\n Heads of #b#\"{0}\"##:", Workspace.CurrentBranch.Name); foreach (var x in heads) { var v = Workspace.GetVersion(x.Version); Printer.WriteLineMessage(" #b#{0}##: {1} by {2}", v.ShortName, v.Timestamp, v.Author); } } return(true); }
protected abstract bool RunInternal(Area ws, Versionr.Status status, IList <Versionr.Status.StatusEntry> targets, FileBaseCommandVerbOptions options);
protected override bool RunInternal(Area ws, Versionr.Status status, IList <Versionr.Status.StatusEntry> targets, FileBaseCommandVerbOptions options) { ResolveVerbOptions localOptions = options as ResolveVerbOptions; ws.Resolve(targets, UnrecordFeedback); return(true); }
protected override bool RunInternal(Area ws, Versionr.Status status, IList <Versionr.Status.StatusEntry> targets, FileBaseCommandVerbOptions options) { UnrecordVerbOptions localOptions = options as UnrecordVerbOptions; ws.Revert(targets, false, localOptions.Interactive, false, UnrecordFeedback); return(true); }
protected virtual bool ComputeTargets(FileBaseCommandVerbOptions localOptions) { return(base.ComputeTargets(localOptions) || localOptions.Recorded || localOptions.Tracked); }