Patchwork [1,of,4,accept-scripts] cleanup: adapt for landing of extdata in core by removing ext{revset, template}

login
register
mail settings
Submitter Augie Fackler
Date Nov. 8, 2018, 12:57 a.m.
Message ID <fa593e6a69f59fef0a10.1541638648@augie-macbookpro2.roam.corp.google.com>
Download mbox | patch
Permalink /patch/36463/
State New
Headers show

Comments

Augie Fackler - Nov. 8, 2018, 12:57 a.m.
# HG changeset patch
# User Augie Fackler <raf@durin42.com>
# Date 1541633026 18000
#      Wed Nov 07 18:23:46 2018 -0500
# Node ID fa593e6a69f59fef0a10a03671ec14b1aa59a283
# Parent  bafcc443cd52382c574822bd4fef2f83141b10e1
cleanup: adapt for landing of extdata in core by removing ext{revset,template}

These don't work on a modern Mercurial anyway. Tests updated to
demonstrate how to use extdata instead.
via Mercurial-devel - Nov. 8, 2018, 6:03 a.m.
On Wed, Nov 7, 2018 at 5:01 PM Augie Fackler <raf@durin42.com> wrote:

> diff --git a/tests/test-land.t b/tests/test-land.t
> --- a/tests/test-land.t
> +++ b/tests/test-land.t
> @@ -102,3 +102,4 @@ We expect to land 3::6.
>    |
>    o  0:1ea7 default
>
> +  $ cat .hg/take.log
>

Was this meant to be here?
via Mercurial-devel - Nov. 8, 2018, 6:04 a.m.
On Wed, Nov 7, 2018 at 10:03 PM Martin von Zweigbergk <martinvonz@google.com>
wrote:

>
>
> On Wed, Nov 7, 2018 at 5:01 PM Augie Fackler <raf@durin42.com> wrote:
>
>> diff --git a/tests/test-land.t b/tests/test-land.t
>> --- a/tests/test-land.t
>> +++ b/tests/test-land.t
>> @@ -102,3 +102,4 @@ We expect to land 3::6.
>>    |
>>    o  0:1ea7 default
>>
>> +  $ cat .hg/take.log
>>
>
> Was this meant to be here?
>
>
I just looked at patch 2/4 and it looks like it was meant to be there. Can
be moved in flight, I suppose.

Patch

diff --git a/extrevset.py b/extrevset.py
deleted file mode 100644
--- a/extrevset.py
+++ /dev/null
@@ -1,31 +0,0 @@ 
-# extrevset.py support external revset keywords
-#
-# Copyright (C) 2016 Matt Mackall <mpm@selenic.com>
-#
-# This software may be used and distributed according to the terms of the
-# GNU General Public License version 2 or any later version.
-
-from mercurial.i18n import _
-from mercurial import util
-from mercurial import registrar
-from mercurial import revset
-
-revsetpredicate = registrar.revsetpredicate()
-
-def buildrevset(name, cmd):
-    @revsetpredicate('%s()' % name)
-    def myrevset(repo, subset, x): # pylint: disable=unused-variable
-        """External shell revset"""
-        revset.getargs(x, 0, 0, _("%s takes no arguments") % name)
-        results = set()
-        for l in util.popen(cmd):
-            n = l.strip().split()[0]
-            if n in repo:
-                results.add(repo[n].rev())
-        return revset.baseset([r for r in subset if r in results])
-
-def extsetup(ui):
-    for k,v in ui.configitems("extrevset"):
-        typ, cmd = v.split(':')
-        if typ == "shell":
-            buildrevset(k, cmd)
diff --git a/exttemplate.py b/exttemplate.py
deleted file mode 100644
--- a/exttemplate.py
+++ /dev/null
@@ -1,37 +0,0 @@ 
-# exttemplate.py support external template keywords
-#
-# Copyright (C) 2016 Matt Mackall <mpm@selenic.com>
-#
-# This software may be used and distributed according to the terms of the
-# GNU General Public License version 2 or any later version.
-
-from mercurial import util
-from mercurial import registrar
-
-templatekeyword = registrar.templatekeyword()
-
-def buildkeyword(name, cmd):
-    # gets bound to closure
-    cache = []
-
-    @templatekeyword(name)
-    def mykeyword(repo, ctx, **args): # pylint: disable=unused-variable,unused-argument
-        """External shell template keyword"""
-        if not cache:
-            results = {}
-            for l in util.popen(cmd):
-                try:
-                    k, v = l.strip().split(" ", 1)
-                    if k in repo:
-                        results[k] = v
-                except ValueError:
-                    pass
-            cache.append(results)
-        results = cache[0]
-        return results.get(ctx.hex(), "")
-
-def extsetup(ui):
-    for k,v in ui.configitems("exttemplate"):
-        typ, cmd = v.split(':')
-        if typ == "shell":
-            buildkeyword(k, cmd)
diff --git a/tests/lib.sh b/tests/lib.sh
--- a/tests/lib.sh
+++ b/tests/lib.sh
@@ -60,13 +60,11 @@  alias diffhash="$TESTDIR/../diffhash"
 alias update-diffhashes="$TESTDIR/../update-diffhashes"
 
 cat >> $HGRCPATH <<EOF
