D3648: show: Get rid of extraneous space if `tip` also has other bookmarks
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/D3648 AFFECTED FILES mercurial/templates/map-cmdline.show CHANGE DETAILS diff --git a/mercurial/templates/map-cmdline.show b/mercurial/templates/map-cmdline.show --- a/mercurial/templates/map-cmdline.show +++ b/mercurial/templates/map-cmdline.show @@ -15,7 +15,7 @@ # Treat branch and tags specially so we don't display "default" or "tip" cset_namespace = '{ifeq(namespace, "branches", names_branches, ifeq(namespace, "tags", names_tags, names_others))}' names_branches = '{ifeq(branch, "default", "", " ({label('log.{colorname}', branch)})")}' -names_tags = '{if(names % "{ifeq(name, 'tip', '', name)}", " ({label('log.{colorname}', join(names % "{ifeq(name, 'tip', '', name)}", ' '))})")}' +names_tags = '{if(names % "{ifeq(name, 'tip', '', name)}", " ({label('log.{colorname}', separate(names % "{ifeq(name, 'tip', '', name)}", ' '))})")}' names_others = '{if(names, " ({label('log.{colorname}', join(names, ' '))})")}' cset_shortdesc = '{label("log.description", desc|firstline)}' To: tom.prince, #hg-reviewers Cc: mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D3414: phabricator: specify some metadata compatibly with arc.
This revision was automatically updated to reflect the committed changes. Closed by commit rHGfb95a54ee45c: phabricator: specify some metadata compatibly with arc. (authored by tom.prince, committed by ). CHANGED PRIOR TO COMMIT https://phab.mercurial-scm.org/D3414?vs=8408=8416#toc REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D3414?vs=8408=8416 REVISION DETAIL https://phab.mercurial-scm.org/D3414 AFFECTED FILES contrib/phabricator.py CHANGE DETAILS diff --git a/contrib/phabricator.py b/contrib/phabricator.py --- a/contrib/phabricator.py +++ b/contrib/phabricator.py @@ -69,11 +69,12 @@ from mercurial.utils import ( procutil, ) +from mercurial.utils import ( +procutil, +stringutil, +) cmdtable = {} -command = registrar.command(cmdtable) - -colortable = { 'phabricator.action.created': 'green', 'phabricator.action.skipped': 'magenta', 'phabricator.action.updated': 'magenta', @@ -332,9 +333,22 @@ olddiff=None, actions=None): """create or update a Differential Revision -If revid is None, create a new Differential Revision, otherwise update -revid. If parentrevid is not None, set it as a dependency. +params = { +'diff_id': diff[r'id'], +'name': 'local:commits', +'data': json.dumps({ +ctx.hex(): { +'author': stringutil.person(ctx.user()), +'authorEmail': stringutil.email(ctx.user()), +'time': ctx.date()[0], +}, +}), +} +callconduit(ctx.repo(), 'differential.setdiffproperty', params) +def createdifferentialrevision(ctx, revid=None, parentrevid=None, oldnode=None, + olddiff=None, actions=None): +"""create or update a Differential Revision If oldnode is not None, check if the patch content (without commit message and metadata) has changed before creating another diff. To: tom.prince, #hg-reviewers, indygreg, durin42 Cc: durin42, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D3414: phabricator: specify some metadata compatibly with arc.
tom.prince updated this revision to Diff 8408. REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D3414?vs=8400=8408 REVISION DETAIL https://phab.mercurial-scm.org/D3414 AFFECTED FILES contrib/phabricator.py CHANGE DETAILS diff --git a/contrib/phabricator.py b/contrib/phabricator.py --- a/contrib/phabricator.py +++ b/contrib/phabricator.py @@ -68,6 +68,7 @@ ) from mercurial.utils import ( procutil, +stringutil, ) cmdtable = {} @@ -328,6 +329,19 @@ } callconduit(ctx.repo(), 'differential.setdiffproperty', params) +params = { +'diff_id': diff[r'id'], +'name': 'local:commits', +'data': json.dumps({ +ctx.hex(): { +'author': stringutil.person(ctx.user()), +'authorEmail': stringutil.email(ctx.user()), +'time': ctx.date()[0], +}, +}), +} +callconduit(ctx.repo(), 'differential.setdiffproperty', params) + def createdifferentialrevision(ctx, revid=None, parentrevid=None, oldnode=None, olddiff=None, actions=None): """create or update a Differential Revision To: tom.prince, #hg-reviewers, indygreg Cc: mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D3414: phabricator: specify some metadata compatibly with arc.
tom.prince added a comment. This is just enough metadata to support Mozilla's autolanding service. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D3414 To: tom.prince, #hg-reviewers, indygreg Cc: mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D3414: phabricator: specify some metadata compatibly with arc.
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/D3414 AFFECTED FILES contrib/phabricator.py mercurial/templatefilters.py mercurial/util.py CHANGE DETAILS diff --git a/mercurial/util.py b/mercurial/util.py --- a/mercurial/util.py +++ b/mercurial/util.py @@ -2341,6 +2341,33 @@ r = None return author[author.find('<') + 1:r] +def person(author): +"""Any text. Returns the name before an email address, +interpreting it as per RFC 5322. + +>>> person(b'foo@bar') +'foo' +>>> person(b'Foo Bar') +'Foo Bar' +>>> person(b'"Foo Bar" ') +'Foo Bar' +>>> person(b'"Foo \"buz\" Bar" ') +'Foo "buz" Bar' +>>> # The following are invalid, but do exist in real-life +... +>>> person(b'Foo "buz" Bar ') +'Foo "buz" Bar' +>>> person(b'"Foo Bar ') +'Foo Bar' +""" +if '@' not in author: +return author +f = author.find('<') +if f != -1: +return author[:f].strip(' "').replace('\\"', '"') +f = author.find('@') +return author[:f].replace('.', ' ') + def ellipsis(text, maxlength=400): """Trim string to at most maxlength (default: 400) columns in display.""" return encoding.trim(text, maxlength, ellipsis='...') diff --git a/mercurial/templatefilters.py b/mercurial/templatefilters.py --- a/mercurial/templatefilters.py +++ b/mercurial/templatefilters.py @@ -297,13 +297,7 @@ >>> person(b'"Foo Bar ') 'Foo Bar' """ -if '@' not in author: -return author -f = author.find('<') -if f != -1: -return author[:f].strip(' "').replace('\\"', '"') -f = author.find('@') -return author[:f].replace('.', ' ') +return util.person(author) @templatefilter('revescape') def revescape(text): diff --git a/contrib/phabricator.py b/contrib/phabricator.py --- a/contrib/phabricator.py +++ b/contrib/phabricator.py @@ -306,6 +306,19 @@ } callconduit(ctx.repo(), 'differential.setdiffproperty', params) +params = { +'diff_id': diff[r'id'], +'name': 'local:commits', +'data': json.dumps({ +ctx.hex(): { +'author': util.person(ctx.user()), +'authorEmail': util.email(ctx.user()), +'time': ctx.date()[0], +}, +}), +} +callconduit(ctx.repo(), 'differential.setdiffproperty', params) + def createdifferentialrevision(ctx, revid=None, parentrevid=None, oldnode=None, olddiff=None, actions=None): """create or update a Differential Revision To: tom.prince, #hg-reviewers Cc: mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D1919: phabricator: specify API tokens per host, rather than per repo
This revision was automatically updated to reflect the committed changes. Closed by commit rHG4397909f82d3: phabricator: specify API tokens per host, rather than per repo (authored by tom.prince, committed by ). REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D1919?vs=4960=6730 REVISION DETAIL https://phab.mercurial-scm.org/D1919 AFFECTED FILES contrib/phabricator.py CHANGE DETAILS diff --git a/contrib/phabricator.py b/contrib/phabricator.py --- a/contrib/phabricator.py +++ b/contrib/phabricator.py @@ -33,6 +33,11 @@ # if you need to specify advanced options that is not easily supported by # the internal library. curlcmd = curl --connect-timeout 2 --retry 3 --silent + +[phabricator.auth] +example.url = https://phab.example.com/ +# API token. Get it from https://$HOST/conduit/login/ +example.token = cli- """ from __future__ import absolute_import @@ -100,14 +105,33 @@ Currently read from [phabricator] config section. In the future, it might make sense to read from .arcconfig and .arcrc as well. """ -values = [] -section = 'phabricator' -for name in ['url', 'token']: -value = repo.ui.config(section, name) -if not value: -raise error.Abort(_('config %s.%s is required') % (section, name)) -values.append(value) -return values +url = repo.ui.config('phabricator', 'url') +if not url: +raise error.Abort(_('config %s.%s is required') + % ('phabricator', 'url')) + +groups = {} +for key, val in repo.ui.configitems('phabricator.auth'): +if '.' not in key: +repo.ui.warn(_("ignoring invalid [phabricator.auth] key '%s'\n") + % key) +continue +group, setting = key.rsplit('.', 1) +groups.setdefault(group, {})[setting] = val + +token = None +for group, auth in groups.iteritems(): +if url != auth.get('url'): +continue +token = auth.get('token') +if token: +break + +if not token: +raise error.Abort(_('Can\'t find conduit token associated to %s') + % (url,)) + +return url, token def callconduit(repo, name, params): """call Conduit API, params is a dict. return json.loads result, or None""" To: tom.prince, #hg-reviewers, durin42 Cc: quark, indygreg, durin42, pulkit, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D1919: phabricator: specify API tokens per host, rather than per repo
tom.prince added a comment. Personally, I don't have arc installed, so I'd prefer putting the auth information in mercurial rather than arc specific places (this is what is stored in `.arcrc` I think). It would make sense to support `.arcrc` as well, though. It would make sense to read the URL and call-sign from `.arcconfig`, which is a file in the repo, if it is provided. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D1919 To: tom.prince, #hg-reviewers, durin42 Cc: quark, indygreg, durin42, pulkit, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D1919: phabricator: specify API tokens per host, rather than per repo
tom.prince added a comment. I'm not sure what the compatibility policy for `contrib/` files is. This just *changes* the format for auth data, but it wouldn't be hard to support the old format too. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D1919 To: tom.prince, #hg-reviewers Cc: mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D1919: phabricator: specify API tokens per host, rather than per repo
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/D1919 AFFECTED FILES contrib/phabricator.py CHANGE DETAILS diff --git a/contrib/phabricator.py b/contrib/phabricator.py --- a/contrib/phabricator.py +++ b/contrib/phabricator.py @@ -33,6 +33,11 @@ # if you need to specify advanced options that is not easily supported by # the internal library. curlcmd = curl --connect-timeout 2 --retry 3 --silent + +[phabricator.auth] +example.url = https://phab.example.com/ +# API token. Get it from https://$HOST/conduit/login/ +example.token = cli- """ from __future__ import absolute_import @@ -100,14 +105,33 @@ Currently read from [phabricator] config section. In the future, it might make sense to read from .arcconfig and .arcrc as well. """ -values = [] -section = 'phabricator' -for name in ['url', 'token']: -value = repo.ui.config(section, name) -if not value: -raise error.Abort(_('config %s.%s is required') % (section, name)) -values.append(value) -return values +url = repo.ui.config('phabricator', 'url') +if not url: +raise error.Abort(_('config %s.%s is required') + % ('phabricator', 'url')) + +groups = {} +for key, val in repo.ui.configitems('phabricator.auth'): +if '.' not in key: +repo.ui.warn(_("ignoring invalid [phabricator.auth] key '%s'\n") + % key) +continue +group, setting = key.rsplit('.', 1) +groups.setdefault(group, {})[setting] = val + +token = None +for group, auth in groups.iteritems(): +if url != auth.get('url'): +continue +token = auth.get('token') +if token: +break + +if not token: +raise error.Abort(_('Can\'t find conduit token associated to %s') + % (url,)) + +return url, token def callconduit(repo, name, params): """call Conduit API, params is a dict. return json.loads result, or None""" To: tom.prince, #hg-reviewers Cc: mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D1802: phabricator: add a template item for linking to a differential review
This revision was automatically updated to reflect the committed changes. Closed by commit rHGf18ba40d792f: phabricator: add a template item for linking to a differential review (authored by tom.prince, committed by ). REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D1802?vs=4834=4926 REVISION DETAIL https://phab.mercurial-scm.org/D1802 AFFECTED FILES contrib/phabricator.py CHANGE DETAILS diff --git a/contrib/phabricator.py b/contrib/phabricator.py --- a/contrib/phabricator.py +++ b/contrib/phabricator.py @@ -865,3 +865,17 @@ params = {'objectIdentifier': drev[r'phid'], 'transactions': actions} callconduit(repo, 'differential.revision.edit', params) + +templatekeyword = registrar.templatekeyword() + +@templatekeyword('phabreview') +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')), +} To: tom.prince, #hg-reviewers, indygreg, durin42 Cc: durin42, indygreg, pulkit, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D1802: phabricator: add a template item for linking to a differential review
tom.prince updated this revision to Diff 4834. tom.prince retitled this revision from "Add a template item for linking to a differential review." to "phabricator: add a template item for linking to a differential review". REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D1802?vs=4681=4834 REVISION DETAIL https://phab.mercurial-scm.org/D1802 AFFECTED FILES contrib/phabricator.py CHANGE DETAILS diff --git a/contrib/phabricator.py b/contrib/phabricator.py --- a/contrib/phabricator.py +++ b/contrib/phabricator.py @@ -865,3 +865,17 @@ params = {'objectIdentifier': drev[r'phid'], 'transactions': actions} callconduit(repo, 'differential.revision.edit', params) + +templatekeyword = registrar.templatekeyword() + +@templatekeyword('phabreview') +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')), +} To: tom.prince, #hg-reviewers, indygreg Cc: indygreg, pulkit, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D1801: Use named group for parsing differential reviews lines.
This revision was automatically updated to reflect the committed changes. Closed by commit rHGa0d33f4ddff9: phabricator: use named group for parsing differential reviews lines (authored by tom.prince, committed by ). REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D1801?vs=4680=4818 REVISION DETAIL https://phab.mercurial-scm.org/D1801 AFFECTED FILES contrib/phabricator.py CHANGE DETAILS diff --git a/contrib/phabricator.py b/contrib/phabricator.py --- a/contrib/phabricator.py +++ b/contrib/phabricator.py @@ -166,7 +166,7 @@ _differentialrevisiontagre = re.compile('\AD([1-9][0-9]*)\Z') _differentialrevisiondescre = re.compile( -'^Differential Revision:\s*(?:.*)D([1-9][0-9]*)$', re.M) +'^Differential Revision:\s*(?P(?:.*)D(?P[1-9][0-9]*))$', re.M) def getoldnodedrevmap(repo, nodelist): """find previous nodes that has been sent to Phabricator @@ -207,7 +207,7 @@ # Check commit message m = _differentialrevisiondescre.search(ctx.description()) if m: -toconfirm[node] = (1, set(precnodes), int(m.group(1))) +toconfirm[node] = (1, set(precnodes), int(m.group('id'))) # Double check if tags are genuine by collecting all old nodes from # Phabricator, and expect precursors overlap with it. @@ -442,7 +442,7 @@ # Create a local tag to note the association, if commit message # does not have it already m = _differentialrevisiondescre.search(ctx.description()) -if not m or int(m.group(1)) != newrevid: +if not m or int(m.group('id')) != newrevid: tagname = 'D%d' % newrevid tags.tag(repo, tagname, ctx.node(), message=None, user=None, date=None, local=True) To: tom.prince, #hg-reviewers, indygreg Cc: indygreg, mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D1801: Use named group for parsing differential reviews lines.
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/D1801 AFFECTED FILES contrib/phabricator.py CHANGE DETAILS diff --git a/contrib/phabricator.py b/contrib/phabricator.py --- a/contrib/phabricator.py +++ b/contrib/phabricator.py @@ -166,7 +166,7 @@ _differentialrevisiontagre = re.compile('\AD([1-9][0-9]*)\Z') _differentialrevisiondescre = re.compile( -'^Differential Revision:\s*(?:.*)D([1-9][0-9]*)$', re.M) +'^Differential Revision:\s*(?P(?:.*)D(?P[1-9][0-9]*))$', re.M) def getoldnodedrevmap(repo, nodelist): """find previous nodes that has been sent to Phabricator @@ -207,7 +207,7 @@ # Check commit message m = _differentialrevisiondescre.search(ctx.description()) if m: -toconfirm[node] = (1, set(precnodes), int(m.group(1))) +toconfirm[node] = (1, set(precnodes), int(m.group('id'))) # Double check if tags are genuine by collecting all old nodes from # Phabricator, and expect precursors overlap with it. @@ -442,7 +442,7 @@ # Create a local tag to note the association, if commit message # does not have it already m = _differentialrevisiondescre.search(ctx.description()) -if not m or int(m.group(1)) != newrevid: +if not m or int(m.group('id')) != newrevid: tagname = 'D%d' % newrevid tags.tag(repo, tagname, ctx.node(), message=None, user=None, date=None, local=True) To: tom.prince, #hg-reviewers Cc: mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D1802: Add a template item for linking to a differential review.
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 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')), +} To: tom.prince, #hg-reviewers Cc: mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel