anatoly techtonik  committed 1aa64f9 Draft option refactoring

change options of from:

1. on first submission
-m, --message gives an issue a title
-d, adds description to an issue
2. on issue update
-m, --message gives title to a patchset
-d ??? updates description ???


1. on first submission
-t, --title issue subject
-m, --message issue description
-F, --file <file> read description from file
2. on issue update
-t, --title new patchset title
-m, --message message to reviewers
-F, --file <file> read message from file

Review URL:


  • Participants
  • Parent commits 150c416

Comments (0)

Files changed (1)

                        "valid choices are 'GOOGLE' and 'HOSTED')."))
 # Issue
 group = parser.add_option_group("Issue options")
-group.add_option("-d", "--description", action="store", dest="description",
-                 metavar="DESCRIPTION", default=None,
-                 help="Optional description when creating an issue.")
-group.add_option("-f", "--description_file", action="store",
-                 dest="description_file", metavar="DESCRIPTION_FILE",
+group.add_option("-t", "--title", action="store", dest="title",
+                 help="New issue subject or new patch set title")
+group.add_option("-m", "--message", action="store", dest="message",
-                 help="Optional path of a file that contains "
-                      "the description when creating an issue.")
+                 help="New issue description or new patch set message")
+group.add_option("-F", "--file", action="store", dest="file",
+                 default=None, help="Read the message above from file.")
 group.add_option("-r", "--reviewers", action="store", dest="reviewers",
                  metavar="REVIEWERS", default=None,
                  help="Add reviewers (comma separated email addresses).")
                  help="Make the issue restricted to reviewers and those CCed")
 # Upload options
 group = parser.add_option_group("Patch options")
-group.add_option("-m", "--message", action="store", dest="message",
-                 metavar="MESSAGE", default=None,
-                 help="A message to identify the patch. "
-                      "Will prompt if omitted.")
 group.add_option("-i", "--issue", type="int", action="store",
                  metavar="ISSUE", default=None,
                  help="Issue number to which to add. Defaults to new issue.")
-    if not options.message:
+    if not options.title:
       description = self.RunPerforceCommand(["describe", self.p4_changelist],
       if description and "desc" in description:
         # Rietveld doesn't support multi-line descriptions
-        raw_message = description["desc"].strip()
-        lines = raw_message.splitlines()
+        raw_title = description["desc"].strip()
+        lines = raw_title.splitlines()
         if len(lines):
-          options.message = lines[0]
+          options.title = lines[0]
   def GetGUID(self):
     """For now we don't know how to get repository ID for Perforce"""
   if verbosity >= 1:
     print "Upload server:", options.server, "(change with -s/--server)"
   if options.issue:
-    prompt = "Message describing this patch set: "
+    prompt = "Title describing this patch set: "
     prompt = "New issue subject: "
-  message = options.message or raw_input(prompt).strip()
-  if not message:
-    ErrorExit("A non-empty message is required")
+  title = options.title or raw_input(prompt).strip()
+  if not title:
+    ErrorExit("A non-empty title is required")
   rpc_server = GetRpcServer(options.server,
-  form_fields = [("subject", message)]
+  form_fields = [("subject", title)]
   repo_guid = vcs.GetGUID()
   if repo_guid:
     for cc in','):
-  description = options.description
-  if options.description_file:
-    if options.description:
-      ErrorExit("Can't specify description and description_file")
-    file = open(options.description_file, 'r')
-    description =
+  message = options.message
+  if options.file:
+    if options.message:
+      ErrorExit("Can't specify both message and message file options")
+    file = open(options.file, 'r')
+    message =
-  if description:
-    form_fields.append(("description", description))
+  if message:
+    if not options.issue:
+      form_fields.append(("description", message))
+    else:
+      # TODO: [ ] figure out how to send a comment from
+      pass
   # Send a hash of all the base file so the server can determine if a copy
   # already exists in an earlier patchset.
   base_hashes = ""