Commits

Anonymous committed 4ff7498

Added --all option to shelve all changes without prompting

Comments (0)

Files changed (1)

         state = newstate
     return p.finished()
 
-def filterpatch(ui, chunks):
+def filterpatch(ui, chunks, shouldprompt=True):
     chunks = list(chunks)
     chunks.reverse()
     seen = {}
             else:
                 consumed.append(chunks.pop())
         return consumed
+    
     resp_all = [None]
+
+    # If we're not to prompt (i.e. they specified the --all flag) we pre-emptively set the 'all' flag
+    if shouldprompt == False:
+        resp_all = ['y']
+    
     resp_file = [None]
     applied = {}
     def prompt(query):
             seen[hdr] = True
             if resp_all[0] is None:
                 chunk.pretty(ui)
-            r = prompt(_('shelve changes to %s?') %
+            if shouldprompt == True:
+                r = prompt(_('shelve changes to %s?') %
                        _(' and ').join(map(repr, chunk.files())))
+            else:
+                r = 'y'
+            
             if r == 'y':
                 applied[chunk.filename()] = [chunk]
                 if chunk.allhunks():
         fp = cStringIO.StringIO(patch_diff)
         ac = parsepatch(fp)
         fp.close()
-        chunks = filterpatch(ui, ac)
+        
+        chunks = filterpatch(ui, ac, not opts['all'])
         rc = refilterpatch(ac, chunks)
 
         contenders = {}
            _('overwrite existing shelve data')),
           ('a', 'append', None,
            _('append to existing shelve data')),
+          ('', 'all', None,
+           _('shelve all changes')),
          ] + commands.walkopts,
          _('hg shelve [OPTION]... [FILE]...')),
     "unshelve":