revset: build dict of extra sort options before evaluating set
Prepares for extracting a function that only validates sort options.
--- a/mercurial/revset.py Sat Jun 11 10:15:40 2016 +0900
+++ b/mercurial/revset.py Wed Jun 15 21:26:45 2016 +0900
@@ -1881,30 +1881,33 @@
raise error.ParseError(_("unknown sort key %r") % fk)
keyflags.append((k, reverse))
- s = args['set']
- revs = getset(repo, subset, s)
-
if len(keyflags) > 1 and any(k == 'topo' for k, reverse in keyflags):
# i18n: "topo" is a keyword
raise error.ParseError(_(
'topo sort order cannot be combined with other sort keys'))
- firstbranch = ()
+ opts = {}
if 'topo.firstbranch' in args:
if any(k == 'topo' for k, reverse in keyflags):
- firstbranch = getset(repo, subset, args['topo.firstbranch'])
+ opts['topo.firstbranch'] = args['topo.firstbranch']
else:
# i18n: "topo" and "topo.firstbranch" are keywords
raise error.ParseError(_(
'topo.firstbranch can only be used when using the topo sort '
'key'))
+ s = args['set']
+ revs = getset(repo, subset, s)
+
if not keyflags:
return revs
if len(keyflags) == 1 and keyflags[0][0] == "rev":
revs.sort(reverse=keyflags[0][1])
return revs
elif keyflags[0][0] == "topo":
+ firstbranch = ()
+ if 'topo.firstbranch' in opts:
+ firstbranch = getset(repo, subset, opts['topo.firstbranch'])
revs = baseset(_toposort(revs, repo.changelog.parentrevs, firstbranch),
istopo=True)
if keyflags[0][1]: