Patchwork D1802: Add a template item for linking to a differential review.

login
register
mail settings
Submitter phabricator
Date Jan. 2, 2018, 5:09 p.m.
Message ID <differential-rev-PHID-DREV-s6k7wxz6d2bbonv3dpgk-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/26524/
State Superseded
Headers show

Comments

phabricator - Jan. 2, 2018, 5:09 p.m.
tom.prince created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  contrib/phabricator.py

CHANGE DETAILS




To: tom.prince, #hg-reviewers
Cc: mercurial-devel
phabricator - Jan. 10, 2018, 8:48 a.m.
pulkit added inline comments.

INLINE COMMENTS

> phabricator.py:873
> +    templatekw.keywords['phabreview'] = template_review
> +
> +

couple of new lines here and above too, did you ran test-check-commit.t?

REPOSITORY
  rHG Mercurial

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

To: tom.prince, #hg-reviewers
Cc: pulkit, mercurial-devel
phabricator - Jan. 14, 2018, 7:31 p.m.
indygreg requested changes to this revision.
indygreg added a comment.
This revision now requires changes to proceed.


  Please also remove the double newlines and fix the commit message to abide by our message standards.
  
  From the `tests`/ directory, run `./run-tests.py -j8 test-check-*` to run the static analysis checks.

INLINE COMMENTS

> phabricator.py:871-872
> +
> +def extsetup(ui):
> +    templatekw.keywords['phabreview'] = template_review
> +

`registrar.templatekeyword()` returns a function that can be used as a decorator. This is the preferred mechanism to define templates in extensions. See `hgext/transplant.py` for a simple example.

Please switch to that API.

REPOSITORY
  rHG Mercurial

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

To: tom.prince, #hg-reviewers, indygreg
Cc: indygreg, pulkit, mercurial-devel
phabricator - Jan. 18, 2018, 7:36 p.m.
durin42 accepted this revision.
durin42 added a comment.


  nice, I was about to do this today

REPOSITORY
  rHG Mercurial

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

To: tom.prince, #hg-reviewers, indygreg, durin42
Cc: durin42, indygreg, pulkit, mercurial-devel

Patch

diff --git a/contrib/phabricator.py b/contrib/phabricator.py
--- a/contrib/phabricator.py
+++ b/contrib/phabricator.py
@@ -57,6 +57,7 @@ 
     scmutil,
     smartset,
     tags,
+    templatekw,
     url as urlmod,
     util,
 )
@@ -865,3 +866,19 @@ 
             params = {'objectIdentifier': drev[r'phid'],
                       'transactions': actions}
             callconduit(repo, 'differential.revision.edit', params)
+
+
+def extsetup(ui):
+    templatekw.keywords['phabreview'] = template_review
+
+
+def template_review(repo, ctx, revcache, **args):
+    """:phabreview: Object describing the review for this changeset.
+    Has attributes `url` and `id`.
+    """
+    m = _differentialrevisiondescre.search(ctx.description())
+    if m:
+        return {
+            'url': m.group('url'),
+            'id': "D{}".format(m.group('id')),
+        }