Commits

Jason Harris committed 846fbb0

- Fix glitch pointed out by Scott Palmer to do with displaying the update sheet followed
by the update alert.
- Previously the update sheet will always present a confirmation dialog. And the dialog
had a button "Options..." which just redirected back to the update sheet. So now only
show the "do you really want to update" dialog only when there are uncommitted changes.
Also remove the "Options..." button from the dialog when we have just come from the
update sheet.

Comments (0)

Files changed (5)

Classes/Document/MacHgDocument.h

 - (BOOL)		showingFilesOrDifferencesView;
 - (BOOL)		showingFilesOrHistoryOrDifferencesView;
 - (BOOL)		showingASheet;
+- (BOOL)		showingSheetOf:(NSWindowController*)controller;
 - (PaneViewNum)	currentPane;
 - (void)		setCurrentPane:(PaneViewNum)paneNum;
 - (IBAction)	actionSwitchViewToFilesView:(id)sender;
 - (BOOL)		primaryActionIgnoreSelectedFiles:(NSArray*)theSelectedFiles;
 - (BOOL)		primaryActionUnignoreSelectedFiles:(NSArray*)theSelectedFiles;
 - (BOOL)		primaryActionAnnotateSelectedFiles:(NSArray*)theSelectedFiles;
-- (BOOL)		primaryActionUpdateFilesToVersion:(NSNumber*)version withCleanOption:(BOOL)clean;
+- (BOOL)		primaryActionUpdateFilesToVersion:(NSNumber*)version withCleanOption:(BOOL)clean withConfirmation:(BOOL)confirm;
 - (BOOL)		primaryActionBackoutFilesToVersion:(NSNumber*)version;
 - (BOOL)		primaryActionMergeWithVersion:(NSNumber*)mergeVersion andOptions:(NSArray*)options withConfirmation:(BOOL)confirm;
 - (void)		primaryActionDisplayManifestForVersion:(NSNumber*)version;

Classes/Document/MacHgDocument.m

 - (BOOL)	showingFilesOrDifferencesView					{ return currentPane_ == eFilesView || currentPane_ == eDifferencesView; }
 - (BOOL)	showingFilesOrHistoryOrDifferencesView			{ return currentPane_ == eFilesView || currentPane_ == eHistoryView || currentPane_ == eDifferencesView; }
 - (BOOL)	showingASheet									{ return shownSheet_ != nil; }
+- (BOOL)	showingSheetOf:(NSWindowController*)controller	{ return shownSheet_ && ([controller window] == shownSheet_); }
 
 
 - (IBAction) actionSwitchViewToFilesView:(id)sender			{ [self setCurrentPane:eFilesView]; }
 // MARK: All Files Menu Actions
 // -----------------------------------------------------------------------------------------------------------------------------------------
 
-- (IBAction) mainMenuUpdateRepository:(id)sender				{ [self primaryActionUpdateFilesToVersion:[self getHGTipRevision] withCleanOption:NO]; }
+- (IBAction) mainMenuUpdateRepository:(id)sender				{ [self primaryActionUpdateFilesToVersion:[self getHGTipRevision] withCleanOption:NO withConfirmation:YES]; }
 - (IBAction) mainMenuUpdateRepositoryToVersion:(id)sender		{ [[self theUpdateSheetController] openUpdateSheetWithSelectedRevision:sender]; }
 - (IBAction) toolbarUpdate:(id)sender							{ [[self theUpdateSheetController] openUpdateSheetWithSelectedRevision:sender]; }
 
 }
 
 
