D6082: phabricator: add a `--branch` flag to `hg phabsend`

pulkit (Pulkit Goyal) phabricator at mercurial-scm.org
Thu Mar 7 14:00:01 UTC 2019


pulkit created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  One of the existing problems with using phabricator for us is that there is no
  way to specify that the revision/patch/differential is intended for stable
  branch.
  
  This patch adds a new flag `--branch` to `hg phabsend` command. If the
  `--branch` is passed, `hg phabsend` will add a comment to the related
  differential saying that `The review is intended for a <branch-name> branch`.
  
  I looked into other API's which we can use or other properties which can be used
  to put the branch info and didn't found anything quite useful.
  
  Future improvement can be checking the branch of the patch and commenting that
  branch name.
  
  I am not sure how to add tests for this. I tested this patch while sending this
  patch.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D6082

AFFECTED FILES
  hgext/phabricator.py

CHANGE DETAILS

diff --git a/hgext/phabricator.py b/hgext/phabricator.py
--- a/hgext/phabricator.py
+++ b/hgext/phabricator.py
@@ -465,6 +465,7 @@
 
 @vcrcommand(b'phabsend',
          [(b'r', b'rev', [], _(b'revisions to send'), _(b'REV')),
+          (b'', b'branch', b'', _(b'comments review is for specific branch')),
           (b'', b'amend', True, _(b'update commit messages')),
           (b'', b'reviewer', [], _(b'specify reviewers')),
           (b'', b'confirm', None, _(b'ask for confirmation before sending'))],
@@ -496,6 +497,15 @@
 
     phabsend will check obsstore and the above association to decide whether to
     update an existing Differential Revision, or create a new one.
+
+    When working with multiple named branches, one can specify which branch your
+    reviews/differentials are intended for using --branch flag. Doing that,
+    phabsend will add a comment to your differential about that. For example::
+
+        `hg phabsend -r . --branch stable`
+
+    This will upload the parent of working directory and will add a comment on
+    related differential saying "This review is intented for stable branch".
     """
     revs = list(revs) + opts.get(b'rev', [])
     revs = scmutil.revrange(repo, revs)
@@ -524,6 +534,10 @@
     drevids = [] # [int]
     diffmap = {} # {newnode: diff}
 
+    bmsg = None
+    if opts.get(b'branch'):
+        bmsg = b"This review is intended for `%s` branch." % opts[b'branch']
+
     # Send patches one by one so we know their Differential Revision IDs and
     # can provide dependency relationship
     lastrevid = None
@@ -570,6 +584,12 @@
         drevids.append(newrevid)
         lastrevid = newrevid
 
+        if bmsg:
+            # comment on the new differential created the this review is for
+            # this certain branch
+            callconduit(repo, b'differential.createcomment',
+                        {b'revision_id': newrevid, b'message': bmsg})
+
     # Update commit messages and remove tags
     if opts.get(b'amend'):
         unfi = repo.unfiltered()



To: pulkit, #hg-reviewers
Cc: mercurial-devel


More information about the Mercurial-devel mailing list