Jens Alfke avatar Jens Alfke committed 763d5ad

* The "Discard Changes" command no longer uses the --no-backup option to 'hg revert', unless the 'RevertWithoutBackup' user default is set. (There's no UI for this yet.)
* Don't display '*.orig' files left behind by 'hg revert'.

Comments (0)

Files changed (4)

                 NSString *path = [line substringFromIndex: 2];
                 if( myPath.length > 0 && ! [path hasPrefix: myPath] )
                     continue;
+                else if (status == kNotTracked && [path hasSuffix: @".orig"]) {
+                    // Ignore .orig files not in repo; they're backups from 'hg revert'.
+                    LogTo(HgFile,@"Ignoring backup: %@", line);
+                    continue;
+                }
+                // OK, add/update it:
                 path = [path substringFromIndex: myPath.length];
-                
                 HgFile *file = [self addFileWithPath: path];
                 file.status = status;
                 [oldFiles removeObject: file];
-                //Log(@"    %c %@", file.status,file.path);
+                LogTo(HgFile,@"    %c %@", file.status,file.path);
             }
         }
     }

Source/HgUncommittedRevision.h

 
 - (BOOL) addFiles: (NSArray*)files error: (NSError**)outError;
 - (BOOL) removeFiles: (NSArray*)files error: (NSError**)outError;
-- (BOOL) revertFiles: (NSArray*)files error: (NSError**)outError;
+- (BOOL) revertFiles: (NSArray*)files
+              backup: (BOOL)backup
+               error: (NSError**)outError;
 
 - (BOOL) commitFiles: (NSArray*)files           // nil means to commit everything
              message: (NSString*)message 

Source/HgUncommittedRevision.m

     return YES;
 }
 
-- (BOOL) revertFiles: (NSArray*)files error: (NSError**)outError
+- (BOOL) revertFiles: (NSArray*)files backup: (BOOL)backup error: (NSError**)outError
 {
     return [self applyCommand: @"revert"
-                    arguments: [NSArray arrayWithObjects: @"--no-backup", nil]
+                    arguments: (backup ?nil :$array(@"--no-backup"))
                       toFiles: files
                         error: outError];
 }

Source/RepoController_Actions.m

 #import "URLFormatter.h"
 
 
+#define kPrefRevertWithoutBackup @"RevertWithoutBackup"
+
+
 @implementation RepoController (Actions)
 
 
 {
     [sheet orderOut: self];
     if( returnCode == NSOKButton ) {
+        BOOL backup = ! [[NSUserDefaults standardUserDefaults] boolForKey: kPrefRevertWithoutBackup];
         NSError *error = nil;
-        if( ! [_repo.uncommittedRevision revertFiles: (NSArray*)context error: &error] ) {
+        if( ! [_repo.uncommittedRevision revertFiles: (NSArray*)context
+                                              backup: backup
+                                               error: &error] ) {
             [self presentError: error];
         }
     }
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.