-- (BOOL) primaryActionUpdateFilesToVersion:(NSNumber*)version withCleanOption:(BOOL)clean
+- (BOOL) primaryActionUpdateFilesToVersion:(NSNumber*)version withCleanOption:(BOOL)clean withConfirmation:(BOOL)confirm
 {
 	BOOL containsChangedFiles = [self repositoryHasFilesWhichContainStatus:eHGStatusCommittable];
-	if (DisplayWarningForUpdatingFromDefaults() || [self repositoryHasFilesWhichContainStatus:eHGStatusCommittable])
+	if ((confirm && DisplayWarningForUpdatingFromDefaults()) || containsChangedFiles)
 	{
 		NSString* mainMessage = @"Updating All Files";
 		NSString* subMessage  = fstr( @"Are you sure you want to update the repository “%@” to revision “%@”?",
 		if (containsChangedFiles)
 			subMessage = fstr(@"There are uncommitted changes. %@", subMessage);
 		
-		NSAlert* alert = NewAlertPanel(mainMessage, subMessage, @"Update", @"Cancel", @"Options…");
+		BOOL showingUpdateSheet = [self showingSheetOf:[self theUpdateSheetController]];
+		NSString* thirdButton = showingUpdateSheet ? nil : @"Options…";
+		NSAlert* alert = NewAlertPanel(mainMessage, subMessage, @"Update", @"Cancel", thirdButton);
 		[updateAlertAccessoryCleanCheckBox setState:clean];
+		[updateAlertAccessoryAlertSuppressionCheckBox setHidden:containsChangedFiles];
 		[updateAlertAccessoryAlertSuppressionCheckBox setState:NO];
 		[alert setAccessoryView:updateAlertAccessoryView];
 		int result = [alert runModal];

Classes/HistoryView/HistoryViewController.m

 - (IBAction) historyMenuUpdateRepositoryToChosenRevision:(id)sender
 {
 	NSNumber* theSelectedRevision = [[logTableView chosenEntry] revision];
-	[myDocument primaryActionUpdateFilesToVersion:theSelectedRevision withCleanOption:NO];
+	[myDocument primaryActionUpdateFilesToVersion:theSelectedRevision withCleanOption:NO withConfirmation:YES];
 }
 
 - (IBAction) historyMenuGotoChangeset:(id)sender
 			}
 			if (![[[myDocument repositoryData] getHGParent1Revision] isEqualToNumber:rev])
 			{
-				BOOL didUpdateToReversion = [myDocument primaryActionUpdateFilesToVersion:rev withCleanOption:NO];
+				BOOL didUpdateToReversion = [myDocument primaryActionUpdateFilesToVersion:rev withCleanOption:NO withConfirmation:YES];
 				if (!didUpdateToReversion)
 					return;
 			}
 {
 	LabelData* label = [theLabelsTableView_ chosenLabel];
 	[[[myDocument theHistoryView] logTableView] scrollToRevision:[label revision]];
-	[myDocument primaryActionUpdateFilesToVersion:[label revision] withCleanOption:NO];
+	[myDocument primaryActionUpdateFilesToVersion:[label revision] withCleanOption:NO withConfirmation:YES];
 }
 
 

Classes/Sheets/MoveLabelSheet/MoveLabelSheetController.m

 		{
 			if (![versionToRevertTo isEqualToNumber:[[myDocument repositoryData] getHGParent1Revision]])
 			{
-				BOOL updatedToTagetRev = [myDocument primaryActionUpdateFilesToVersion:versionToRevertTo withCleanOption:NO];
+				BOOL updatedToTagetRev = [myDocument primaryActionUpdateFilesToVersion:versionToRevertTo withCleanOption:NO withConfirmation:YES];
 				if (!updatedToTagetRev)
 					bailEarly = YES;
 			}

Classes/Sheets/UpdateSheet/UpdateSheetController.m

 - (IBAction) sheetButtonOk:(id)sender
 {
 	NSNumber* versionToUpdateTo = [logTableView selectedRevision];
-	BOOL didReversion = [myDocument primaryActionUpdateFilesToVersion:versionToUpdateTo withCleanOption:[self cleanUpdate]];
+	BOOL didReversion = [myDocument primaryActionUpdateFilesToVersion:versionToUpdateTo withCleanOption:[self cleanUpdate] withConfirmation:NO];
 	if (!didReversion)
 		return;