protected override bool RunInternal(IRemoteClient client, RemoteCommandVerbOptions options) { AheadVerbOptions localOptions = options as AheadVerbOptions; Info.DisplayInfo(client.Workspace); Objects.Branch desiredBranch = client.Workspace.CurrentBranch; if (!string.IsNullOrEmpty(localOptions.Branch)) { bool multiple; desiredBranch = client.Workspace.GetBranchByPartialName(localOptions.Branch, out multiple); if (desiredBranch == null) { Printer.PrintError("#e#Error:## Local branch #b#`{0}`## not found.", localOptions.Branch); return(false); } } var branches = client.ListBranches(); if (branches == null) { Printer.PrintError("#e#Error:## Server does not support branch list operation."); return(false); } foreach (var x in branches.Item1) { if (x.ID != desiredBranch.ID && !localOptions.AllBranches) { continue; } var localBranch = client.Workspace.GetBranch(x.ID); if (localOptions.AllBranches && localBranch == null && !localOptions.ShowUninteresting) { continue; } if (x.Terminus.HasValue && (!localOptions.AllBranches || localOptions.IncludeDeleted)) { bool present = client.Workspace.GetVersion(x.Terminus.Value) != null; Objects.Version terminus = null; branches.Item3.TryGetValue(x.Terminus.Value, out terminus); string presentMarker = present ? "" : " #w#(behind)##"; if (present && localBranch != null) { if (localBranch.Terminus.Value != x.Terminus.Value) { presentMarker += " #w#(ahead)##"; } else { if (localOptions.AllBranches && !localOptions.ShowUninteresting) { continue; } presentMarker += " #s#(up-to-date)##"; } } if (localBranch != null && !localBranch.Terminus.HasValue) { presentMarker += " #w#(not locally deleted)##"; } if (localBranch == null) { presentMarker += " #w#(not synchronized)##"; } string branchMarker = localOptions.AllBranches ? "#b#" + x.Name + "##" : ""; if (terminus == null) { Printer.PrintMessage("Remote - #e#(deleted)## {2} - Last version: #e#(unknown)## #b#{0}##{1}", x.Terminus.Value, presentMarker, branchMarker); } else { Printer.PrintMessage("Remote - #e#(deleted)## {4} - Last version: #b#{0}##{3}, #q#{2} {1}##", terminus.ShortName, terminus.Timestamp.ToLocalTime(), terminus.Author, presentMarker, branchMarker); } } foreach (var z in branches.Item2.Where(y => y.Key == x.ID)) { bool present = client.Workspace.GetVersion(z.Value) != null; string presentMarker = present ? "" : " #w#(behind)##"; if (present && localBranch != null) { var localHeads = client.Workspace.GetBranchHeads(localBranch); if (localHeads.Count == 1 && localHeads[0].Version != z.Value) { presentMarker += " #w#(ahead)##"; } else { if (localOptions.AllBranches && !localOptions.ShowUninteresting) { continue; } presentMarker += " #s#(up-to-date)##"; } } if (localBranch != null && localBranch.Terminus.HasValue) { presentMarker += " #e#(locally deleted)##"; } if (localBranch == null) { presentMarker += " #w#(not synchronized)##"; } string branchMarker = localOptions.AllBranches ? "#b#" + x.Name + "##" : ""; var head = branches.Item3[z.Value]; Printer.PrintMessage("Remote - #s#(active)## {4} - Version: #b#{0}##{3}, #q#{2} {1}##", head.ShortName, head.Timestamp.ToLocalTime(), head.Author, presentMarker, branchMarker); } } return(true); }
protected override bool RunInternal(IRemoteClient client, RemoteCommandVerbOptions options) { PullVerbOptions localOptions = options as PullVerbOptions; bool objects = true; if (localOptions.PullAll) { objects = false; } if (localOptions.List) { var branches = client.ListBranches(); if (branches == null) { return(false); } Printer.PrintMessage("Displaying remote branches:"); foreach (var x in branches.Item1) { if (!localOptions.Deleted && x.Terminus.HasValue) { continue; } string tipmarker = ""; if (x.ID == client.Workspace.CurrentBranch.ID) { tipmarker = " #w#*<current>##"; } Printer.PrintMessage("#b#{1}## - #c#{0}##{2}", x.ID, x.Name, tipmarker); string heading = string.Empty; var localBranch = client.Workspace.GetBranch(x.ID); if (x.Terminus.HasValue) { Objects.Version terminus = null; bool present = client.Workspace.GetVersion(x.Terminus.Value) != null; string presentMarker = present ? "" : " #w#(behind)##"; if (!branches.Item3.TryGetValue(x.Terminus.Value, out terminus)) { Printer.PrintMessage(" #e#(deleted)## - #w#(no data)##"); continue; } if (present && localBranch != null) { if (localBranch.Terminus.Value != x.Terminus.Value) { presentMarker += " #w#(ahead)##"; } } if (localBranch != null && !localBranch.Terminus.HasValue) { presentMarker += " #w#(not locally deleted)##"; } if (localBranch == null) { presentMarker += " #w#(not synchronized)##"; } Printer.PrintMessage(" #e#(deleted)## - Last version: #b#{0}##{3}, #q#{2} {1}##", terminus.ShortName, terminus.Timestamp.ToLocalTime(), terminus.Author, presentMarker); } foreach (var z in branches.Item2.Where(y => y.Key == x.ID)) { bool present = client.Workspace.GetVersion(z.Value) != null; string presentMarker = present ? "" : " #w#(behind)##"; if (present && localBranch != null) { var localHeads = client.Workspace.GetBranchHeads(localBranch); if (localHeads.Count == 1 && localHeads[0].Version != z.Value) { presentMarker += " #w#(ahead)##"; } } if (localBranch != null && localBranch.Terminus.HasValue) { presentMarker += " #e#(locally deleted)##"; } if (localBranch == null) { presentMarker += " #w#(not synchronized)##"; } var head = branches.Item3[z.Value]; Printer.PrintMessage(" #s#(head)## - Version: #b#{0}##{3}, #q#{2} {1}##", head.ShortName, head.Timestamp.ToLocalTime(), head.Author, presentMarker); } } return(true); } if (!client.Pull(localOptions.PullObjects.HasValue ? localOptions.PullObjects.Value : objects, localOptions.RemoteBranch, localOptions.PullAll, localOptions.AcceptDeletes)) { return(false); } if (localOptions.Update) { client.Workspace.Update(new Area.MergeSpecialOptions()); } return(true); }