[PATCH 2 of 4 accept-scripts] land: turn three identical function calls into one variable
Kevin Bullock
kbullock+mercurial at ringworld.org
Wed May 2 20:31:50 UTC 2018
# HG changeset patch
# User Kevin Bullock <kbullock at ringworld.org>
# Date 1525292391 18000
# Wed May 02 15:19:51 2018 -0500
# Node ID 1e166e3e0bd6bd0fed28a8e8b9961ff3e517bef7
# Parent 138a6f224f8529ecdc69daac026684ee0892eb5e
land: turn three identical function calls into one variable
diff --git a/land b/land
--- a/land
+++ b/land
@@ -44,27 +44,21 @@ def _destcontains(node):
except subprocess.CalledProcessError:
return False
-def _thesenodesrevset(nodes):
- """Given a list of hex nodes, return a revset query that matches them all.
-
- Just here to make things a bit cleaner.
- """
- return ' + '.join(nodes)
-
# Find all accepted revisions
all_accepted = [n for n in cq.draft() if cq.accepted(n)]
+accepted_revset = ' + '.join(all_accepted)
info = json.load(os.popen("hg log -R %s -r '%s' -Tjson" % (
- conf.source, _thesenodesrevset(all_accepted))))
+ conf.source, accepted_revset)))
# dict of node: its parents.
parents = {i['node']: i['parents'] for i in info}
# Identify heads and roots of accepted revision ranges
accepted_roots = {r.strip() for r in os.popen(
"hg log -R %s -r 'roots(%s)' -T'{node}\\n'" % (
- conf.source, _thesenodesrevset(all_accepted)))}
+ conf.source, accepted_revset))}
accepted_heads = [h.strip() for h in os.popen(
"hg log -R %s -r 'heads(%s)' -T'{node}\\n'" % (
- conf.source, _thesenodesrevset(all_accepted)))]
+ conf.source, accepted_revset))]
# Condense accepted revisions down into accepted ranges
acceptrange = collections.namedtuple('acceptrange', 'roots head')
ranges = []
diff --git a/tests/test-land.t b/tests/test-land.t
--- a/tests/test-land.t
+++ b/tests/test-land.t
@@ -3,8 +3,8 @@ BUG: Fails with no accepted nodes to lan
$ land
hg: parse error: empty query
Traceback (most recent call last):
- File "/Users/kbullock/Source/Projects/hg/accept/tests/../land", line 57, in <module>
- conf.source, _thesenodesrevset(all_accepted))))
+ File "/Users/kbullock/Source/Projects/hg/accept/tests/../land", line 51, in <module>
+ conf.source, accepted_revset)))
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/__init__.py", line 290, in load
**kw)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/__init__.py", line 338, in loads
More information about the Mercurial-devel
mailing list