-[extensions]
-exttemplate = $TESTDIR/../exttemplate.py
-extrevset = $TESTDIR/../extrevset.py
-
-[exttemplate]
+[extdata]
 reviewers = shell:$TESTDIR/../reviewed
+_byalice = shell:$TESTDIR/../reviewed | grep alice
+
+[revsetalias]
+byalice = extdata(_byalice)
 
-[extrevset]
-byalice = shell:$TESTDIR/../reviewed | grep alice
 EOF
diff --git a/tests/test-diffhashes.t b/tests/test-diffhashes.t
--- a/tests/test-diffhashes.t
+++ b/tests/test-diffhashes.t
@@ -19,7 +19,7 @@ 
   e49acdfe1396efbda77644ef349f82d2442065a6
 
   $ hg ci --amend --date '1 0' --message 'Add beta (corrected)'
-  saved backup bundle to $TESTTMP/source/.hg/strip-backup/ff05b7beb451-f05ceee3-amend-backup.hg (glob)
+  saved backup bundle to $TESTTMP/source/.hg/strip-backup/ff05b7beb451-f05ceee3-*.hg (glob)
   $ hg export
   # HG changeset patch
   # User alice
@@ -42,7 +42,7 @@  Note that the diffhash doesn't change he
 
   $ echo 'content of beta' >> beta
   $ hg ci --amend --date '1 0' --message 'Add beta (corrected)'
-  saved backup bundle to $TESTTMP/source/.hg/strip-backup/9c1cf7d076f2-034e2cfa-amend-backup.hg (glob)
+  saved backup bundle to $TESTTMP/source/.hg/strip-backup/*.hg (glob)
 This "unknown revision" abort is because obsolete markers aren't enabled
 in the test repositories. It should be harmless.
   $ update-diffhashes
@@ -81,7 +81,7 @@  Now we amend the change, and record the 
 the approval doesn't follow it to the new node.
 
   $ hg ci --amend --message 'amended message of tip' --date '100 0'
-  saved backup bundle to $TESTTMP/source/.hg/strip-backup/4db820271774-59296beb-amend-backup.hg (glob)
+  saved backup bundle to $TESTTMP/source/.hg/strip-backup/4db820271774-59296beb-*.hg (glob)
   $ logpush tip alice alice
   $ accepted
   4db820271774eb2b1e5983449385a52e7469551c alice bob
diff --git a/tests/test-exttemplate.t b/tests/test-exttemplate.t
deleted file mode 100644
--- a/tests/test-exttemplate.t
+++ /dev/null
@@ -1,11 +0,0 @@ 
-  $ . "$TESTDIR/lib.sh"
-
-  $ cd source
-  $ hg log --template '{node|short} {reviewers}\n'
-  ff05b7beb451 alice
-  eb8972173e17 alice
-  6b70f47fc5e7 
-
-  $ hg log --template '{node|short} {reviewers}\n' --rev 'byalice()'
-  eb8972173e17 alice
-  ff05b7beb451 alice
diff --git a/tests/test-land.t b/tests/test-land.t
--- a/tests/test-land.t
+++ b/tests/test-land.t
@@ -102,3 +102,4 @@  We expect to land 3::6.
   |
   o  0:1ea7 default
   
+  $ cat .hg/take.log