private bool DoSync(IEnumerable <IResource> resources) { if (!CanUseSourceControl) { return(false); } using (new ProgressBarWrapper("Syncing...")) { foreach (var resource in resources) { SledOutDevice.OutLine( SledMessageType.Info, "{0}: Syncing: {1}", SourceControlText, GetUriRelPath(resource)); if (!SourceControlService.IsSynched(resource.Uri)) { SourceControlService.GetLatestVersion(resource.Uri); } } } return(true); }
public CheckInViewModel(SourceControlService sourceControlService, IEnumerable <IResource> toCheckIn) { Title = "Check In Files".Localize(); m_sourceControlService = sourceControlService; m_checkInItems = toCheckIn.Select(x => new CheckInItem(this, x)).ToList(); Items = new ListCollectionView(m_checkInItems); }
private bool DoCommandHelper(Command cmd, ISourceControlContext context) { if (SourceControlService == null) { return(false); } if (cmd == Command.Enabled) { SourceControlService.Enabled = !SourceControlService.Enabled; return(true); } if (cmd == Command.Connection) { SourceControlService.Connect(); return(true); } if (!CanUseSourceControl) { return(false); } if (context == null) { return(false); } switch (cmd) { case Command.Add: return(false); case Command.CheckIn: return(DoCheckIn(context.Resources)); case Command.CheckOut: return(DoCheckOut(context.Resources)); case Command.Revert: return(DoRevert(context.Resources)); case Command.Refresh: return(DoRefresh(context.Resources)); case Command.Sync: return(DoSync(context.Resources)); case Command.History: return(DoHistory(context.Resources)); } return(false); }
public ReconcileViewModel(SourceControlService sourceControlService, IEnumerable <Uri> modified, IEnumerable <Uri> notInDepot) { Title = "Reconcile Offline Work".Localize(); m_sourceControlService = sourceControlService; m_modified = modified.Select(x => new CheckableItem(this, x)).ToList(); m_notInDepot = notInDepot.Select(x => new CheckableItem(this, x)).ToList(); Modified = new ListCollectionView(m_modified); NotInDepot = new ListCollectionView(m_notInDepot); }
private bool DoHistory(IEnumerable <IResource> resources) { if (!CanUseSourceControl) { return(false); } var tables = new DataTable[resources.Count()]; for (var i = 0; i < tables.Length; i++) { tables[i] = SourceControlService.GetRevisionLog(resources.ElementAt(i).Uri); } for (var i = 0; i < tables.Length; i++) { using (var dialog = new SledSourceControlHistoryForm()) { dialog.Uri = resources.ElementAt(i).Uri; foreach (DataRow row in tables[i].Rows) { // How row is created in P4 plugin /* * DataRow row = p4DataTable.NewRow(); * row["revision"] = Int32.Parse(change); * row["user"] = user; * row["description"] = desc; * row["status"] = status; * row["client"] = client; * row["time"] = date; */ // NOTE: These might not match what SVN uses for its row keys (!) dialog.AddEntry( new SledSourceControlHistoryForm.Entry { Revision = (int)row["revision"], User = (string)row["user"], Description = (string)row["description"], Status = (string)row["status"], Client = (string)row["client"], Date = (DateTime)row["time"] }); } dialog.ShowDialog(m_mainForm); } } return(true); }
public SourceControlStatus GetStatus(IResource sc) { if (sc == null) { return(SourceControlStatus.FileDoesNotExist); } return (!CanUseSourceControl ? SourceControlStatus.FileDoesNotExist : SourceControlService.GetStatus(sc.Uri)); }
/// <summary> /// Perform the Reconcile command</summary> /// <param name="doing">True to perform the Reconcile; false to test whether Reconcile can be done</param> /// <returns>True iff Reconcile can be done or was done</returns> protected override bool DoReconcile(bool doing) { if (SourceControlService == null || SourceControlContext == null) { return(false); } if (!doing) { return(SourceControlContext.Resources.Any()); } var uris = SourceControlContext.Resources.Select(resource => resource.Uri).ToList(); var modified = new List <Uri>(); var localNotInDepot = new List <Uri>(); //using (new WaitCursor()) { foreach (Uri uri in SourceControlService.GetModifiedFiles(uris)) { if (SourceControlService.GetStatus(uri) != SourceControlStatus.CheckedOut) { modified.Add(uri); } } foreach (Uri uri in uris) { if (!modified.Contains(uri)) { if (SourceControlService.GetStatus(uri) == SourceControlStatus.NotControlled) { localNotInDepot.Add(uri); } } } } var vm = new ReconcileViewModel(SourceControlService, modified, localNotInDepot); DialogUtils.ShowDialogWithViewModel <ReconcileDialog>(vm); return(true); }
private bool DoRefresh(IEnumerable <IResource> resources) { if (!CanUseSourceControl) { return(false); } using (new ProgressBarWrapper("Refreshing...")) { foreach (var resource in resources) { SledOutDevice.OutLine( SledMessageType.Info, "{0}: Refreshing: {1}", SourceControlText, GetUriRelPath(resource)); SourceControlService.RefreshStatus(resource.Uri); } } return(true); }
private bool DoCheckOut(IEnumerable <IResource> resources) { if (!CanUseSourceControl) { return(false); } var lstNeedResolves = new List <IResource>(); using (new ProgressBarWrapper("Checking out...")) { SledOutDevice.OutLine( SledMessageType.Info, "{0}: Refreshing {1} item(s)...", SourceControlText, resources.Count()); SourceControlService.RefreshStatus(resources.Select(r => r.Uri)); foreach (var resource in resources) { if (!SourceControlService.IsSynched(resource.Uri)) { SledOutDevice.OutLine( SledMessageType.Info, "{0}: Need user resolution: {1}", SourceControlText, GetUriRelPath(resource)); lstNeedResolves.Add(resource); } else { SledOutDevice.OutLine( SledMessageType.Info, "{0}: Checking out: {1}", SourceControlText, GetUriRelPath(resource)); SourceControlService.CheckOut(resource.Uri); } } } if (lstNeedResolves.Count <= 0) { return(true); } foreach (var resource in lstNeedResolves) { using (var dialog = new SledSourceControlResolutionForm()) { // Default action var choice = SledSourceControlResolutionForm.UserChoice.EditCurrent; dialog.Uri = resource.Uri; if (dialog.ShowDialog(m_mainForm) == DialogResult.OK) { choice = dialog.Choice; } // Do something based off of choice switch (choice) { case SledSourceControlResolutionForm.UserChoice.EditCurrent: { SledOutDevice.OutLine( SledMessageType.Info, "{0}: Checking out: {1}", SourceControlText, GetUriRelPath(resource)); SourceControlService.CheckOut(resource.Uri); } break; case SledSourceControlResolutionForm.UserChoice.GetLatest: DoSync(new[] { resource }); break; } } } return(true); }