alu  committed cbcbf75

added --purgestash option to task
added --purge optoin to debugtask

  • Participants
  • Parent commits 9cdc962

Comments (0)

Files changed (1)

File hgext/

 def task(ui, repo, task=None, rev=None, force=False, delete=False, info=None, all=False, \
         complete=None, resume=None, delete_all=False, delete_complete=False, \
-        rename=None, trim=None, append=None ):
+        rename=None, trim=None, append=None, purge_stash=False ):
     '''mercurial tasks
     Tasks are collections of contiguous changesets.  A task can be short or long
     tasks = parse(repo)
     # all these options need a valid task name
-    if delete or info or complete or resume or trim or append:
+    if delete or info or complete or resume or trim or append or (purge_stash and not all):
         if task == None:
             raise util.Abort(_("task name required"))
         if task not in tasks:
             raise util.Abort(_("a task of this name does not exist"))
     # all these options don't want a task
-    if delete_all or delete_complete:
+    if delete_all or delete_complete or (purge_stash and all):
         if task:
             raise util.Abort(_("no task name required for this option"))
     # check for force when deleting tasks with stash
     if delete_all or delete_complete or delete:
         if not force:
         write(ui, repo, tasks)
+    # purge stash
+    if purge_stash:
+        purgetasks = all and tasks or [ task ]
+        for t in purgetasks:
+            removestashfiles(repo, t)
+        return
     # create a task
     if task != None:
         if "\n" in task:
     return res
-def debugtask(ui, repo, task=None, showstash=False):
-    '''show tasks debug info'''
+def debugtask(ui, repo, task=None, showstash=False, purge=False, force=False):
+    '''tasks debug'''
     def showtask(ui, repo, tname, tinfo):
         ui.write("%s\n" % tname)
         for sf in stashfiles(repo, tname):
             showstashfile(ui, repo, sf)
+    if purge and not force:
+        raise util.Abort(_("this will wipe out all your tasks info, the entire\n.hg/tasks directory, if you're sure, use -f to force"))
+    if purge:
+        for f in os.listdir(repo.join('tasks')):
+            os.unlink("%s/%s" % (repo.join('tasks'), f))
+        os.rmdir(repo.join('tasks'))
+        return
     if showstash and not task:
         raise util.Abort(_("must specify task with --showstash"))
                 ('i', 'info', False, _('gives info a given task')),
                 ('a', 'all', False, _('all tasks including completed tasks')),
                 ('n', 'append', False, _('append revisions to task')),
-                ('t', 'trim', False, _('trim revisions from given task'))
+                ('t', 'trim', False, _('trim revisions from given task')),
+                ('',  'purge-stash', False, _('purge stash information from given task'))
             _('hg tasks [-f] [-d] [-i] [-c] [-u] [-A] [-C] [-i] [-a] [-m OLDNAME NEWNAME] [-r REV] [NAME] [-t REV] [-n REV]')),
-                ('',  'showstash', False, _('show stash info'))
+                ('',  'showstash', False, _('show stash info')),
+                ('',  'purge', False, _('purge all tasks')),
+                ('f', 'force', False, _('force'))
-            _('hg debugtasks [-f] [--showstash] [remove] [NAME]')),
+            _('hg debugtasks [-f] [--showstash] [--purge] [NAME]')),