Michael Diamond  committed a106b8e

Added -e flag to launch editor automatically

  • Participants
  • Parent commits 97c0153

Comments (0)

Files changed (3)

 Files should be added to mercurial at the end, not the begining of the call | owner:Michael, open:False, id:6ba1ae74c48a6fd84c5d0698fa8169a28e88b343, time:1277680246.97
 hg b help should exist, and point to hg help b               | owner:Michael, open:False, id:7e79f51975af54656f9afdf6958df40c812b5278, time:1319064278.86
 Config / CLI parameter to auto-create details file on add    | owner:Michael, open:True, id:8307524a05a75d607ae6f9922ae55abf26627130, time:1324634082.58
-add a -e flag to add to launch details editor                | owner:Michael, open:True, id:87d6567124da5d70714771733f2ba6aca1f5cfee, time:1324633981.08
+add a -e flag to add to launch details editor                | owner:Michael, open:False, id:87d6567124da5d70714771733f2ba6aca1f5cfee, time:1324633981.08
 Use consistent EOL markers and set up a .hgeol file          | owner:Michael, open:False, id:884b4c3360aa89bbd841013a6cf34bc904dcc3b5, time:1313353463.53
-Add optional commented out fields to default details file    | owner:Michael, open:True, id:9ce51de4c80014f8cf09e97041a8ae1d9cc001e4, time:1324634131.06
+Add optional commented out fields to default details file    | owner:Michael, open:False, id:9ce51de4c80014f8cf09e97041a8ae1d9cc001e4, time:1324634131.06
 Bugs with no details but a details file should act like there is not details file | owner:Michael, open:False, id:9f771c1b687a119eb8e6f9a8443f2c0dde30776b, time:1277680715.42
 edit doesn't handle editors with spaces properly             | owner:Michael, open:False, id:aad16b3f42cade7b71eb1cc92c490f77c7366084, time:1310458238.24
 adding a long issue rewrites entire bugs file to align metadata | owner:Michael, open:False, id:b2f52086a6ca25bc3f9c131e8ded23d474b9a11d, time:1319079486.17

File src/
         self.assertEqual(, 'd - test|with"bars,and\'other\t'
                          'potentially#bad{characters}\nFound 1 open bug')
+        self.assertEqual(,'deea8c528cd4fe5ff34b3a15bb97de097d99c4f2')
     def test_rename(self):
         self.user = user
         self.file = 'bugs'
         self.detailsdir = 'details'
+        self.last_added_id = None
         self.bugs = {}
         # this is the default contents of the bugs directory.  If you'd like, you can
         # modify this variable's contents.  Be sure to leave [comments] as the last field.
         "[reproduce]\n# Reproduction steps\n\n",
         "[comments]\n# Comments and updates - leave your name"
         path = os.path.join(os.path.expanduser(self.bugsdir), self.file)
         if os.path.isdir(path):
             raise InvalidTaskfile(_("The path where the bugs database should be is blocked and cannot be created."))
         global _simple_hash
         task_id = _hash(text) if _simple_hash else _hash(text+self.user+str(time.time()))
         self.bugs[task_id] = {'id': task_id, 'open': 'True', 'owner': self.user, 'text': text, 'time': time.time()}
+        self.last_added_id = task_id
         return _("Added bug %s...") % task_id[:10]
     def rename(self, prefix, text):
     List of Commands::
-    add text
+    add text [-e]
         Adds a new open bug to the database, if user is set in the config files, assigns it to user
-    rename prefix text
+        -e here and elsewhere launches the details editor for the issue upon successful execution of the command
+    rename prefix text [-e]
         Renames The bug denoted by prefix to text.   You can use sed-style substitution strings if so desired.
     users [--rev rev]
         Displays a list of all users, and the number of open bugs assigned to each of them
-    assign prefix username [-f]
+    assign prefix username [-f] [-e]
         Assigns bug denoted by prefix to username.  Username can be a lowercase prefix of
         another username and it will be mapped to that username.  To avoid this functionality
         and assign the bug to the exact username specified, or if the user does not already
         Use 'me' to assign the bug to the current user,
         and 'Nobody' to remove its assignment.
-    details [--rev rev] prefix
+    details [--rev rev] prefix [-e]
         Prints the extended details of the specified bug
     edit prefix
         Launches your specified editor to provide additional details 
-    comment prefix comment
+    comment prefix comment [-e]
         Appends comment to the details of the bug, along with the date
         and, if specified, your username without needing to launch an editor
-    resolve prefix
+    resolve prefix [-e]
         Marks the specified bug as resolved
-    reopen prefix
+    reopen prefix [-e]
         Marks the specified bug as open
     list [--rev rev] [-r] [-o owner] [-g search] [-a|-c]
             -c list bugs chronologically
-    id [--rev rev] prefix
+    id [--rev rev] prefix [-e]
         Takes a prefix and returns the full id of that bug
             raise NonReadOnlyCommand(cmd)
+        # launch the editor - will fail on commands that don't have an issue prefix
+        if cmd != 'edit' and opts['edit']:
+            if opts['rev']:
+                raise NonReadOnlyCommand('edit')
+            if cmd == 'add':
+                id = bd.last_added_id
+            cmds['edit']()
         # Add all new files to Mercurial - does not commit
         if not opts['rev']:
 cmdtable = {"b|bug|bugs": (cmd,[
                                 ('f', 'force', False, _('Force this exact username')),
+                                ('e', 'edit', False, _('Launch details editor after running command')),
                                 ('r', 'resolved', False, _('List resolved bugs')),
                                 ('o', 'owner', '*', _('Specify an owner to list by')),
                                 ('g', 'grep', '', _('Filter titles by STRING')),