reviewboard: use parse_commit_id (bug 1245589); r?dminor draft
authorGregory Szorc <gps@mozilla.com>
Wed, 03 Feb 2016 11:21:09 -0800
changeset 7134 86b45eac2461343ac71bc7f6c14235e1a89d97b8
parent 7133 351b30e32e1c38b6e5f439afdb83a6279368db84
child 7135 c81a1a9a085e287c65f1088aac6051ab0d91800e
push id599
push usergszorc@mozilla.com
push dateFri, 05 Feb 2016 23:51:45 +0000
reviewersdminor
bugs1245589
reviewboard: use parse_commit_id (bug 1245589); r?dminor We have a dedicated function for this now. Use it. Also convert the description to a str so we are passing around the raw bytes as opposed to whatever Mercurial has munged it to for local representation. MozReview-Commit-ID: 3fXxsiMak9Q
hgext/reviewboard/client.py
--- a/hgext/reviewboard/client.py
+++ b/hgext/reviewboard/client.py
@@ -18,17 +18,16 @@ This extension adds new options to the `
   * --reviewid The review identifier to use. Pushes using the same
     review ID will overwrite existing reviews for that ID.
   * -c Single changeset to review.
 """
 
 import errno
 import json
 import os
-import re
 import sys
 import urllib
 import urllib2
 
 from mercurial import (
     cmdutil,
     commands,
     context,
@@ -63,17 +62,20 @@ except ImportError:
     import hgrb.proto
 demandimport.enable()
 
 from hgrb.util import (
     addcommitid,
     ReviewID,
 )
 
-from mozautomation.commitparser import parse_bugs
+from mozautomation.commitparser import (
+    parse_bugs,
+    parse_commit_id,
+)
 from mozhg.auth import (
     getbugzillaauth,
     configureautobmoapikeyauth,
 )
 from mozhg.rewrite import (
     newparents,
     replacechangesets,
 )
@@ -394,17 +396,17 @@ def wrappedpushdiscovery(orig, pushop):
             raise util.Abort(
                     _('cannot review empty changeset %s') % ctx.hex()[:12],
                     hint=_('add files to or remove changeset'))
 
     # Ensure all reviewed changesets have commit IDs.
     replacenodes = []
     for node in nodes:
         ctx = repo[node]
-        if not re.search('^MozReview-Commit-ID: ', ctx.description(), re.MULTILINE):
+        if not parse_commit_id(encoding.fromlocal(ctx.description())):
             replacenodes.append(node)
 
     def makememctx(repo, ctx, revmap, copyfilectxfn):
         parents = newparents(repo, ctx, revmap)
         # Need to make a copy otherwise modification is made on original,
         # which is just plain wrong.
         msg = encoding.fromlocal(ctx.description())
         new_msg, changed = addcommitid(msg, repo=repo)