author | Raphaël Gomès <rgomes@octobus.net> |
Mon, 09 Jan 2023 17:40:03 +0100 | |
changeset 49914 | 58074252db3c |
parent 49725 | f632b9e1e047 |
child 49972 | 1bd33932713d |
permissions | -rw-r--r-- |
11275 | 1 |
# revset.py - revision set queries for mercurial |
2 |
# |
|
46819
d4ba4d51f85f
contributor: change mentions of mpm to olivia
Raphaël Gomès <rgomes@octobus.net>
parents:
46809
diff
changeset
|
3 |
# Copyright 2010 Olivia Mackall <olivia@selenic.com> |
11275 | 4 |
# |
5 |
# This software may be used and distributed according to the terms of the |
|
6 |
# GNU General Public License version 2 or any later version. |
|
7 |
||
25971
e9cd028f2dff
revset: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25929
diff
changeset
|
8 |
|
49248
63fd0282ad40
node: stop converting binascii.Error to TypeError in bin()
Manuel Jacob <me@manueljacob.de>
parents:
48913
diff
changeset
|
9 |
import binascii |
49447
6dbe74669eba
sort-revset: introduce a `random` variant
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49279
diff
changeset
|
10 |
import functools |
6dbe74669eba
sort-revset: introduce a `random` variant
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49279
diff
changeset
|
11 |
import random |
25971
e9cd028f2dff
revset: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25929
diff
changeset
|
12 |
import re |
49447
6dbe74669eba
sort-revset: introduce a `random` variant
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49279
diff
changeset
|
13 |
import sys |
25971
e9cd028f2dff
revset: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25929
diff
changeset
|
14 |
|
e9cd028f2dff
revset: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25929
diff
changeset
|
15 |
from .i18n import _ |
43089
c59eb1560c44
py3: manually import getattr where it is needed
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43077
diff
changeset
|
16 |
from .pycompat import getattr |
46113
59fa3890d40a
node: import symbols explicitly
Joerg Sonnenberger <joerg@bec.de>
parents:
45942
diff
changeset
|
17 |
from .node import ( |
59fa3890d40a
node: import symbols explicitly
Joerg Sonnenberger <joerg@bec.de>
parents:
45942
diff
changeset
|
18 |
bin, |
59fa3890d40a
node: import symbols explicitly
Joerg Sonnenberger <joerg@bec.de>
parents:
45942
diff
changeset
|
19 |
nullrev, |
59fa3890d40a
node: import symbols explicitly
Joerg Sonnenberger <joerg@bec.de>
parents:
45942
diff
changeset
|
20 |
wdirrev, |
59fa3890d40a
node: import symbols explicitly
Joerg Sonnenberger <joerg@bec.de>
parents:
45942
diff
changeset
|
21 |
) |
25971
e9cd028f2dff
revset: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25929
diff
changeset
|
22 |
from . import ( |
32903
27932a76a88d
dagop: split module hosting DAG-related algorithms from revset
Yuya Nishihara <yuya@tcha.org>
parents:
32885
diff
changeset
|
23 |
dagop, |
26713
a271925699d6
revset: reintroduce and experimental revset for update destination
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26638
diff
changeset
|
24 |
destutil, |
38588
1c93e0237a24
diffutil: move the module out of utils package
Yuya Nishihara <yuya@tcha.org>
parents:
38587
diff
changeset
|
25 |
diffutil, |
25971
e9cd028f2dff
revset: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25929
diff
changeset
|
26 |
encoding, |
e9cd028f2dff
revset: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25929
diff
changeset
|
27 |
error, |
45725
99b8b73eb622
revset: add diff(pattern) predicate for "grep --diff"
Yuya Nishihara <yuya@tcha.org>
parents:
45701
diff
changeset
|
28 |
grep as grepmod, |
25971
e9cd028f2dff
revset: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25929
diff
changeset
|
29 |
hbisect, |
e9cd028f2dff
revset: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25929
diff
changeset
|
30 |
match as matchmod, |
e9cd028f2dff
revset: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25929
diff
changeset
|
31 |
obsolete as obsmod, |
33377 | 32 |
obsutil, |
25971
e9cd028f2dff
revset: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25929
diff
changeset
|
33 |
pathutil, |
e9cd028f2dff
revset: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25929
diff
changeset
|
34 |
phases, |
35367
6eee2bcc57c4
py3: handle keyword arguments correctly in revset.py
Pulkit Goyal <7895pulkit@gmail.com>
parents:
35330
diff
changeset
|
35 |
pycompat, |
27584
fc7c8cac6a4b
revset: use decorator to register a function as revset predicate
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27517
diff
changeset
|
36 |
registrar, |
25971
e9cd028f2dff
revset: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25929
diff
changeset
|
37 |
repoview, |
31024
0b8356705de6
revset: split language services to revsetlang module (API)
Yuya Nishihara <yuya@tcha.org>
parents:
31017
diff
changeset
|
38 |
revsetlang, |
32661
a3064fe3e495
revset: add support for integer and hex wdir identifiers
Yuya Nishihara <yuya@tcha.org>
parents:
32442
diff
changeset
|
39 |
scmutil, |
30881
1be65deb3d54
smartset: move set classes and related functions from revset module (API)
Yuya Nishihara <yuya@tcha.org>
parents:
30850
diff
changeset
|
40 |
smartset, |
37389
bef863a09acd
stack: follow-up on the stack revset
Boris Feld <boris.feld@octobus.net>
parents:
37350
diff
changeset
|
41 |
stack as stackmod, |
25971
e9cd028f2dff
revset: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25929
diff
changeset
|
42 |
util, |
e9cd028f2dff
revset: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25929
diff
changeset
|
43 |
) |
37084
f0b6fbea00cf
stringutil: bulk-replace call sites to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
37001
diff
changeset
|
44 |
from .utils import ( |
f0b6fbea00cf
stringutil: bulk-replace call sites to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
37001
diff
changeset
|
45 |
dateutil, |
f0b6fbea00cf
stringutil: bulk-replace call sites to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
37001
diff
changeset
|
46 |
stringutil, |
46908
4452cb788404
urlutil: extract `parseurl` from `hg` into the new module
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46819
diff
changeset
|
47 |
urlutil, |
37084
f0b6fbea00cf
stringutil: bulk-replace call sites to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
37001
diff
changeset
|
48 |
) |
11275 | 49 |
|
31024
0b8356705de6
revset: split language services to revsetlang module (API)
Yuya Nishihara <yuya@tcha.org>
parents:
31017
diff
changeset
|
50 |
# helpers for processing parsed tree |
0b8356705de6
revset: split language services to revsetlang module (API)
Yuya Nishihara <yuya@tcha.org>
parents:
31017
diff
changeset
|
51 |
getsymbol = revsetlang.getsymbol |
0b8356705de6
revset: split language services to revsetlang module (API)
Yuya Nishihara <yuya@tcha.org>
parents:
31017
diff
changeset
|
52 |
getstring = revsetlang.getstring |
0b8356705de6
revset: split language services to revsetlang module (API)
Yuya Nishihara <yuya@tcha.org>
parents:
31017
diff
changeset
|
53 |
getinteger = revsetlang.getinteger |
31998
83527d9f1f13
revset: properly parse "descend" argument of followlines()
Denis Laxalde <denis@laxalde.org>
parents:
31938
diff
changeset
|
54 |
getboolean = revsetlang.getboolean |
31024
0b8356705de6
revset: split language services to revsetlang module (API)
Yuya Nishihara <yuya@tcha.org>
parents:
31017
diff
changeset
|
55 |
getlist = revsetlang.getlist |
41561
59638c6fcb70
revset: extract a helper to parse integer range
Yuya Nishihara <yuya@tcha.org>
parents:
41397
diff
changeset
|
56 |
getintrange = revsetlang.getintrange |
31024
0b8356705de6
revset: split language services to revsetlang module (API)
Yuya Nishihara <yuya@tcha.org>
parents:
31017
diff
changeset
|
57 |
getargs = revsetlang.getargs |
0b8356705de6
revset: split language services to revsetlang module (API)
Yuya Nishihara <yuya@tcha.org>
parents:
31017
diff
changeset
|
58 |
getargsdict = revsetlang.getargsdict |
0b8356705de6
revset: split language services to revsetlang module (API)
Yuya Nishihara <yuya@tcha.org>
parents:
31017
diff
changeset
|
59 |
|
30881
1be65deb3d54
smartset: move set classes and related functions from revset module (API)
Yuya Nishihara <yuya@tcha.org>
parents:
30850
diff
changeset
|
60 |
baseset = smartset.baseset |
1be65deb3d54
smartset: move set classes and related functions from revset module (API)
Yuya Nishihara <yuya@tcha.org>
parents:
30850
diff
changeset
|
61 |
generatorset = smartset.generatorset |
1be65deb3d54
smartset: move set classes and related functions from revset module (API)
Yuya Nishihara <yuya@tcha.org>
parents:
30850
diff
changeset
|
62 |
spanset = smartset.spanset |
1be65deb3d54
smartset: move set classes and related functions from revset module (API)
Yuya Nishihara <yuya@tcha.org>
parents:
30850
diff
changeset
|
63 |
fullreposet = smartset.fullreposet |
1be65deb3d54
smartset: move set classes and related functions from revset module (API)
Yuya Nishihara <yuya@tcha.org>
parents:
30850
diff
changeset
|
64 |
|
42262
a0c5e06e9b1a
revset: extract private constant of {nullrev, wdirrev} set
Yuya Nishihara <yuya@tcha.org>
parents:
42104
diff
changeset
|
65 |
# revisions not included in all(), but populated if specified |
46113
59fa3890d40a
node: import symbols explicitly
Joerg Sonnenberger <joerg@bec.de>
parents:
45942
diff
changeset
|
66 |
_virtualrevs = (nullrev, wdirrev) |
42262
a0c5e06e9b1a
revset: extract private constant of {nullrev, wdirrev} set
Yuya Nishihara <yuya@tcha.org>
parents:
42104
diff
changeset
|
67 |
|
34016
96f249dce03e
revset: move order constants from revsetlang
Yuya Nishihara <yuya@tcha.org>
parents:
34011
diff
changeset
|
68 |
# Constants for ordering requirement, used in getset(): |
96f249dce03e
revset: move order constants from revsetlang
Yuya Nishihara <yuya@tcha.org>
parents:
34011
diff
changeset
|
69 |
# |
96f249dce03e
revset: move order constants from revsetlang
Yuya Nishihara <yuya@tcha.org>
parents:
34011
diff
changeset
|
70 |
# If 'define', any nested functions and operations MAY change the ordering of |
96f249dce03e
revset: move order constants from revsetlang
Yuya Nishihara <yuya@tcha.org>
parents:
34011
diff
changeset
|
71 |
# the entries in the set (but if changes the ordering, it MUST ALWAYS change |
96f249dce03e
revset: move order constants from revsetlang
Yuya Nishihara <yuya@tcha.org>
parents:
34011
diff
changeset
|
72 |
# it). If 'follow', any nested functions and operations MUST take the ordering |
96f249dce03e
revset: move order constants from revsetlang
Yuya Nishihara <yuya@tcha.org>
parents:
34011
diff
changeset
|
73 |
# specified by the first operand to the '&' operator. |
96f249dce03e
revset: move order constants from revsetlang
Yuya Nishihara <yuya@tcha.org>
parents:
34011
diff
changeset
|
74 |
# |
96f249dce03e
revset: move order constants from revsetlang
Yuya Nishihara <yuya@tcha.org>
parents:
34011
diff
changeset
|
75 |
# For instance, |
96f249dce03e
revset: move order constants from revsetlang
Yuya Nishihara <yuya@tcha.org>
parents:
34011
diff
changeset
|
76 |
# |
96f249dce03e
revset: move order constants from revsetlang
Yuya Nishihara <yuya@tcha.org>
parents:
34011
diff
changeset
|
77 |
# X & (Y | Z) |
96f249dce03e
revset: move order constants from revsetlang
Yuya Nishihara <yuya@tcha.org>
parents:
34011
diff
changeset
|
78 |
# ^ ^^^^^^^ |
96f249dce03e
revset: move order constants from revsetlang
Yuya Nishihara <yuya@tcha.org>
parents:
34011
diff
changeset
|
79 |
# | follow |
96f249dce03e
revset: move order constants from revsetlang
Yuya Nishihara <yuya@tcha.org>
parents:
34011
diff
changeset
|
80 |
# define |
96f249dce03e
revset: move order constants from revsetlang
Yuya Nishihara <yuya@tcha.org>
parents:
34011
diff
changeset
|
81 |
# |
96f249dce03e
revset: move order constants from revsetlang
Yuya Nishihara <yuya@tcha.org>
parents:
34011
diff
changeset
|
82 |
# will be evaluated as 'or(y(x()), z(x()))', where 'x()' can change the order |
96f249dce03e
revset: move order constants from revsetlang
Yuya Nishihara <yuya@tcha.org>
parents:
34011
diff
changeset
|
83 |
# of the entries in the set, but 'y()', 'z()' and 'or()' shouldn't. |
96f249dce03e
revset: move order constants from revsetlang
Yuya Nishihara <yuya@tcha.org>
parents:
34011
diff
changeset
|
84 |
# |
96f249dce03e
revset: move order constants from revsetlang
Yuya Nishihara <yuya@tcha.org>
parents:
34011
diff
changeset
|
85 |
# 'any' means the order doesn't matter. For instance, |
96f249dce03e
revset: move order constants from revsetlang
Yuya Nishihara <yuya@tcha.org>
parents:
34011
diff
changeset
|
86 |
# |
34017
62cc1f17c571
revset: fix example describing how ordering is determined
Yuya Nishihara <yuya@tcha.org>
parents:
34016
diff
changeset
|
87 |
# (X & !Y) | ancestors(Z) |
62cc1f17c571
revset: fix example describing how ordering is determined
Yuya Nishihara <yuya@tcha.org>
parents:
34016
diff
changeset
|
88 |
# ^ ^ |
62cc1f17c571
revset: fix example describing how ordering is determined
Yuya Nishihara <yuya@tcha.org>
parents:
34016
diff
changeset
|
89 |
# any any |
34016
96f249dce03e
revset: move order constants from revsetlang
Yuya Nishihara <yuya@tcha.org>
parents:
34011
diff
changeset
|
90 |
# |
34017
62cc1f17c571
revset: fix example describing how ordering is determined
Yuya Nishihara <yuya@tcha.org>
parents:
34016
diff
changeset
|
91 |
# For 'X & !Y', 'X' decides the order and 'Y' is subtracted from 'X', so the |
62cc1f17c571
revset: fix example describing how ordering is determined
Yuya Nishihara <yuya@tcha.org>
parents:
34016
diff
changeset
|
92 |
# order of 'Y' does not matter. For 'ancestors(Z)', Z's order does not matter |
62cc1f17c571
revset: fix example describing how ordering is determined
Yuya Nishihara <yuya@tcha.org>
parents:
34016
diff
changeset
|
93 |
# since 'ancestors' does not care about the order of its argument. |
34016
96f249dce03e
revset: move order constants from revsetlang
Yuya Nishihara <yuya@tcha.org>
parents:
34011
diff
changeset
|
94 |
# |
96f249dce03e
revset: move order constants from revsetlang
Yuya Nishihara <yuya@tcha.org>
parents:
34011
diff
changeset
|
95 |
# Currently, most revsets do not care about the order, so 'define' is |
96f249dce03e
revset: move order constants from revsetlang
Yuya Nishihara <yuya@tcha.org>
parents:
34011
diff
changeset
|
96 |
# equivalent to 'follow' for them, and the resulting order is based on the |
96f249dce03e
revset: move order constants from revsetlang
Yuya Nishihara <yuya@tcha.org>
parents:
34011
diff
changeset
|
97 |
# 'subset' parameter passed down to them: |
96f249dce03e
revset: move order constants from revsetlang
Yuya Nishihara <yuya@tcha.org>
parents:
34011
diff
changeset
|
98 |
# |
34018
de286200f722
revset: move order argument to run-time match function
Yuya Nishihara <yuya@tcha.org>
parents:
34017
diff
changeset
|
99 |
# m = revset.match(...) |
de286200f722
revset: move order argument to run-time match function
Yuya Nishihara <yuya@tcha.org>
parents:
34017
diff
changeset
|
100 |
# m(repo, subset, order=defineorder) |
34016
96f249dce03e
revset: move order constants from revsetlang
Yuya Nishihara <yuya@tcha.org>
parents:
34011
diff
changeset
|
101 |
# ^^^^^^ |
96f249dce03e
revset: move order constants from revsetlang
Yuya Nishihara <yuya@tcha.org>
parents:
34011
diff
changeset
|
102 |
# For most revsets, 'define' means using the order this subset provides |
96f249dce03e
revset: move order constants from revsetlang
Yuya Nishihara <yuya@tcha.org>
parents:
34011
diff
changeset
|
103 |
# |
96f249dce03e
revset: move order constants from revsetlang
Yuya Nishihara <yuya@tcha.org>
parents:
34011
diff
changeset
|
104 |
# There are a few revsets that always redefine the order if 'define' is |
96f249dce03e
revset: move order constants from revsetlang
Yuya Nishihara <yuya@tcha.org>
parents:
34011
diff
changeset
|
105 |
# specified: 'sort(X)', 'reverse(X)', 'x:y'. |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
106 |
anyorder = b'any' # don't care the order, could be even random-shuffled |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
107 |
defineorder = b'define' # ALWAYS redefine, or ALWAYS follow the current order |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
108 |
followorder = b'follow' # MUST follow the current order |
34016
96f249dce03e
revset: move order constants from revsetlang
Yuya Nishihara <yuya@tcha.org>
parents:
34011
diff
changeset
|
109 |
|
11275 | 110 |
# helpers |
111 |
||
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
112 |
|
34011
1b28525e6698
revset: remove order information from tree (API)
Jun Wu <quark@fb.com>
parents:
33855
diff
changeset
|
113 |
def getset(repo, subset, x, order=defineorder): |
11275 | 114 |
if not x: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
115 |
raise error.ParseError(_(b"missing argument")) |
34011
1b28525e6698
revset: remove order information from tree (API)
Jun Wu <quark@fb.com>
parents:
33855
diff
changeset
|
116 |
return methods[x[0]](repo, subset, *x[1:], order=order) |
11275 | 117 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
118 |
|
17003
42c472877825
revset: add a utility for obtaining the source of a given rev
Matt Harbison <matt_harbison@yahoo.com>
parents:
17002
diff
changeset
|
119 |
def _getrevsource(repo, r): |
42c472877825
revset: add a utility for obtaining the source of a given rev
Matt Harbison <matt_harbison@yahoo.com>
parents:
17002
diff
changeset
|
120 |
extra = repo[r].extra() |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
121 |
for label in (b'source', b'transplant_source', b'rebase_source'): |
17003
42c472877825
revset: add a utility for obtaining the source of a given rev
Matt Harbison <matt_harbison@yahoo.com>
parents:
17002
diff
changeset
|
122 |
if label in extra: |
42c472877825
revset: add a utility for obtaining the source of a given rev
Matt Harbison <matt_harbison@yahoo.com>
parents:
17002
diff
changeset
|
123 |
try: |
42c472877825
revset: add a utility for obtaining the source of a given rev
Matt Harbison <matt_harbison@yahoo.com>
parents:
17002
diff
changeset
|
124 |
return repo[extra[label]].rev() |
42c472877825
revset: add a utility for obtaining the source of a given rev
Matt Harbison <matt_harbison@yahoo.com>
parents:
17002
diff
changeset
|
125 |
except error.RepoLookupError: |
42c472877825
revset: add a utility for obtaining the source of a given rev
Matt Harbison <matt_harbison@yahoo.com>
parents:
17002
diff
changeset
|
126 |
pass |
42c472877825
revset: add a utility for obtaining the source of a given rev
Matt Harbison <matt_harbison@yahoo.com>
parents:
17002
diff
changeset
|
127 |
return None |
42c472877825
revset: add a utility for obtaining the source of a given rev
Matt Harbison <matt_harbison@yahoo.com>
parents:
17002
diff
changeset
|
128 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
129 |
|
35904
fc44c2657dc5
py3: drop b'' from repr() of smartset
Yuya Nishihara <yuya@tcha.org>
parents:
35892
diff
changeset
|
130 |
def _sortedb(xs): |
38575
152f4822d210
pycompat: move rapply() from util
Yuya Nishihara <yuya@tcha.org>
parents:
38565
diff
changeset
|
131 |
return sorted(pycompat.rapply(pycompat.maybebytestr, xs)) |
35904
fc44c2657dc5
py3: drop b'' from repr() of smartset
Yuya Nishihara <yuya@tcha.org>
parents:
35892
diff
changeset
|
132 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
133 |
|
11275 | 134 |
# operator methods |
135 |
||
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
136 |
|
34011
1b28525e6698
revset: remove order information from tree (API)
Jun Wu <quark@fb.com>
parents:
33855
diff
changeset
|
137 |
def stringset(repo, subset, x, order): |
37264
d2c912836465
revset: drop support for '' as alias for '.'
Martin von Zweigbergk <martinvonz@google.com>
parents:
37084
diff
changeset
|
138 |
if not x: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
139 |
raise error.ParseError(_(b"empty string is not a valid revision")) |
37271
0194dac77c93
scmutil: add method for looking up a context given a revision symbol
Martin von Zweigbergk <martinvonz@google.com>
parents:
37264
diff
changeset
|
140 |
x = scmutil.intrev(scmutil.revsymbol(repo, x)) |
42264
6bc1245cd598
revset: populate wdir() by its hash or revision number
Yuya Nishihara <yuya@tcha.org>
parents:
42262
diff
changeset
|
141 |
if x in subset or x in _virtualrevs and isinstance(subset, fullreposet): |
20364
a6cf48b2880d
revset: added baseset class (still empty) to improve revset performance
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20289
diff
changeset
|
142 |
return baseset([x]) |
22802
1fcd361efaf4
baseset: use default value instead of [] when possible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22801
diff
changeset
|
143 |
return baseset() |
11275 | 144 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
145 |
|
41222
8aca89a694d4
revset: introduce an API that avoids `formatspec` input serialization
Boris Feld <boris.feld@octobus.net>
parents:
40931
diff
changeset
|
146 |
def rawsmartset(repo, subset, x, order): |
8aca89a694d4
revset: introduce an API that avoids `formatspec` input serialization
Boris Feld <boris.feld@octobus.net>
parents:
40931
diff
changeset
|
147 |
"""argument is already a smartset, use that directly""" |
8aca89a694d4
revset: introduce an API that avoids `formatspec` input serialization
Boris Feld <boris.feld@octobus.net>
parents:
40931
diff
changeset
|
148 |
if order == followorder: |
8aca89a694d4
revset: introduce an API that avoids `formatspec` input serialization
Boris Feld <boris.feld@octobus.net>
parents:
40931
diff
changeset
|
149 |
return subset & x |
8aca89a694d4
revset: introduce an API that avoids `formatspec` input serialization
Boris Feld <boris.feld@octobus.net>
parents:
40931
diff
changeset
|
150 |
else: |
8aca89a694d4
revset: introduce an API that avoids `formatspec` input serialization
Boris Feld <boris.feld@octobus.net>
parents:
40931
diff
changeset
|
151 |
return x & subset |
8aca89a694d4
revset: introduce an API that avoids `formatspec` input serialization
Boris Feld <boris.feld@octobus.net>
parents:
40931
diff
changeset
|
152 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
153 |
|
29932
09a84e747c88
revset: pass around ordering flags to operations
Yuya Nishihara <yuya@tcha.org>
parents:
29931
diff
changeset
|
154 |
def rangeset(repo, subset, x, y, order): |
23162
69524a05a7fa
revset-rangeset: call 'getset' on a 'fullreposet'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23139
diff
changeset
|
155 |
m = getset(repo, fullreposet(repo), x) |
69524a05a7fa
revset-rangeset: call 'getset' on a 'fullreposet'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23139
diff
changeset
|
156 |
n = getset(repo, fullreposet(repo), y) |
11456
88abbb046e66
revset: deal with empty sets in range endpoints
Matt Mackall <mpm@selenic.com>
parents:
11446
diff
changeset
|
157 |
|
88abbb046e66
revset: deal with empty sets in range endpoints
Matt Mackall <mpm@selenic.com>
parents:
11446
diff
changeset
|
158 |
if not m or not n: |
22802
1fcd361efaf4
baseset: use default value instead of [] when possible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22801
diff
changeset
|
159 |
return baseset() |
30043
49d5434d68fb
revset: extract function that creates range set from computed revisions
Yuya Nishihara <yuya@tcha.org>
parents:
29955
diff
changeset
|
160 |
return _makerangeset(repo, subset, m.first(), n.last(), order) |
49d5434d68fb
revset: extract function that creates range set from computed revisions
Yuya Nishihara <yuya@tcha.org>
parents:
29955
diff
changeset
|
161 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
162 |
|
30803
d389f19f14aa
revset: do not transform range* operators in parsed tree
Yuya Nishihara <yuya@tcha.org>
parents:
30802
diff
changeset
|
163 |
def rangeall(repo, subset, x, order): |
d389f19f14aa
revset: do not transform range* operators in parsed tree
Yuya Nishihara <yuya@tcha.org>
parents:
30802
diff
changeset
|
164 |
assert x is None |
35673
134ef400cb11
revset: use 'tiprev' when appropriate
Boris Feld <boris.feld@octobus.net>
parents:
35438
diff
changeset
|
165 |
return _makerangeset(repo, subset, 0, repo.changelog.tiprev(), order) |
30803
d389f19f14aa
revset: do not transform range* operators in parsed tree
Yuya Nishihara <yuya@tcha.org>
parents:
30802
diff
changeset
|
166 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
167 |
|
30044
69b61d0bb008
revset: do not rewrite ':y' to '0:y' (issue5385)
Yuya Nishihara <yuya@tcha.org>
parents:
30043
diff
changeset
|
168 |
def rangepre(repo, subset, y, order): |
69b61d0bb008
revset: do not rewrite ':y' to '0:y' (issue5385)
Yuya Nishihara <yuya@tcha.org>
parents:
30043
diff
changeset
|
169 |
# ':y' can't be rewritten to '0:y' since '0' may be hidden |
69b61d0bb008
revset: do not rewrite ':y' to '0:y' (issue5385)
Yuya Nishihara <yuya@tcha.org>
parents:
30043
diff
changeset
|
170 |
n = getset(repo, fullreposet(repo), y) |
69b61d0bb008
revset: do not rewrite ':y' to '0:y' (issue5385)
Yuya Nishihara <yuya@tcha.org>
parents:
30043
diff
changeset
|
171 |
if not n: |
69b61d0bb008
revset: do not rewrite ':y' to '0:y' (issue5385)
Yuya Nishihara <yuya@tcha.org>
parents:
30043
diff
changeset
|
172 |
return baseset() |
69b61d0bb008
revset: do not rewrite ':y' to '0:y' (issue5385)
Yuya Nishihara <yuya@tcha.org>
parents:
30043
diff
changeset
|
173 |
return _makerangeset(repo, subset, 0, n.last(), order) |
69b61d0bb008
revset: do not rewrite ':y' to '0:y' (issue5385)
Yuya Nishihara <yuya@tcha.org>
parents:
30043
diff
changeset
|
174 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
175 |
|
30803
d389f19f14aa
revset: do not transform range* operators in parsed tree
Yuya Nishihara <yuya@tcha.org>
parents:
30802
diff
changeset
|
176 |
def rangepost(repo, subset, x, order): |
d389f19f14aa
revset: do not transform range* operators in parsed tree
Yuya Nishihara <yuya@tcha.org>
parents:
30802
diff
changeset
|
177 |
m = getset(repo, fullreposet(repo), x) |
d389f19f14aa
revset: do not transform range* operators in parsed tree
Yuya Nishihara <yuya@tcha.org>
parents:
30802
diff
changeset
|
178 |
if not m: |
d389f19f14aa
revset: do not transform range* operators in parsed tree
Yuya Nishihara <yuya@tcha.org>
parents:
30802
diff
changeset
|
179 |
return baseset() |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
180 |
return _makerangeset( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
181 |
repo, subset, m.first(), repo.changelog.tiprev(), order |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
182 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
183 |
|
30803
d389f19f14aa
revset: do not transform range* operators in parsed tree
Yuya Nishihara <yuya@tcha.org>
parents:
30802
diff
changeset
|
184 |
|
30043
49d5434d68fb
revset: extract function that creates range set from computed revisions
Yuya Nishihara <yuya@tcha.org>
parents:
29955
diff
changeset
|
185 |
def _makerangeset(repo, subset, m, n, order): |
25766
d51dac68ec98
revset: work around x:y range where x or y is wdir()
Yuya Nishihara <yuya@tcha.org>
parents:
25765
diff
changeset
|
186 |
if m == n: |
d51dac68ec98
revset: work around x:y range where x or y is wdir()
Yuya Nishihara <yuya@tcha.org>
parents:
25765
diff
changeset
|
187 |
r = baseset([m]) |
46113
59fa3890d40a
node: import symbols explicitly
Joerg Sonnenberger <joerg@bec.de>
parents:
45942
diff
changeset
|
188 |
elif n == wdirrev: |
25766
d51dac68ec98
revset: work around x:y range where x or y is wdir()
Yuya Nishihara <yuya@tcha.org>
parents:
25765
diff
changeset
|
189 |
r = spanset(repo, m, len(repo)) + baseset([n]) |
46113
59fa3890d40a
node: import symbols explicitly
Joerg Sonnenberger <joerg@bec.de>
parents:
45942
diff
changeset
|
190 |
elif m == wdirrev: |
35673
134ef400cb11
revset: use 'tiprev' when appropriate
Boris Feld <boris.feld@octobus.net>
parents:
35438
diff
changeset
|
191 |
r = baseset([m]) + spanset(repo, repo.changelog.tiprev(), n - 1) |
25766
d51dac68ec98
revset: work around x:y range where x or y is wdir()
Yuya Nishihara <yuya@tcha.org>
parents:
25765
diff
changeset
|
192 |
elif m < n: |
20526
9ad6dae67845
revset: changed revsets to use spanset
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20525
diff
changeset
|
193 |
r = spanset(repo, m, n + 1) |
11456
88abbb046e66
revset: deal with empty sets in range endpoints
Matt Mackall <mpm@selenic.com>
parents:
11446
diff
changeset
|
194 |
else: |
20526
9ad6dae67845
revset: changed revsets to use spanset
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20525
diff
changeset
|
195 |
r = spanset(repo, m, n - 1) |
29944
5f56a3b9675e
revset: fix order of nested 'range' expression (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
29943
diff
changeset
|
196 |
|
5f56a3b9675e
revset: fix order of nested 'range' expression (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
29943
diff
changeset
|
197 |
if order == defineorder: |
5f56a3b9675e
revset: fix order of nested 'range' expression (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
29943
diff
changeset
|
198 |
return r & subset |
5f56a3b9675e
revset: fix order of nested 'range' expression (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
29943
diff
changeset
|
199 |
else: |
5f56a3b9675e
revset: fix order of nested 'range' expression (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
29943
diff
changeset
|
200 |
# carrying the sorting over when possible would be more efficient |
5f56a3b9675e
revset: fix order of nested 'range' expression (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
29943
diff
changeset
|
201 |
return subset & r |
11275 | 202 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
203 |
|
29932
09a84e747c88
revset: pass around ordering flags to operations
Yuya Nishihara <yuya@tcha.org>
parents:
29931
diff
changeset
|
204 |
def dagrange(repo, subset, x, y, order): |
24115
ff24af40728b
revset: specify fullreposet without using spanset factory
Yuya Nishihara <yuya@tcha.org>
parents:
24114
diff
changeset
|
205 |
r = fullreposet(repo) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
206 |
xs = dagop.reachableroots( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
207 |
repo, getset(repo, r, x), getset(repo, r, y), includepath=True |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
208 |
) |
29139
64c1955a0461
revset: make dagrange preserve order of input set
Yuya Nishihara <yuya@tcha.org>
parents:
29119
diff
changeset
|
209 |
return subset & xs |
16860
e1aa1ed30030
revset: turn dagrange into a function
Bryan O'Sullivan <bryano@fb.com>
parents:
16859
diff
changeset
|
210 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
211 |
|
29932
09a84e747c88
revset: pass around ordering flags to operations
Yuya Nishihara <yuya@tcha.org>
parents:
29931
diff
changeset
|
212 |
def andset(repo, subset, x, y, order): |
34011
1b28525e6698
revset: remove order information from tree (API)
Jun Wu <quark@fb.com>
parents:
33855
diff
changeset
|
213 |
if order == anyorder: |
1b28525e6698
revset: remove order information from tree (API)
Jun Wu <quark@fb.com>
parents:
33855
diff
changeset
|
214 |
yorder = anyorder |
1b28525e6698
revset: remove order information from tree (API)
Jun Wu <quark@fb.com>
parents:
33855
diff
changeset
|
215 |
else: |
1b28525e6698
revset: remove order information from tree (API)
Jun Wu <quark@fb.com>
parents:
33855
diff
changeset
|
216 |
yorder = followorder |
1b28525e6698
revset: remove order information from tree (API)
Jun Wu <quark@fb.com>
parents:
33855
diff
changeset
|
217 |
return getset(repo, getset(repo, subset, x, order), y, yorder) |
1b28525e6698
revset: remove order information from tree (API)
Jun Wu <quark@fb.com>
parents:
33855
diff
changeset
|
218 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
219 |
|
34020
37b82485097f
revset: do not flip "and" arguments when optimizing
Jun Wu <quark@fb.com>
parents:
34019
diff
changeset
|
220 |
def andsmallyset(repo, subset, x, y, order): |
37b82485097f
revset: do not flip "and" arguments when optimizing
Jun Wu <quark@fb.com>
parents:
34019
diff
changeset
|
221 |
# 'andsmally(x, y)' is equivalent to 'and(x, y)', but faster when y is small |
34011
1b28525e6698
revset: remove order information from tree (API)
Jun Wu <quark@fb.com>
parents:
33855
diff
changeset
|
222 |
if order == anyorder: |
1b28525e6698
revset: remove order information from tree (API)
Jun Wu <quark@fb.com>
parents:
33855
diff
changeset
|
223 |
yorder = anyorder |
1b28525e6698
revset: remove order information from tree (API)
Jun Wu <quark@fb.com>
parents:
33855
diff
changeset
|
224 |
else: |
1b28525e6698
revset: remove order information from tree (API)
Jun Wu <quark@fb.com>
parents:
33855
diff
changeset
|
225 |
yorder = followorder |
1b28525e6698
revset: remove order information from tree (API)
Jun Wu <quark@fb.com>
parents:
33855
diff
changeset
|
226 |
return getset(repo, getset(repo, subset, y, yorder), x, order) |
11275 | 227 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
228 |
|
29932
09a84e747c88
revset: pass around ordering flags to operations
Yuya Nishihara <yuya@tcha.org>
parents:
29931
diff
changeset
|
229 |
def differenceset(repo, subset, x, y, order): |
34011
1b28525e6698
revset: remove order information from tree (API)
Jun Wu <quark@fb.com>
parents:
33855
diff
changeset
|
230 |
return getset(repo, subset, x, order) - getset(repo, subset, y, anyorder) |
28217
d2ac8b57a75d
revset: use smartset minus operator
Durham Goode <durham@fb.com>
parents:
28139
diff
changeset
|
231 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
232 |
|
34011
1b28525e6698
revset: remove order information from tree (API)
Jun Wu <quark@fb.com>
parents:
33855
diff
changeset
|
233 |
def _orsetlist(repo, subset, xs, order): |
25929
289149111d46
revset: make balanced addsets by orset() without using _combinesets()
Yuya Nishihara <yuya@tcha.org>
parents:
25927
diff
changeset
|
234 |
assert xs |
289149111d46
revset: make balanced addsets by orset() without using _combinesets()
Yuya Nishihara <yuya@tcha.org>
parents:
25927
diff
changeset
|
235 |
if len(xs) == 1: |
34011
1b28525e6698
revset: remove order information from tree (API)
Jun Wu <quark@fb.com>
parents:
33855
diff
changeset
|
236 |
return getset(repo, subset, xs[0], order) |
25929
289149111d46
revset: make balanced addsets by orset() without using _combinesets()
Yuya Nishihara <yuya@tcha.org>
parents:
25927
diff
changeset
|
237 |
p = len(xs) // 2 |
34011
1b28525e6698
revset: remove order information from tree (API)
Jun Wu <quark@fb.com>
parents:
33855
diff
changeset
|
238 |
a = _orsetlist(repo, subset, xs[:p], order) |
1b28525e6698
revset: remove order information from tree (API)
Jun Wu <quark@fb.com>
parents:
33855
diff
changeset
|
239 |
b = _orsetlist(repo, subset, xs[p:], order) |
25929
289149111d46
revset: make balanced addsets by orset() without using _combinesets()
Yuya Nishihara <yuya@tcha.org>
parents:
25927
diff
changeset
|
240 |
return a + b |
11275 | 241 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
242 |
|
29932
09a84e747c88
revset: pass around ordering flags to operations
Yuya Nishihara <yuya@tcha.org>
parents:
29931
diff
changeset
|
243 |
def orset(repo, subset, x, order): |
29934
2c6a05b938d8
revset: fix order of nested 'or' expression (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
29933
diff
changeset
|
244 |
xs = getlist(x) |
38489
626d29c6e987
revset: leverage orset() to flatten ancestor() arguments
Yuya Nishihara <yuya@tcha.org>
parents:
38488
diff
changeset
|
245 |
if not xs: |
626d29c6e987
revset: leverage orset() to flatten ancestor() arguments
Yuya Nishihara <yuya@tcha.org>
parents:
38488
diff
changeset
|
246 |
return baseset() |
29934
2c6a05b938d8
revset: fix order of nested 'or' expression (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
29933
diff
changeset
|
247 |
if order == followorder: |
2c6a05b938d8
revset: fix order of nested 'or' expression (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
29933
diff
changeset
|
248 |
# slow path to take the subset order |
34011
1b28525e6698
revset: remove order information from tree (API)
Jun Wu <quark@fb.com>
parents:
33855
diff
changeset
|
249 |
return subset & _orsetlist(repo, fullreposet(repo), xs, anyorder) |
29934
2c6a05b938d8
revset: fix order of nested 'or' expression (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
29933
diff
changeset
|
250 |
else: |
34011
1b28525e6698
revset: remove order information from tree (API)
Jun Wu <quark@fb.com>
parents:
33855
diff
changeset
|
251 |
return _orsetlist(repo, subset, xs, order) |
29929
b3845cab4ddc
revset: wrap arguments of 'or' by 'list' node
Yuya Nishihara <yuya@tcha.org>
parents:
29922
diff
changeset
|
252 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
253 |
|
29932
09a84e747c88
revset: pass around ordering flags to operations
Yuya Nishihara <yuya@tcha.org>
parents:
29931
diff
changeset
|
254 |
def notset(repo, subset, x, order): |
34011
1b28525e6698
revset: remove order information from tree (API)
Jun Wu <quark@fb.com>
parents:
33855
diff
changeset
|
255 |
return subset - getset(repo, subset, x, anyorder) |
11275 | 256 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
257 |
|
33416
9467d5337292
revset: add experimental relation and subscript operators
Yuya Nishihara <yuya@tcha.org>
parents:
33377
diff
changeset
|
258 |
def relationset(repo, subset, x, y, order): |
44710
eca82eb9d777
revset: implement a simple 'foo#generations' expression
Anton Shestakov <av6@dwimlabs.net>
parents:
44709
diff
changeset
|
259 |
# this is pretty basic implementation of 'x#y' operator, still |
eca82eb9d777
revset: implement a simple 'foo#generations' expression
Anton Shestakov <av6@dwimlabs.net>
parents:
44709
diff
changeset
|
260 |
# experimental so undocumented. see the wiki for further ideas. |
eca82eb9d777
revset: implement a simple 'foo#generations' expression
Anton Shestakov <av6@dwimlabs.net>
parents:
44709
diff
changeset
|
261 |
# https://www.mercurial-scm.org/wiki/RevsetOperatorPlan |
eca82eb9d777
revset: implement a simple 'foo#generations' expression
Anton Shestakov <av6@dwimlabs.net>
parents:
44709
diff
changeset
|
262 |
rel = getsymbol(y) |
eca82eb9d777
revset: implement a simple 'foo#generations' expression
Anton Shestakov <av6@dwimlabs.net>
parents:
44709
diff
changeset
|
263 |
if rel in relations: |
eca82eb9d777
revset: implement a simple 'foo#generations' expression
Anton Shestakov <av6@dwimlabs.net>
parents:
44709
diff
changeset
|
264 |
return relations[rel](repo, subset, x, rel, order) |
eca82eb9d777
revset: implement a simple 'foo#generations' expression
Anton Shestakov <av6@dwimlabs.net>
parents:
44709
diff
changeset
|
265 |
|
eca82eb9d777
revset: implement a simple 'foo#generations' expression
Anton Shestakov <av6@dwimlabs.net>
parents:
44709
diff
changeset
|
266 |
relnames = [r for r in relations.keys() if len(r) > 1] |
eca82eb9d777
revset: implement a simple 'foo#generations' expression
Anton Shestakov <av6@dwimlabs.net>
parents:
44709
diff
changeset
|
267 |
raise error.UnknownIdentifier(rel, relnames) |
33416
9467d5337292
revset: add experimental relation and subscript operators
Yuya Nishihara <yuya@tcha.org>
parents:
33377
diff
changeset
|
268 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
269 |
|
41359
431cf2c8c839
revset: support ranges in #generations relation
Anton Shestakov <av6@dwimlabs.net>
parents:
41297
diff
changeset
|
270 |
def _splitrange(a, b): |
431cf2c8c839
revset: support ranges in #generations relation
Anton Shestakov <av6@dwimlabs.net>
parents:
41297
diff
changeset
|
271 |
"""Split range with bounds a and b into two ranges at 0 and return two |
431cf2c8c839
revset: support ranges in #generations relation
Anton Shestakov <av6@dwimlabs.net>
parents:
41297
diff
changeset
|
272 |
tuples of numbers for use as startdepth and stopdepth arguments of |
431cf2c8c839
revset: support ranges in #generations relation
Anton Shestakov <av6@dwimlabs.net>
parents:
41297
diff
changeset
|
273 |
revancestors and revdescendants. |
431cf2c8c839
revset: support ranges in #generations relation
Anton Shestakov <av6@dwimlabs.net>
parents:
41297
diff
changeset
|
274 |
|
431cf2c8c839
revset: support ranges in #generations relation
Anton Shestakov <av6@dwimlabs.net>
parents:
41297
diff
changeset
|
275 |
>>> _splitrange(-10, -5) # [-10:-5] |
431cf2c8c839
revset: support ranges in #generations relation
Anton Shestakov <av6@dwimlabs.net>
parents:
41297
diff
changeset
|
276 |
((5, 11), (None, None)) |
431cf2c8c839
revset: support ranges in #generations relation
Anton Shestakov <av6@dwimlabs.net>
parents:
41297
diff
changeset
|
277 |
>>> _splitrange(5, 10) # [5:10] |
431cf2c8c839
revset: support ranges in #generations relation
Anton Shestakov <av6@dwimlabs.net>
parents:
41297
diff
changeset
|
278 |
((None, None), (5, 11)) |
431cf2c8c839
revset: support ranges in #generations relation
Anton Shestakov <av6@dwimlabs.net>
parents:
41297
diff
changeset
|
279 |
>>> _splitrange(-10, 10) # [-10:10] |
431cf2c8c839
revset: support ranges in #generations relation
Anton Shestakov <av6@dwimlabs.net>
parents:
41297
diff
changeset
|
280 |
((0, 11), (0, 11)) |
431cf2c8c839
revset: support ranges in #generations relation
Anton Shestakov <av6@dwimlabs.net>
parents:
41297
diff
changeset
|
281 |
>>> _splitrange(-10, 0) # [-10:0] |
431cf2c8c839
revset: support ranges in #generations relation
Anton Shestakov <av6@dwimlabs.net>
parents:
41297
diff
changeset
|
282 |
((0, 11), (None, None)) |
431cf2c8c839
revset: support ranges in #generations relation
Anton Shestakov <av6@dwimlabs.net>
parents:
41297
diff
changeset
|
283 |
>>> _splitrange(0, 10) # [0:10] |
431cf2c8c839
revset: support ranges in #generations relation
Anton Shestakov <av6@dwimlabs.net>
parents:
41297
diff
changeset
|
284 |
((None, None), (0, 11)) |
431cf2c8c839
revset: support ranges in #generations relation
Anton Shestakov <av6@dwimlabs.net>
parents:
41297
diff
changeset
|
285 |
>>> _splitrange(0, 0) # [0:0] |
431cf2c8c839
revset: support ranges in #generations relation
Anton Shestakov <av6@dwimlabs.net>
parents:
41297
diff
changeset
|
286 |
((0, 1), (None, None)) |
431cf2c8c839
revset: support ranges in #generations relation
Anton Shestakov <av6@dwimlabs.net>
parents:
41297
diff
changeset
|
287 |
>>> _splitrange(1, -1) # [1:-1] |
431cf2c8c839
revset: support ranges in #generations relation
Anton Shestakov <av6@dwimlabs.net>
parents:
41297
diff
changeset
|
288 |
((None, None), (None, None)) |
431cf2c8c839
revset: support ranges in #generations relation
Anton Shestakov <av6@dwimlabs.net>
parents:
41297
diff
changeset
|
289 |
""" |
431cf2c8c839
revset: support ranges in #generations relation
Anton Shestakov <av6@dwimlabs.net>
parents:
41297
diff
changeset
|
290 |
ancdepths = (None, None) |
431cf2c8c839
revset: support ranges in #generations relation
Anton Shestakov <av6@dwimlabs.net>
parents:
41297
diff
changeset
|
291 |
descdepths = (None, None) |
431cf2c8c839
revset: support ranges in #generations relation
Anton Shestakov <av6@dwimlabs.net>
parents:
41297
diff
changeset
|
292 |
if a == b == 0: |
431cf2c8c839
revset: support ranges in #generations relation
Anton Shestakov <av6@dwimlabs.net>
parents:
41297
diff
changeset
|
293 |
ancdepths = (0, 1) |
431cf2c8c839
revset: support ranges in #generations relation
Anton Shestakov <av6@dwimlabs.net>
parents:
41297
diff
changeset
|
294 |
if a < 0: |
431cf2c8c839
revset: support ranges in #generations relation
Anton Shestakov <av6@dwimlabs.net>
parents:
41297
diff
changeset
|
295 |
ancdepths = (-min(b, 0), -a + 1) |
431cf2c8c839
revset: support ranges in #generations relation
Anton Shestakov <av6@dwimlabs.net>
parents:
41297
diff
changeset
|
296 |
if b > 0: |
431cf2c8c839
revset: support ranges in #generations relation
Anton Shestakov <av6@dwimlabs.net>
parents:
41297
diff
changeset
|
297 |
descdepths = (max(a, 0), b + 1) |
431cf2c8c839
revset: support ranges in #generations relation
Anton Shestakov <av6@dwimlabs.net>
parents:
41297
diff
changeset
|
298 |
return ancdepths, descdepths |
431cf2c8c839
revset: support ranges in #generations relation
Anton Shestakov <av6@dwimlabs.net>
parents:
41297
diff
changeset
|
299 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
300 |
|
44710
eca82eb9d777
revset: implement a simple 'foo#generations' expression
Anton Shestakov <av6@dwimlabs.net>
parents:
44709
diff
changeset
|
301 |
def generationsrel(repo, subset, x, rel, order): |
eca82eb9d777
revset: implement a simple 'foo#generations' expression
Anton Shestakov <av6@dwimlabs.net>
parents:
44709
diff
changeset
|
302 |
z = (b'rangeall', None) |
eca82eb9d777
revset: implement a simple 'foo#generations' expression
Anton Shestakov <av6@dwimlabs.net>
parents:
44709
diff
changeset
|
303 |
return generationssubrel(repo, subset, x, rel, z, order) |
eca82eb9d777
revset: implement a simple 'foo#generations' expression
Anton Shestakov <av6@dwimlabs.net>
parents:
44709
diff
changeset
|
304 |
|
eca82eb9d777
revset: implement a simple 'foo#generations' expression
Anton Shestakov <av6@dwimlabs.net>
parents:
44709
diff
changeset
|
305 |
|
44709
8859de3e83dc
revset: rename generationsrel() to generationssubrel()
Anton Shestakov <av6@dwimlabs.net>
parents:
44700
diff
changeset
|
306 |
def generationssubrel(repo, subset, x, rel, z, order): |
41359
431cf2c8c839
revset: support ranges in #generations relation
Anton Shestakov <av6@dwimlabs.net>
parents:
41297
diff
changeset
|
307 |
# TODO: rewrite tests, and drop startdepth argument from ancestors() and |
431cf2c8c839
revset: support ranges in #generations relation
Anton Shestakov <av6@dwimlabs.net>
parents:
41297
diff
changeset
|
308 |
# descendants() predicates |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
309 |
a, b = getintrange( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
310 |
z, |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
311 |
_(b'relation subscript must be an integer or a range'), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
312 |
_(b'relation subscript bounds must be integers'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
313 |
deffirst=-(dagop.maxlogdepth - 1), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
314 |
deflast=+(dagop.maxlogdepth - 1), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
315 |
) |
41359
431cf2c8c839
revset: support ranges in #generations relation
Anton Shestakov <av6@dwimlabs.net>
parents:
41297
diff
changeset
|
316 |
(ancstart, ancstop), (descstart, descstop) = _splitrange(a, b) |
431cf2c8c839
revset: support ranges in #generations relation
Anton Shestakov <av6@dwimlabs.net>
parents:
41297
diff
changeset
|
317 |
|
431cf2c8c839
revset: support ranges in #generations relation
Anton Shestakov <av6@dwimlabs.net>
parents:
41297
diff
changeset
|
318 |
if ancstart is None and descstart is None: |
431cf2c8c839
revset: support ranges in #generations relation
Anton Shestakov <av6@dwimlabs.net>
parents:
41297
diff
changeset
|
319 |
return baseset() |
431cf2c8c839
revset: support ranges in #generations relation
Anton Shestakov <av6@dwimlabs.net>
parents:
41297
diff
changeset
|
320 |
|
431cf2c8c839
revset: support ranges in #generations relation
Anton Shestakov <av6@dwimlabs.net>
parents:
41297
diff
changeset
|
321 |
revs = getset(repo, fullreposet(repo), x) |
431cf2c8c839
revset: support ranges in #generations relation
Anton Shestakov <av6@dwimlabs.net>
parents:
41297
diff
changeset
|
322 |
if not revs: |
431cf2c8c839
revset: support ranges in #generations relation
Anton Shestakov <av6@dwimlabs.net>
parents:
41297
diff
changeset
|
323 |
return baseset() |
431cf2c8c839
revset: support ranges in #generations relation
Anton Shestakov <av6@dwimlabs.net>
parents:
41297
diff
changeset
|
324 |
|
431cf2c8c839
revset: support ranges in #generations relation
Anton Shestakov <av6@dwimlabs.net>
parents:
41297
diff
changeset
|
325 |
if ancstart is not None and descstart is not None: |
431cf2c8c839
revset: support ranges in #generations relation
Anton Shestakov <av6@dwimlabs.net>
parents:
41297
diff
changeset
|
326 |
s = dagop.revancestors(repo, revs, False, ancstart, ancstop) |
431cf2c8c839
revset: support ranges in #generations relation
Anton Shestakov <av6@dwimlabs.net>
parents:
41297
diff
changeset
|
327 |
s += dagop.revdescendants(repo, revs, False, descstart, descstop) |
431cf2c8c839
revset: support ranges in #generations relation
Anton Shestakov <av6@dwimlabs.net>
parents:
41297
diff
changeset
|
328 |
elif ancstart is not None: |
431cf2c8c839
revset: support ranges in #generations relation
Anton Shestakov <av6@dwimlabs.net>
parents:
41297
diff
changeset
|
329 |
s = dagop.revancestors(repo, revs, False, ancstart, ancstop) |
431cf2c8c839
revset: support ranges in #generations relation
Anton Shestakov <av6@dwimlabs.net>
parents:
41297
diff
changeset
|
330 |
elif descstart is not None: |
431cf2c8c839
revset: support ranges in #generations relation
Anton Shestakov <av6@dwimlabs.net>
parents:
41297
diff
changeset
|
331 |
s = dagop.revdescendants(repo, revs, False, descstart, descstop) |
431cf2c8c839
revset: support ranges in #generations relation
Anton Shestakov <av6@dwimlabs.net>
parents:
41297
diff
changeset
|
332 |
|
431cf2c8c839
revset: support ranges in #generations relation
Anton Shestakov <av6@dwimlabs.net>
parents:
41297
diff
changeset
|
333 |
return subset & s |
40931
e54bfde922f2
revset: move subscript relation functions to its own dict
Anton Shestakov <av6@dwimlabs.net>
parents:
40534
diff
changeset
|
334 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
335 |
|
33416
9467d5337292
revset: add experimental relation and subscript operators
Yuya Nishihara <yuya@tcha.org>
parents:
33377
diff
changeset
|
336 |
def relsubscriptset(repo, subset, x, y, z, order): |
33417
d1b13d4995ed
revset: add experimental ancestors/descendants relation subscript
Yuya Nishihara <yuya@tcha.org>
parents:
33416
diff
changeset
|
337 |
# this is pretty basic implementation of 'x#y[z]' operator, still |
d1b13d4995ed
revset: add experimental ancestors/descendants relation subscript
Yuya Nishihara <yuya@tcha.org>
parents:
33416
diff
changeset
|
338 |
# experimental so undocumented. see the wiki for further ideas. |
d1b13d4995ed
revset: add experimental ancestors/descendants relation subscript
Yuya Nishihara <yuya@tcha.org>
parents:
33416
diff
changeset
|
339 |
# https://www.mercurial-scm.org/wiki/RevsetOperatorPlan |
d1b13d4995ed
revset: add experimental ancestors/descendants relation subscript
Yuya Nishihara <yuya@tcha.org>
parents:
33416
diff
changeset
|
340 |
rel = getsymbol(y) |
40931
e54bfde922f2
revset: move subscript relation functions to its own dict
Anton Shestakov <av6@dwimlabs.net>
parents:
40534
diff
changeset
|
341 |
if rel in subscriptrelations: |
41563
13f7a6a4f0db
revset: leverage getintrange() helper in relation-subscript operation (API)
Yuya Nishihara <yuya@tcha.org>
parents:
41562
diff
changeset
|
342 |
return subscriptrelations[rel](repo, subset, x, rel, z, order) |
33417
d1b13d4995ed
revset: add experimental ancestors/descendants relation subscript
Yuya Nishihara <yuya@tcha.org>
parents:
33416
diff
changeset
|
343 |
|
40931
e54bfde922f2
revset: move subscript relation functions to its own dict
Anton Shestakov <av6@dwimlabs.net>
parents:
40534
diff
changeset
|
344 |
relnames = [r for r in subscriptrelations.keys() if len(r) > 1] |
e54bfde922f2
revset: move subscript relation functions to its own dict
Anton Shestakov <av6@dwimlabs.net>
parents:
40534
diff
changeset
|
345 |
raise error.UnknownIdentifier(rel, relnames) |
33416
9467d5337292
revset: add experimental relation and subscript operators
Yuya Nishihara <yuya@tcha.org>
parents:
33377
diff
changeset
|
346 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
347 |
|
33416
9467d5337292
revset: add experimental relation and subscript operators
Yuya Nishihara <yuya@tcha.org>
parents:
33377
diff
changeset
|
348 |
def subscriptset(repo, subset, x, y, order): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
349 |
raise error.ParseError(_(b"can't use a subscript in this context")) |
33416
9467d5337292
revset: add experimental relation and subscript operators
Yuya Nishihara <yuya@tcha.org>
parents:
33377
diff
changeset
|
350 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
351 |
|
34011
1b28525e6698
revset: remove order information from tree (API)
Jun Wu <quark@fb.com>
parents:
33855
diff
changeset
|
352 |
def listset(repo, subset, *xs, **opts): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
353 |
raise error.ParseError( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
354 |
_(b"can't use a list in this context"), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
355 |
hint=_(b'see \'hg help "revsets.x or y"\''), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
356 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
357 |
|
11275 | 358 |
|
34011
1b28525e6698
revset: remove order information from tree (API)
Jun Wu <quark@fb.com>
parents:
33855
diff
changeset
|
359 |
def keyvaluepair(repo, subset, k, v, order): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
360 |
raise error.ParseError(_(b"can't use a key-value pair in this context")) |
25704
70a2082f855a
revset: add parsing rule for key=value pair
Yuya Nishihara <yuya@tcha.org>
parents:
25689
diff
changeset
|
361 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
362 |
|
29932
09a84e747c88
revset: pass around ordering flags to operations
Yuya Nishihara <yuya@tcha.org>
parents:
29931
diff
changeset
|
363 |
def func(repo, subset, a, b, order): |
29441
9e8d258708bb
revset: check invalid function syntax "func-name"() explicitly
Yuya Nishihara <yuya@tcha.org>
parents:
29425
diff
changeset
|
364 |
f = getsymbol(a) |
9e8d258708bb
revset: check invalid function syntax "func-name"() explicitly
Yuya Nishihara <yuya@tcha.org>
parents:
29425
diff
changeset
|
365 |
if f in symbols: |
30392
155d7ea98085
revset: avoid shadowing a variable with a list comprehension
Augie Fackler <augie@google.com>
parents:
30332
diff
changeset
|
366 |
func = symbols[f] |
155d7ea98085
revset: avoid shadowing a variable with a list comprehension
Augie Fackler <augie@google.com>
parents:
30332
diff
changeset
|
367 |
if getattr(func, '_takeorder', False): |
155d7ea98085
revset: avoid shadowing a variable with a list comprehension
Augie Fackler <augie@google.com>
parents:
30332
diff
changeset
|
368 |
return func(repo, subset, b, order) |
155d7ea98085
revset: avoid shadowing a variable with a list comprehension
Augie Fackler <augie@google.com>
parents:
30332
diff
changeset
|
369 |
return func(repo, subset, b) |
25632
015c0d1087a3
revset: don't suggest private or undocumented queries
Matt Harbison <matt_harbison@yahoo.com>
parents:
25630
diff
changeset
|
370 |
|
015c0d1087a3
revset: don't suggest private or undocumented queries
Matt Harbison <matt_harbison@yahoo.com>
parents:
25630
diff
changeset
|
371 |
keep = lambda fn: getattr(fn, '__doc__', None) is not None |
015c0d1087a3
revset: don't suggest private or undocumented queries
Matt Harbison <matt_harbison@yahoo.com>
parents:
25630
diff
changeset
|
372 |
|
015c0d1087a3
revset: don't suggest private or undocumented queries
Matt Harbison <matt_harbison@yahoo.com>
parents:
25630
diff
changeset
|
373 |
syms = [s for (s, fn) in symbols.items() if keep(fn)] |
29441
9e8d258708bb
revset: check invalid function syntax "func-name"() explicitly
Yuya Nishihara <yuya@tcha.org>
parents:
29425
diff
changeset
|
374 |
raise error.UnknownIdentifier(f, syms) |
11275 | 375 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
376 |
|
11275 | 377 |
# functions |
378 |
||
27584
fc7c8cac6a4b
revset: use decorator to register a function as revset predicate
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27517
diff
changeset
|
379 |
# symbols are callables like: |
fc7c8cac6a4b
revset: use decorator to register a function as revset predicate
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27517
diff
changeset
|
380 |
# fn(repo, subset, x) |
fc7c8cac6a4b
revset: use decorator to register a function as revset predicate
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27517
diff
changeset
|
381 |
# with: |
fc7c8cac6a4b
revset: use decorator to register a function as revset predicate
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27517
diff
changeset
|
382 |
# repo - current repository instance |
fc7c8cac6a4b
revset: use decorator to register a function as revset predicate
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27517
diff
changeset
|
383 |
# subset - of revisions to be examined |
fc7c8cac6a4b
revset: use decorator to register a function as revset predicate
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27517
diff
changeset
|
384 |
# x - argument in tree form |
34273
b0790bebfcf8
revset: move weight information to predicate
Jun Wu <quark@fb.com>
parents:
34065
diff
changeset
|
385 |
symbols = revsetlang.symbols |
27584
fc7c8cac6a4b
revset: use decorator to register a function as revset predicate
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27517
diff
changeset
|
386 |
|
27587
c8dc480142a8
revset: use decorator to mark a predicate as safe
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27586
diff
changeset
|
387 |
# symbols which can't be used for a DoS attack for any given input |
c8dc480142a8
revset: use decorator to mark a predicate as safe
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27586
diff
changeset
|
388 |
# (e.g. those which accept regexes as plain strings shouldn't be included) |
c8dc480142a8
revset: use decorator to mark a predicate as safe
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27586
diff
changeset
|
389 |
# functions that just return a lot of changesets (like all) don't count here |
c8dc480142a8
revset: use decorator to mark a predicate as safe
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27586
diff
changeset
|
390 |
safesymbols = set() |
c8dc480142a8
revset: use decorator to mark a predicate as safe
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27586
diff
changeset
|
391 |
|
28395
0383f7a5e86c
revset: replace predicate by revsetpredicate of registrar
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28393
diff
changeset
|
392 |
predicate = registrar.revsetpredicate() |
27587
c8dc480142a8
revset: use decorator to mark a predicate as safe
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27586
diff
changeset
|
393 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
394 |
|
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
395 |
@predicate(b'_destupdate') |
26713
a271925699d6
revset: reintroduce and experimental revset for update destination
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26638
diff
changeset
|
396 |
def _destupdate(repo, subset, x): |
a271925699d6
revset: reintroduce and experimental revset for update destination
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26638
diff
changeset
|
397 |
# experimental revset for update destination |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
398 |
args = getargsdict(x, b'limit', b'clean') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
399 |
return subset & baseset( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
400 |
[destutil.destupdate(repo, **pycompat.strkwargs(args))[0]] |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
401 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
402 |
|
26713
a271925699d6
revset: reintroduce and experimental revset for update destination
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26638
diff
changeset
|
403 |
|
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
404 |
@predicate(b'_destmerge') |
26716
c027641f8a83
revset: rename and test '_destmerge'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26714
diff
changeset
|
405 |
def _destmerge(repo, subset, x): |
c027641f8a83
revset: rename and test '_destmerge'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26714
diff
changeset
|
406 |
# experimental revset for merge destination |
28139
5476a7a039c0
destutil: allow to specify an explicit source for the merge
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
28015
diff
changeset
|
407 |
sourceset = None |
5476a7a039c0
destutil: allow to specify an explicit source for the merge
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
28015
diff
changeset
|
408 |
if x is not None: |
5476a7a039c0
destutil: allow to specify an explicit source for the merge
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
28015
diff
changeset
|
409 |
sourceset = getset(repo, fullreposet(repo), x) |
5476a7a039c0
destutil: allow to specify an explicit source for the merge
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
28015
diff
changeset
|
410 |
return subset & baseset([destutil.destmerge(repo, sourceset=sourceset)]) |
26303
c99b4d6efdd8
merge: move default destination computation in a revset
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26232
diff
changeset
|
411 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
412 |
|
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
413 |
@predicate(b'adds(pattern)', safe=True, weight=30) |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
414 |
def adds(repo, subset, x): |
27584
fc7c8cac6a4b
revset: use decorator to register a function as revset predicate
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27517
diff
changeset
|
415 |
"""Changesets that add a file matching pattern. |
20289
96be25f1da45
revset: add explanation about the pattern without explicit kind
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20288
diff
changeset
|
416 |
|
96be25f1da45
revset: add explanation about the pattern without explicit kind
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20288
diff
changeset
|
417 |
The pattern without explicit kind like ``glob:`` is expected to be |
96be25f1da45
revset: add explanation about the pattern without explicit kind
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20288
diff
changeset
|
418 |
relative to the current directory and match against a file or a |
96be25f1da45
revset: add explanation about the pattern without explicit kind
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20288
diff
changeset
|
419 |
directory. |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
420 |
""" |
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
421 |
# i18n: "adds" is a keyword |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
422 |
pat = getstring(x, _(b"adds requires a pattern")) |
45428
9b9071fabcd3
revset: remove indirect indexing of status tuple
Yuya Nishihara <yuya@tcha.org>
parents:
44856
diff
changeset
|
423 |
return checkstatus(repo, subset, pat, 'added') |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
424 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
425 |
|
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
426 |
@predicate(b'ancestor(*changeset)', safe=True, weight=0.5) |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
427 |
def ancestor(repo, subset, x): |
27584
fc7c8cac6a4b
revset: use decorator to register a function as revset predicate
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27517
diff
changeset
|
428 |
"""A greatest common ancestor of the changesets. |
18536
ae645d4f084c
revset: change ancestor to accept 0 or more arguments (issue3750)
Paul Cavallaro <ptc@fb.com>
parents:
18495
diff
changeset
|
429 |
|
ae645d4f084c
revset: change ancestor to accept 0 or more arguments (issue3750)
Paul Cavallaro <ptc@fb.com>
parents:
18495
diff
changeset
|
430 |
Accepts 0 or more changesets. |
ae645d4f084c
revset: change ancestor to accept 0 or more arguments (issue3750)
Paul Cavallaro <ptc@fb.com>
parents:
18495
diff
changeset
|
431 |
Will return empty list when passed no args. |
ae645d4f084c
revset: change ancestor to accept 0 or more arguments (issue3750)
Paul Cavallaro <ptc@fb.com>
parents:
18495
diff
changeset
|
432 |
Greatest common ancestor of a single changeset is that changeset. |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
433 |
""" |
38490
5d88fd1bc2af
revset: move lookup of first ancestor() candidate out of the loop
Yuya Nishihara <yuya@tcha.org>
parents:
38489
diff
changeset
|
434 |
reviter = iter(orset(repo, fullreposet(repo), x, order=anyorder)) |
5d88fd1bc2af
revset: move lookup of first ancestor() candidate out of the loop
Yuya Nishihara <yuya@tcha.org>
parents:
38489
diff
changeset
|
435 |
try: |
5d88fd1bc2af
revset: move lookup of first ancestor() candidate out of the loop
Yuya Nishihara <yuya@tcha.org>
parents:
38489
diff
changeset
|
436 |
anc = repo[next(reviter)] |
5d88fd1bc2af
revset: move lookup of first ancestor() candidate out of the loop
Yuya Nishihara <yuya@tcha.org>
parents:
38489
diff
changeset
|
437 |
except StopIteration: |
5d88fd1bc2af
revset: move lookup of first ancestor() candidate out of the loop
Yuya Nishihara <yuya@tcha.org>
parents:
38489
diff
changeset
|
438 |
return baseset() |
5d88fd1bc2af
revset: move lookup of first ancestor() candidate out of the loop
Yuya Nishihara <yuya@tcha.org>
parents:
38489
diff
changeset
|
439 |
for r in reviter: |
5d88fd1bc2af
revset: move lookup of first ancestor() candidate out of the loop
Yuya Nishihara <yuya@tcha.org>
parents:
38489
diff
changeset
|
440 |
anc = anc.ancestor(repo[r]) |
20991
a05d694599f9
revlog: use context ancestor instead of changelog ancestor
Mads Kiilerich <madski@unity3d.com>
parents:
20895
diff
changeset
|
441 |
|
38522
54d7aaa243cc
revset: add partial support for ancestor(wdir())
Yuya Nishihara <yuya@tcha.org>
parents:
38519
diff
changeset
|
442 |
r = scmutil.intrev(anc) |
54d7aaa243cc
revset: add partial support for ancestor(wdir())
Yuya Nishihara <yuya@tcha.org>
parents:
38519
diff
changeset
|
443 |
if r in subset: |
54d7aaa243cc
revset: add partial support for ancestor(wdir())
Yuya Nishihara <yuya@tcha.org>
parents:
38519
diff
changeset
|
444 |
return baseset([r]) |
22802
1fcd361efaf4
baseset: use default value instead of [] when possible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22801
diff
changeset
|
445 |
return baseset() |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
446 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
447 |
|
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
448 |
def _ancestors( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
449 |
repo, subset, x, followfirst=False, startdepth=None, stopdepth=None |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
450 |
): |
24115
ff24af40728b
revset: specify fullreposet without using spanset factory
Yuya Nishihara <yuya@tcha.org>
parents:
24114
diff
changeset
|
451 |
heads = getset(repo, fullreposet(repo), x) |
22944
5aae3dea8044
revset: better naming of variables containing the value of a single argument
Mads Kiilerich <madski@unity3d.com>
parents:
22891
diff
changeset
|
452 |
if not heads: |
22802
1fcd361efaf4
baseset: use default value instead of [] when possible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22801
diff
changeset
|
453 |
return baseset() |
33003
f63d111258da
revset: add startdepth limit to ancestors() as internal option
Yuya Nishihara <yuya@tcha.org>
parents:
33002
diff
changeset
|
454 |
s = dagop.revancestors(repo, heads, followfirst, startdepth, stopdepth) |
23003
62d19ce9d7b6
revset-_ancestor: use & instead of filter
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22999
diff
changeset
|
455 |
return subset & s |
16409
2cbd7dd0cc1f
graphlog: fix --follow-first --rev combinations
Patrick Mezard <patrick@mezard.eu>
parents:
16402
diff
changeset
|
456 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
457 |
|
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
458 |
@predicate(b'ancestors(set[, depth])', safe=True) |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
459 |
def ancestors(repo, subset, x): |
32905
2851b24eecc4
help: clarify ancestors() and descendants() include given set (issue5594)
Yuya Nishihara <yuya@tcha.org>
parents:
32904
diff
changeset
|
460 |
"""Changesets that are ancestors of changesets in set, including the |
2851b24eecc4
help: clarify ancestors() and descendants() include given set (issue5594)
Yuya Nishihara <yuya@tcha.org>
parents:
32904
diff
changeset
|
461 |
given changesets themselves. |
33002
272a44cac57e
revset: add depth limit to ancestors()
Yuya Nishihara <yuya@tcha.org>
parents:
32914
diff
changeset
|
462 |
|
272a44cac57e
revset: add depth limit to ancestors()
Yuya Nishihara <yuya@tcha.org>
parents:
32914
diff
changeset
|
463 |
If depth is specified, the result only includes changesets up to |
272a44cac57e
revset: add depth limit to ancestors()
Yuya Nishihara <yuya@tcha.org>
parents:
32914
diff
changeset
|
464 |
the specified generation. |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
465 |
""" |
33003
f63d111258da
revset: add startdepth limit to ancestors() as internal option
Yuya Nishihara <yuya@tcha.org>
parents:
33002
diff
changeset
|
466 |
# startdepth is for internal use only until we can decide the UI |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
467 |
args = getargsdict(x, b'ancestors', b'set depth startdepth') |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
468 |
if b'set' not in args: |
32914
577759ef2ed2
revset: add support of keyword arguments to ancestors() and descendants()
Yuya Nishihara <yuya@tcha.org>
parents:
32905
diff
changeset
|
469 |
# i18n: "ancestors" is a keyword |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
470 |
raise error.ParseError(_(b'ancestors takes at least 1 argument')) |
33003
f63d111258da
revset: add startdepth limit to ancestors() as internal option
Yuya Nishihara <yuya@tcha.org>
parents:
33002
diff
changeset
|
471 |
startdepth = stopdepth = None |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
472 |
if b'startdepth' in args: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
473 |
n = getinteger( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
474 |
args[b'startdepth'], b"ancestors expects an integer startdepth" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
475 |
) |
33003
f63d111258da
revset: add startdepth limit to ancestors() as internal option
Yuya Nishihara <yuya@tcha.org>
parents:
33002
diff
changeset
|
476 |
if n < 0: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
477 |
raise error.ParseError(b"negative startdepth") |
33003
f63d111258da
revset: add startdepth limit to ancestors() as internal option
Yuya Nishihara <yuya@tcha.org>
parents:
33002
diff
changeset
|
478 |
startdepth = n |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
479 |
if b'depth' in args: |
33002
272a44cac57e
revset: add depth limit to ancestors()
Yuya Nishihara <yuya@tcha.org>
parents:
32914
diff
changeset
|
480 |
# i18n: "ancestors" is a keyword |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
481 |
n = getinteger(args[b'depth'], _(b"ancestors expects an integer depth")) |
33002
272a44cac57e
revset: add depth limit to ancestors()
Yuya Nishihara <yuya@tcha.org>
parents:
32914
diff
changeset
|
482 |
if n < 0: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
483 |
raise error.ParseError(_(b"negative depth")) |
33002
272a44cac57e
revset: add depth limit to ancestors()
Yuya Nishihara <yuya@tcha.org>
parents:
32914
diff
changeset
|
484 |
stopdepth = n + 1 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
485 |
return _ancestors( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
486 |
repo, subset, args[b'set'], startdepth=startdepth, stopdepth=stopdepth |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
487 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
488 |
|
16409
2cbd7dd0cc1f
graphlog: fix --follow-first --rev combinations
Patrick Mezard <patrick@mezard.eu>
parents:
16402
diff
changeset
|
489 |
|
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
490 |
@predicate(b'_firstancestors', safe=True) |
16409
2cbd7dd0cc1f
graphlog: fix --follow-first --rev combinations
Patrick Mezard <patrick@mezard.eu>
parents:
16402
diff
changeset
|
491 |
def _firstancestors(repo, subset, x): |
2cbd7dd0cc1f
graphlog: fix --follow-first --rev combinations
Patrick Mezard <patrick@mezard.eu>
parents:
16402
diff
changeset
|
492 |
# ``_firstancestors(set)`` |
2cbd7dd0cc1f
graphlog: fix --follow-first --rev combinations
Patrick Mezard <patrick@mezard.eu>
parents:
16402
diff
changeset
|
493 |
# Like ``ancestors(set)`` but follows only the first parents. |
2cbd7dd0cc1f
graphlog: fix --follow-first --rev combinations
Patrick Mezard <patrick@mezard.eu>
parents:
16402
diff
changeset
|
494 |
return _ancestors(repo, subset, x, followfirst=True) |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
495 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
496 |
|
32699
f75d0aa5dc83
revset: lookup descendents for negative arguments to ancestor operator
David Soria Parra <davidsp@fb.com>
parents:
32684
diff
changeset
|
497 |
def _childrenspec(repo, subset, x, n, order): |
f75d0aa5dc83
revset: lookup descendents for negative arguments to ancestor operator
David Soria Parra <davidsp@fb.com>
parents:
32684
diff
changeset
|
498 |
"""Changesets that are the Nth child of a changeset |
f75d0aa5dc83
revset: lookup descendents for negative arguments to ancestor operator
David Soria Parra <davidsp@fb.com>
parents:
32684
diff
changeset
|
499 |
in set. |
f75d0aa5dc83
revset: lookup descendents for negative arguments to ancestor operator
David Soria Parra <davidsp@fb.com>
parents:
32684
diff
changeset
|
500 |
""" |
f75d0aa5dc83
revset: lookup descendents for negative arguments to ancestor operator
David Soria Parra <davidsp@fb.com>
parents:
32684
diff
changeset
|
501 |
cs = set() |
f75d0aa5dc83
revset: lookup descendents for negative arguments to ancestor operator
David Soria Parra <davidsp@fb.com>
parents:
32684
diff
changeset
|
502 |
for r in getset(repo, fullreposet(repo), x): |
f75d0aa5dc83
revset: lookup descendents for negative arguments to ancestor operator
David Soria Parra <davidsp@fb.com>
parents:
32684
diff
changeset
|
503 |
for i in range(n): |
f75d0aa5dc83
revset: lookup descendents for negative arguments to ancestor operator
David Soria Parra <davidsp@fb.com>
parents:
32684
diff
changeset
|
504 |
c = repo[r].children() |
f75d0aa5dc83
revset: lookup descendents for negative arguments to ancestor operator
David Soria Parra <davidsp@fb.com>
parents:
32684
diff
changeset
|
505 |
if len(c) == 0: |
f75d0aa5dc83
revset: lookup descendents for negative arguments to ancestor operator
David Soria Parra <davidsp@fb.com>
parents:
32684
diff
changeset
|
506 |
break |
f75d0aa5dc83
revset: lookup descendents for negative arguments to ancestor operator
David Soria Parra <davidsp@fb.com>
parents:
32684
diff
changeset
|
507 |
if len(c) > 1: |
f75d0aa5dc83
revset: lookup descendents for negative arguments to ancestor operator
David Soria Parra <davidsp@fb.com>
parents:
32684
diff
changeset
|
508 |
raise error.RepoLookupError( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
509 |
_(b"revision in set has more than one child") |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
510 |
) |
32885
8e02829bec61
revset: fix negative ancestor spec to not return changectx objects
Yuya Nishihara <yuya@tcha.org>
parents:
32819
diff
changeset
|
511 |
r = c[0].rev() |
32699
f75d0aa5dc83
revset: lookup descendents for negative arguments to ancestor operator
David Soria Parra <davidsp@fb.com>
parents:
32684
diff
changeset
|
512 |
else: |
f75d0aa5dc83
revset: lookup descendents for negative arguments to ancestor operator
David Soria Parra <davidsp@fb.com>
parents:
32684
diff
changeset
|
513 |
cs.add(r) |
f75d0aa5dc83
revset: lookup descendents for negative arguments to ancestor operator
David Soria Parra <davidsp@fb.com>
parents:
32684
diff
changeset
|
514 |
return subset & cs |
f75d0aa5dc83
revset: lookup descendents for negative arguments to ancestor operator
David Soria Parra <davidsp@fb.com>
parents:
32684
diff
changeset
|
515 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
516 |
|
29932
09a84e747c88
revset: pass around ordering flags to operations
Yuya Nishihara <yuya@tcha.org>
parents:
29931
diff
changeset
|
517 |
def ancestorspec(repo, subset, x, n, order): |
14070
305c97670d7a
revset: add ^ and ~ operators from parentrevspec extension
Kevin Gessner <kevin@kevingessner.com>
parents:
14061
diff
changeset
|
518 |
"""``set~n`` |
16683 | 519 |
Changesets that are the Nth ancestor (first parents only) of a changeset |
520 |
in set. |
|
14070
305c97670d7a
revset: add ^ and ~ operators from parentrevspec extension
Kevin Gessner <kevin@kevingessner.com>
parents:
14061
diff
changeset
|
521 |
""" |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
522 |
n = getinteger(n, _(b"~ expects a number")) |
32699
f75d0aa5dc83
revset: lookup descendents for negative arguments to ancestor operator
David Soria Parra <davidsp@fb.com>
parents:
32684
diff
changeset
|
523 |
if n < 0: |
f75d0aa5dc83
revset: lookup descendents for negative arguments to ancestor operator
David Soria Parra <davidsp@fb.com>
parents:
32684
diff
changeset
|
524 |
# children lookup |
f75d0aa5dc83
revset: lookup descendents for negative arguments to ancestor operator
David Soria Parra <davidsp@fb.com>
parents:
32684
diff
changeset
|
525 |
return _childrenspec(repo, subset, x, -n, order) |
14070
305c97670d7a
revset: add ^ and ~ operators from parentrevspec extension
Kevin Gessner <kevin@kevingessner.com>
parents:
14061
diff
changeset
|
526 |
ps = set() |
305c97670d7a
revset: add ^ and ~ operators from parentrevspec extension
Kevin Gessner <kevin@kevingessner.com>
parents:
14061
diff
changeset
|
527 |
cl = repo.changelog |
23163
6f1b8b3f12fd
revset-ancestorspec: call 'getset' on a 'fullreposet'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23162
diff
changeset
|
528 |
for r in getset(repo, fullreposet(repo), x): |
14070
305c97670d7a
revset: add ^ and ~ operators from parentrevspec extension
Kevin Gessner <kevin@kevingessner.com>
parents:
14061
diff
changeset
|
529 |
for i in range(n): |
32441
018f638ad88e
revset: add support for using ~ operator on wdir() predicate
Pulkit Goyal <7895pulkit@gmail.com>
parents:
32440
diff
changeset
|
530 |
try: |
018f638ad88e
revset: add support for using ~ operator on wdir() predicate
Pulkit Goyal <7895pulkit@gmail.com>
parents:
32440
diff
changeset
|
531 |
r = cl.parentrevs(r)[0] |
018f638ad88e
revset: add support for using ~ operator on wdir() predicate
Pulkit Goyal <7895pulkit@gmail.com>
parents:
32440
diff
changeset
|
532 |
except error.WdirUnsupported: |
41397
0bd56c291359
cleanup: use p1() and p2() instead of parents()[0] and parents()[1]
Martin von Zweigbergk <martinvonz@google.com>
parents:
41388
diff
changeset
|
533 |
r = repo[r].p1().rev() |
14070
305c97670d7a
revset: add ^ and ~ operators from parentrevspec extension
Kevin Gessner <kevin@kevingessner.com>
parents:
14061
diff
changeset
|
534 |
ps.add(r) |
22531
22ba2c0825da
revset: use `subset &` in `ancestorspec`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22530
diff
changeset
|
535 |
return subset & ps |
14070
305c97670d7a
revset: add ^ and ~ operators from parentrevspec extension
Kevin Gessner <kevin@kevingessner.com>
parents:
14061
diff
changeset
|
536 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
537 |
|
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
538 |
@predicate(b'author(string)', safe=True, weight=10) |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
539 |
def author(repo, subset, x): |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45750
diff
changeset
|
540 |
"""Alias for ``user(string)``.""" |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
541 |
# i18n: "author" is a keyword |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
542 |
n = getstring(x, _(b"author requires a string")) |
30782
db38cfc7c29d
revset: stop lowercasing the regex pattern for 'author'
Matt Harbison <matt_harbison@yahoo.com>
parents:
30772
diff
changeset
|
543 |
kind, pattern, matcher = _substringmatcher(n, casesensitive=False) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
544 |
return subset.filter( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
545 |
lambda x: matcher(repo[x].user()), condrepr=(b'<user %r>', n) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
546 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
547 |
|
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
548 |
|
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
549 |
@predicate(b'bisect(string)', safe=True) |
15134
81adf7777f8f
revset: rename bisected() to bisect()
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
15133
diff
changeset
|
550 |
def bisect(repo, subset, x): |
27584
fc7c8cac6a4b
revset: use decorator to register a function as revset predicate
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27517
diff
changeset
|
551 |
"""Changesets marked in the specified bisect status: |
15136
18219c0789ae
revset.bisect: add new 'range' set to the bisect keyword
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
15135
diff
changeset
|
552 |
|
15153
fa0a464e4ca5
hbisect: add two new revset descriptions: 'goods' and 'bads'
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
15147
diff
changeset
|
553 |
- ``good``, ``bad``, ``skip``: csets explicitly marked as good/bad/skip |
17424
e7cfe3587ea4
fix trivial spelling errors
Mads Kiilerich <mads@kiilerich.com>
parents:
17390
diff
changeset
|
554 |
- ``goods``, ``bads`` : csets topologically good/bad |
15153
fa0a464e4ca5
hbisect: add two new revset descriptions: 'goods' and 'bads'
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
15147
diff
changeset
|
555 |
- ``range`` : csets taking part in the bisection |
fa0a464e4ca5
hbisect: add two new revset descriptions: 'goods' and 'bads'
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
15147
diff
changeset
|
556 |
- ``pruned`` : csets that are goods, bads or skipped |
fa0a464e4ca5
hbisect: add two new revset descriptions: 'goods' and 'bads'
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
15147
diff
changeset
|
557 |
- ``untested`` : csets whose fate is yet unknown |
fa0a464e4ca5
hbisect: add two new revset descriptions: 'goods' and 'bads'
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
15147
diff
changeset
|
558 |
- ``ignored`` : csets ignored due to DAG topology |
16647
14913fcb30c6
bisect: track the current changeset (issue3382)
Bryan O'Sullivan <bryano@fb.com>
parents:
16640
diff
changeset
|
559 |
- ``current`` : the cset currently being bisected |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
560 |
""" |
17259
e96ad092fb18
i18n: add/relocate "i18n keyword" comments for i18n messages in revset.py
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
17258
diff
changeset
|
561 |
# i18n: "bisect" is a keyword |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
562 |
status = getstring(x, _(b"bisect requires a string")).lower() |
16467
7f59900e3f8b
revset: fix O(n**2) behaviour of bisect() (issue3381)
Bryan O'Sullivan <bryano@fb.com>
parents:
16453
diff
changeset
|
563 |
state = set(hbisect.get(repo, status)) |
22532
0cf46b8298fe
revset: use `subset &` in `bisect`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22531
diff
changeset
|
564 |
return subset & state |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
565 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
566 |
|
15134
81adf7777f8f
revset: rename bisected() to bisect()
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
15133
diff
changeset
|
567 |
# Backward-compatibility |
81adf7777f8f
revset: rename bisected() to bisect()
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
15133
diff
changeset
|
568 |
# - no help entry so that we do not advertise it any more |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
569 |
@predicate(b'bisected', safe=True) |
15134
81adf7777f8f
revset: rename bisected() to bisect()
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
15133
diff
changeset
|
570 |
def bisected(repo, subset, x): |
81adf7777f8f
revset: rename bisected() to bisect()
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
15133
diff
changeset
|
571 |
return bisect(repo, subset, x) |
81adf7777f8f
revset: rename bisected() to bisect()
"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
parents:
15133
diff
changeset
|
572 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
573 |
|
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
574 |
@predicate(b'bookmark([name])', safe=True) |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
575 |
def bookmark(repo, subset, x): |
27584
fc7c8cac6a4b
revset: use decorator to register a function as revset predicate
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27517
diff
changeset
|
576 |
"""The named bookmark or all bookmarks. |
16822
da55d8a77390
revset: add pattern matching to 'bookmarks' revset expression
Simon King <simon@simonking.org.uk>
parents:
16821
diff
changeset
|
577 |
|
30799
0b49449a01f4
help: use :hg: role and canonical name to point to revset string patterns
Yuya Nishihara <yuya@tcha.org>
parents:
30784
diff
changeset
|
578 |
Pattern matching is supported for `name`. See :hg:`help revisions.patterns`. |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
579 |
""" |
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
580 |
# i18n: "bookmark" is a keyword |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
581 |
args = getargs(x, 0, 1, _(b'bookmark takes one or no arguments')) |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
582 |
if args: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
583 |
bm = getstring( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
584 |
args[0], |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
585 |
# i18n: "bookmark" is a keyword |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
586 |
_(b'the argument to bookmark must be a string'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
587 |
) |
37084
f0b6fbea00cf
stringutil: bulk-replace call sites to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
37001
diff
changeset
|
588 |
kind, pattern, matcher = stringutil.stringmatcher(bm) |
22499
8c9f9e346acc
revset: unify code flow in `bookmark`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22498
diff
changeset
|
589 |
bms = set() |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
590 |
if kind == b'literal': |
39303
1eb370761fa0
revset: expand bookmark(.) to the active bookmark
Yuya Nishihara <yuya@tcha.org>
parents:
39274
diff
changeset
|
591 |
if bm == pattern: |
1eb370761fa0
revset: expand bookmark(.) to the active bookmark
Yuya Nishihara <yuya@tcha.org>
parents:
39274
diff
changeset
|
592 |
pattern = repo._bookmarks.expandname(pattern) |
22105
3efe3c2609e0
revset: bookmark revset interprets 'literal:' prefix correctly (issue4329)
Michael O'Connor <mkoconnor@gmail.com>
parents:
21939
diff
changeset
|
593 |
bmrev = repo._bookmarks.get(pattern, None) |
16822
da55d8a77390
revset: add pattern matching to 'bookmarks' revset expression
Simon King <simon@simonking.org.uk>
parents:
16821
diff
changeset
|
594 |
if not bmrev: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
595 |
raise error.RepoLookupError( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
596 |
_(b"bookmark '%s' does not exist") % pattern |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
597 |
) |
22499
8c9f9e346acc
revset: unify code flow in `bookmark`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22498
diff
changeset
|
598 |
bms.add(repo[bmrev].rev()) |
16822
da55d8a77390
revset: add pattern matching to 'bookmarks' revset expression
Simon King <simon@simonking.org.uk>
parents:
16821
diff
changeset
|
599 |
else: |
da55d8a77390
revset: add pattern matching to 'bookmarks' revset expression
Simon King <simon@simonking.org.uk>
parents:
16821
diff
changeset
|
600 |
matchrevs = set() |
48913
f254fc73d956
global: bulk replace simple pycompat.iteritems(x) with x.items()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
48875
diff
changeset
|
601 |
for name, bmrev in repo._bookmarks.items(): |
16822
da55d8a77390
revset: add pattern matching to 'bookmarks' revset expression
Simon King <simon@simonking.org.uk>
parents:
16821
diff
changeset
|
602 |
if matcher(name): |
da55d8a77390
revset: add pattern matching to 'bookmarks' revset expression
Simon King <simon@simonking.org.uk>
parents:
16821
diff
changeset
|
603 |
matchrevs.add(bmrev) |
da55d8a77390
revset: add pattern matching to 'bookmarks' revset expression
Simon King <simon@simonking.org.uk>
parents:
16821
diff
changeset
|
604 |
for bmrev in matchrevs: |
22499
8c9f9e346acc
revset: unify code flow in `bookmark`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22498
diff
changeset
|
605 |
bms.add(repo[bmrev].rev()) |
8c9f9e346acc
revset: unify code flow in `bookmark`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22498
diff
changeset
|
606 |
else: |
32291
bd872f64a8ba
cleanup: use set literals
Martin von Zweigbergk <martinvonz@google.com>
parents:
32085
diff
changeset
|
607 |
bms = {repo[r].rev() for r in repo._bookmarks.values()} |
46113
59fa3890d40a
node: import symbols explicitly
Joerg Sonnenberger <joerg@bec.de>
parents:
45942
diff
changeset
|
608 |
bms -= {nullrev} |
22530
faf4f63533ff
revset: use `subset &` in `bookmark`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22529
diff
changeset
|
609 |
return subset & bms |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
610 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
611 |
|
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
612 |
@predicate(b'branch(string or set)', safe=True, weight=10) |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
613 |
def branch(repo, subset, x): |
27584
fc7c8cac6a4b
revset: use decorator to register a function as revset predicate
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27517
diff
changeset
|
614 |
""" |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
615 |
All changesets belonging to the given branch or the branches of the given |
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
616 |
changesets. |
16821
0946502fd3d5
revset: add pattern matching to 'branch' revset expression
Simon King <simon@simonking.org.uk>
parents:
16820
diff
changeset
|
617 |
|
30784
5dd67f0993ce
help: eliminate duplicate text for revset string patterns
Matt Harbison <matt_harbison@yahoo.com>
parents:
30783
diff
changeset
|
618 |
Pattern matching is supported for `string`. See |
30799
0b49449a01f4
help: use :hg: role and canonical name to point to revset string patterns
Yuya Nishihara <yuya@tcha.org>
parents:
30784
diff
changeset
|
619 |
:hg:`help revisions.patterns`. |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
620 |
""" |
24374
77fd1fb538cd
revbranchcache: store repo on the object
Durham Goode <durham@fb.com>
parents:
24366
diff
changeset
|
621 |
getbi = repo.revbranchcache().branchinfo |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
622 |
|
32683
9f840d99054c
revset: add support for branch(wdir()) and wdir() & branch()
Yuya Nishihara <yuya@tcha.org>
parents:
32661
diff
changeset
|
623 |
def getbranch(r): |
9f840d99054c
revset: add support for branch(wdir()) and wdir() & branch()
Yuya Nishihara <yuya@tcha.org>
parents:
32661
diff
changeset
|
624 |
try: |
9f840d99054c
revset: add support for branch(wdir()) and wdir() & branch()
Yuya Nishihara <yuya@tcha.org>
parents:
32661
diff
changeset
|
625 |
return getbi(r)[0] |
9f840d99054c
revset: add support for branch(wdir()) and wdir() & branch()
Yuya Nishihara <yuya@tcha.org>
parents:
32661
diff
changeset
|
626 |
except error.WdirUnsupported: |
9f840d99054c
revset: add support for branch(wdir()) and wdir() & branch()
Yuya Nishihara <yuya@tcha.org>
parents:
32661
diff
changeset
|
627 |
return repo[r].branch() |
23787
678f53865c68
revset: use localrepo revbranchcache for branch name filtering
Mads Kiilerich <madski@unity3d.com>
parents:
23765
diff
changeset
|
628 |
|
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
629 |
try: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
630 |
b = getstring(x, b'') |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
631 |
except error.ParseError: |
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
632 |
# not a string, but another revspec, e.g. tip() |
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
633 |
pass |
16821
0946502fd3d5
revset: add pattern matching to 'branch' revset expression
Simon King <simon@simonking.org.uk>
parents:
16820
diff
changeset
|
634 |
else: |
37084
f0b6fbea00cf
stringutil: bulk-replace call sites to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
37001
diff
changeset
|
635 |
kind, pattern, matcher = stringutil.stringmatcher(b) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
636 |
if kind == b'literal': |
16821
0946502fd3d5
revset: add pattern matching to 'branch' revset expression
Simon King <simon@simonking.org.uk>
parents:
16820
diff
changeset
|
637 |
# note: falls through to the revspec case if no branch with |
26537
832feae7c986
revset: do not fall through to revspec for literal: branch (issue4838)
Yuya Nishihara <yuya@tcha.org>
parents:
26481
diff
changeset
|
638 |
# this name exists and pattern kind is not specified explicitly |
42004
0bd730fbcc2b
branchcache: introduce hasbranch()
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
42002
diff
changeset
|
639 |
if repo.branchmap().hasbranch(pattern): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
640 |
return subset.filter( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
641 |
lambda r: matcher(getbranch(r)), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
642 |
condrepr=(b'<branch %r>', b), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
643 |
) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
644 |
if b.startswith(b'literal:'): |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
645 |
raise error.RepoLookupError( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
646 |
_(b"branch '%s' does not exist") % pattern |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
647 |
) |
16821
0946502fd3d5
revset: add pattern matching to 'branch' revset expression
Simon King <simon@simonking.org.uk>
parents:
16820
diff
changeset
|
648 |
else: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
649 |
return subset.filter( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
650 |
lambda r: matcher(getbranch(r)), condrepr=(b'<branch %r>', b) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
651 |
) |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
652 |
|
24115
ff24af40728b
revset: specify fullreposet without using spanset factory
Yuya Nishihara <yuya@tcha.org>
parents:
24114
diff
changeset
|
653 |
s = getset(repo, fullreposet(repo), x) |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
654 |
b = set() |
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
655 |
for r in s: |
32683
9f840d99054c
revset: add support for branch(wdir()) and wdir() & branch()
Yuya Nishihara <yuya@tcha.org>
parents:
32661
diff
changeset
|
656 |
b.add(getbranch(r)) |
22867
5ee9b78ce805
revset-branch: remove usage of `set()`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22866
diff
changeset
|
657 |
c = s.__contains__ |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
658 |
return subset.filter( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
659 |
lambda r: c(r) or getbranch(r) in b, |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
660 |
condrepr=lambda: b'<branch %r>' % _sortedb(b), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
661 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
662 |
|
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
663 |
|
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
664 |
@predicate(b'phasedivergent()', safe=True) |
33776
ed99d3afef88
revset: rename bumped into phasedivergent
Boris Feld <boris.feld@octobus.net>
parents:
33775
diff
changeset
|
665 |
def phasedivergent(repo, subset, x): |
27584
fc7c8cac6a4b
revset: use decorator to register a function as revset predicate
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27517
diff
changeset
|
666 |
"""Mutable changesets marked as successors of public changesets. |
17829
c73f7a28953c
revset: add a bumped revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17825
diff
changeset
|
667 |
|
33776
ed99d3afef88
revset: rename bumped into phasedivergent
Boris Feld <boris.feld@octobus.net>
parents:
33775
diff
changeset
|
668 |
Only non-public and non-obsolete changesets can be `phasedivergent`. |
33855
457d1ebf151b
revset: mark evolution-related revsets as experimental
Boris Feld <boris.feld@octobus.net>
parents:
33779
diff
changeset
|
669 |
(EXPERIMENTAL) |
17829
c73f7a28953c
revset: add a bumped revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17825
diff
changeset
|
670 |
""" |
33776
ed99d3afef88
revset: rename bumped into phasedivergent
Boris Feld <boris.feld@octobus.net>
parents:
33775
diff
changeset
|
671 |
# i18n: "phasedivergent" is a keyword |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
672 |
getargs(x, 0, 0, _(b"phasedivergent takes no arguments")) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
673 |
phasedivergent = obsmod.getrevs(repo, b'phasedivergent') |
33779
9fa874fb34e1
obsolete: rename bumped volatile set into phasedivergent volatile set
Boris Feld <boris.feld@octobus.net>
parents:
33778
diff
changeset
|
674 |
return subset & phasedivergent |
17829
c73f7a28953c
revset: add a bumped revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17825
diff
changeset
|
675 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
676 |
|
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
677 |
@predicate(b'bundle()', safe=True) |
17913
03e552aaae67
bundle: add revset expression to show bundle contents (issue3487)
Tomasz Kleczek <tkleczek@fb.com>
parents:
17886
diff
changeset
|
678 |
def bundle(repo, subset, x): |
27584
fc7c8cac6a4b
revset: use decorator to register a function as revset predicate
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27517
diff
changeset
|
679 |
"""Changesets in the bundle. |
17913
03e552aaae67
bundle: add revset expression to show bundle contents (issue3487)
Tomasz Kleczek <tkleczek@fb.com>
parents:
17886
diff
changeset
|
680 |
|
03e552aaae67
bundle: add revset expression to show bundle contents (issue3487)
Tomasz Kleczek <tkleczek@fb.com>
parents:
17886
diff
changeset
|
681 |
Bundle must be specified by the -R option.""" |
03e552aaae67
bundle: add revset expression to show bundle contents (issue3487)
Tomasz Kleczek <tkleczek@fb.com>
parents:
17886
diff
changeset
|
682 |
|
03e552aaae67
bundle: add revset expression to show bundle contents (issue3487)
Tomasz Kleczek <tkleczek@fb.com>
parents:
17886
diff
changeset
|
683 |
try: |
18411
8b0f0dd56cec
bundlerepo: improve performance for bundle() revset expression
Mads Kiilerich <madski@unity3d.com>
parents:
18382
diff
changeset
|
684 |
bundlerevs = repo.changelog.bundlerevs |
17913
03e552aaae67
bundle: add revset expression to show bundle contents (issue3487)
Tomasz Kleczek <tkleczek@fb.com>
parents:
17886
diff
changeset
|
685 |
except AttributeError: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
686 |
raise error.Abort(_(b"no bundle provided - specify with -R")) |
20367
2ac278aab2b4
revset: added intersection to baseset class
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20366
diff
changeset
|
687 |
return subset & bundlerevs |
17913
03e552aaae67
bundle: add revset expression to show bundle contents (issue3487)
Tomasz Kleczek <tkleczek@fb.com>
parents:
17886
diff
changeset
|
688 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
689 |
|
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
690 |
def checkstatus(repo, subset, pat, field): |
42104
4b86f4f199a9
revset: short docstring for checkstatus
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
42039
diff
changeset
|
691 |
"""Helper for status-related revsets (adds, removes, modifies). |
45428
9b9071fabcd3
revset: remove indirect indexing of status tuple
Yuya Nishihara <yuya@tcha.org>
parents:
44856
diff
changeset
|
692 |
The field parameter says which kind is desired. |
42104
4b86f4f199a9
revset: short docstring for checkstatus
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents:
42039
diff
changeset
|
693 |
""" |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
694 |
hasset = matchmod.patkind(pat) == b'set' |
20457
ed7b674824a3
revset: added lazyset implementation to checkstatus
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20456
diff
changeset
|
695 |
|
23115
c23c03605c59
revset: don't recreate matcher for every revision
Martin von Zweigbergk <martinvonz@google.com>
parents:
23100
diff
changeset
|
696 |
mcache = [None] |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
697 |
|
20457
ed7b674824a3
revset: added lazyset implementation to checkstatus
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20456
diff
changeset
|
698 |
def matches(x): |
ed7b674824a3
revset: added lazyset implementation to checkstatus
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20456
diff
changeset
|
699 |
c = repo[x] |
23115
c23c03605c59
revset: don't recreate matcher for every revision
Martin von Zweigbergk <martinvonz@google.com>
parents:
23100
diff
changeset
|
700 |
if not mcache[0] or hasset: |
c23c03605c59
revset: don't recreate matcher for every revision
Martin von Zweigbergk <martinvonz@google.com>
parents:
23100
diff
changeset
|
701 |
mcache[0] = matchmod.match(repo.root, repo.getcwd(), [pat], ctx=c) |
c23c03605c59
revset: don't recreate matcher for every revision
Martin von Zweigbergk <martinvonz@google.com>
parents:
23100
diff
changeset
|
702 |
m = mcache[0] |
c23c03605c59
revset: don't recreate matcher for every revision
Martin von Zweigbergk <martinvonz@google.com>
parents:
23100
diff
changeset
|
703 |
fname = None |
43726
6c6d67fc45cb
revset: add an assertion to help pytype
Matt Harbison <matt_harbison@yahoo.com>
parents:
43650
diff
changeset
|
704 |
|
6c6d67fc45cb
revset: add an assertion to help pytype
Matt Harbison <matt_harbison@yahoo.com>
parents:
43650
diff
changeset
|
705 |
assert m is not None # help pytype |
23115
c23c03605c59
revset: don't recreate matcher for every revision
Martin von Zweigbergk <martinvonz@google.com>
parents:
23100
diff
changeset
|
706 |
if not m.anypats() and len(m.files()) == 1: |
c23c03605c59
revset: don't recreate matcher for every revision
Martin von Zweigbergk <martinvonz@google.com>
parents:
23100
diff
changeset
|
707 |
fname = m.files()[0] |
16521
592701c8eac6
revset: fix adds/modifies/removes and patterns (issue3403)
Patrick Mezard <patrick@mezard.eu>
parents:
16467
diff
changeset
|
708 |
if fname is not None: |
592701c8eac6
revset: fix adds/modifies/removes and patterns (issue3403)
Patrick Mezard <patrick@mezard.eu>
parents:
16467
diff
changeset
|
709 |
if fname not in c.files(): |
20457
ed7b674824a3
revset: added lazyset implementation to checkstatus
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20456
diff
changeset
|
710 |
return False |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
711 |
else: |
43592
61d7bca16dff
revset: simplify checkstatus() by using any()
Martin von Zweigbergk <martinvonz@google.com>
parents:
43561
diff
changeset
|
712 |
if not any(m(f) for f in c.files()): |
20457
ed7b674824a3
revset: added lazyset implementation to checkstatus
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20456
diff
changeset
|
713 |
return False |
45428
9b9071fabcd3
revset: remove indirect indexing of status tuple
Yuya Nishihara <yuya@tcha.org>
parents:
44856
diff
changeset
|
714 |
files = getattr(repo.status(c.p1().node(), c.node()), field) |
16521
592701c8eac6
revset: fix adds/modifies/removes and patterns (issue3403)
Patrick Mezard <patrick@mezard.eu>
parents:
16467
diff
changeset
|
715 |
if fname is not None: |
592701c8eac6
revset: fix adds/modifies/removes and patterns (issue3403)
Patrick Mezard <patrick@mezard.eu>
parents:
16467
diff
changeset
|
716 |
if fname in files: |
20457
ed7b674824a3
revset: added lazyset implementation to checkstatus
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20456
diff
changeset
|
717 |
return True |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
718 |
else: |
43592
61d7bca16dff
revset: simplify checkstatus() by using any()
Martin von Zweigbergk <martinvonz@google.com>
parents:
43561
diff
changeset
|
719 |
if any(m(f) for f in files): |
61d7bca16dff
revset: simplify checkstatus() by using any()
Martin von Zweigbergk <martinvonz@google.com>
parents:
43561
diff
changeset
|
720 |
return True |
20457
ed7b674824a3
revset: added lazyset implementation to checkstatus
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20456
diff
changeset
|
721 |
|
45428
9b9071fabcd3
revset: remove indirect indexing of status tuple
Yuya Nishihara <yuya@tcha.org>
parents:
44856
diff
changeset
|
722 |
return subset.filter( |
9b9071fabcd3
revset: remove indirect indexing of status tuple
Yuya Nishihara <yuya@tcha.org>
parents:
44856
diff
changeset
|
723 |
matches, condrepr=(b'<status.%s %r>', pycompat.sysbytes(field), pat) |
9b9071fabcd3
revset: remove indirect indexing of status tuple
Yuya Nishihara <yuya@tcha.org>
parents:
44856
diff
changeset
|
724 |
) |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
725 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
726 |
|
29406
c2193e59ef9f
revsets: passing a set to baseset() is not wrong
Martin von Zweigbergk <martinvonz@google.com>
parents:
29389
diff
changeset
|
727 |
def _children(repo, subset, parentset): |
25550
3e9049876ace
revset: gratuitous code move in '_children'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25549
diff
changeset
|
728 |
if not parentset: |
3e9049876ace
revset: gratuitous code move in '_children'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25549
diff
changeset
|
729 |
return baseset() |
15899
476a981fdf34
revset: optimize roots and children
Matt Mackall <mpm@selenic.com>
parents:
15898
diff
changeset
|
730 |
cs = set() |
476a981fdf34
revset: optimize roots and children
Matt Mackall <mpm@selenic.com>
parents:
15898
diff
changeset
|
731 |
pr = repo.changelog.parentrevs |
25567
f140d6207cca
revset: use parentsets.min in _children
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25566
diff
changeset
|
732 |
minrev = parentset.min() |
29406
c2193e59ef9f
revsets: passing a set to baseset() is not wrong
Martin von Zweigbergk <martinvonz@google.com>
parents:
29389
diff
changeset
|
733 |
for r in subset: |
18063
34a1a639d835
revset.children: ignore rev numbers that are too low
Siddharth Agarwal <sid0@fb.com>
parents:
17980
diff
changeset
|
734 |
if r <= minrev: |
34a1a639d835
revset.children: ignore rev numbers that are too low
Siddharth Agarwal <sid0@fb.com>
parents:
17980
diff
changeset
|
735 |
continue |
30699
5bda147c3139
revset: make children() not look at p2 if null (issue5439)
Yuya Nishihara <yuya@tcha.org>
parents:
30392
diff
changeset
|
736 |
p1, p2 = pr(r) |
5bda147c3139
revset: make children() not look at p2 if null (issue5439)
Yuya Nishihara <yuya@tcha.org>
parents:
30392
diff
changeset
|
737 |
if p1 in parentset: |
5bda147c3139
revset: make children() not look at p2 if null (issue5439)
Yuya Nishihara <yuya@tcha.org>
parents:
30392
diff
changeset
|
738 |
cs.add(r) |
5bda147c3139
revset: make children() not look at p2 if null (issue5439)
Yuya Nishihara <yuya@tcha.org>
parents:
30392
diff
changeset
|
739 |
if p2 != nullrev and p2 in parentset: |
5bda147c3139
revset: make children() not look at p2 if null (issue5439)
Yuya Nishihara <yuya@tcha.org>
parents:
30392
diff
changeset
|
740 |
cs.add(r) |
20709
71df845d86cf
revsets: backout d04aac468bf4 due to performance regressions
Matt Mackall <mpm@selenic.com>
parents:
20708
diff
changeset
|
741 |
return baseset(cs) |
15899
476a981fdf34
revset: optimize roots and children
Matt Mackall <mpm@selenic.com>
parents:
15898
diff
changeset
|
742 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
743 |
|
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
744 |
@predicate(b'children(set)', safe=True) |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
745 |
def children(repo, subset, x): |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45750
diff
changeset
|
746 |
"""Child changesets of changesets in set.""" |
23164
7a42e5d4c418
revset-children: call 'getset' on a 'fullreposet'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23163
diff
changeset
|
747 |
s = getset(repo, fullreposet(repo), x) |
15899
476a981fdf34
revset: optimize roots and children
Matt Mackall <mpm@selenic.com>
parents:
15898
diff
changeset
|
748 |
cs = _children(repo, subset, s) |
20367
2ac278aab2b4
revset: added intersection to baseset class
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20366
diff
changeset
|
749 |
return subset & cs |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
750 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
751 |
|
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
752 |
@predicate(b'closed()', safe=True, weight=10) |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
753 |
def closed(repo, subset, x): |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45750
diff
changeset
|
754 |
"""Changeset is closed.""" |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
755 |
# i18n: "closed" is a keyword |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
756 |
getargs(x, 0, 0, _(b"closed takes no arguments")) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
757 |
return subset.filter( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
758 |
lambda r: repo[r].closesbranch(), condrepr=b'<branch closed>' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
759 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
760 |
|
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
761 |
|
38625
52f19a840543
revset: add optimization for heads(commonancestors())
Sean Farley <sean@farley.io>
parents:
38624
diff
changeset
|
762 |
# for internal use |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
763 |
@predicate(b'_commonancestorheads(set)', safe=True) |
38625
52f19a840543
revset: add optimization for heads(commonancestors())
Sean Farley <sean@farley.io>
parents:
38624
diff
changeset
|
764 |
def _commonancestorheads(repo, subset, x): |
52f19a840543
revset: add optimization for heads(commonancestors())
Sean Farley <sean@farley.io>
parents:
38624
diff
changeset
|
765 |
# This is an internal method is for quickly calculating "heads(::x and |
52f19a840543
revset: add optimization for heads(commonancestors())
Sean Farley <sean@farley.io>
parents:
38624
diff
changeset
|
766 |
# ::y)" |
52f19a840543
revset: add optimization for heads(commonancestors())
Sean Farley <sean@farley.io>
parents:
38624
diff
changeset
|
767 |
|
39805
823f34acfd46
revset: make heads(commonancestors(x + x^)) be x^, not x
Valentin Gatien-Baron <vgatien-baron@janestreet.com>
parents:
39803
diff
changeset
|
768 |
# These greatest common ancestors are the same ones that the consensus bid |
38625
52f19a840543
revset: add optimization for heads(commonancestors())
Sean Farley <sean@farley.io>
parents:
38624
diff
changeset
|
769 |
# merge will find. |
39805
823f34acfd46
revset: make heads(commonancestors(x + x^)) be x^, not x
Valentin Gatien-Baron <vgatien-baron@janestreet.com>
parents:
39803
diff
changeset
|
770 |
startrevs = getset(repo, fullreposet(repo), x, order=anyorder) |
38625
52f19a840543
revset: add optimization for heads(commonancestors())
Sean Farley <sean@farley.io>
parents:
38624
diff
changeset
|
771 |
|
39805
823f34acfd46
revset: make heads(commonancestors(x + x^)) be x^, not x
Valentin Gatien-Baron <vgatien-baron@janestreet.com>
parents:
39803
diff
changeset
|
772 |
ancs = repo.changelog._commonancestorsheads(*list(startrevs)) |
38625
52f19a840543
revset: add optimization for heads(commonancestors())
Sean Farley <sean@farley.io>
parents:
38624
diff
changeset
|
773 |
return subset & baseset(ancs) |
52f19a840543
revset: add optimization for heads(commonancestors())
Sean Farley <sean@farley.io>
parents:
38624
diff
changeset
|
774 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
775 |
|
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
776 |
@predicate(b'commonancestors(set)', safe=True) |
38624
5460926352ee
revsets: add commonancestors revset
Sean Farley <sean@farley.io>
parents:
38588
diff
changeset
|
777 |
def commonancestors(repo, subset, x): |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45750
diff
changeset
|
778 |
"""Changesets that are ancestors of every changeset in set.""" |
39801
cb5134f2318a
revset: make commonancestors(x + x^) be ::(x^), not ::x
Valentin Gatien-Baron <vgatien-baron@janestreet.com>
parents:
38705
diff
changeset
|
779 |
startrevs = getset(repo, fullreposet(repo), x, order=anyorder) |
cb5134f2318a
revset: make commonancestors(x + x^) be ::(x^), not ::x
Valentin Gatien-Baron <vgatien-baron@janestreet.com>
parents:
38705
diff
changeset
|
780 |
if not startrevs: |
38705
e4b270a32ba8
revset: special case commonancestors(none()) to be empty set
Yuya Nishihara <yuya@tcha.org>
parents:
38704
diff
changeset
|
781 |
return baseset() |
39801
cb5134f2318a
revset: make commonancestors(x + x^) be ::(x^), not ::x
Valentin Gatien-Baron <vgatien-baron@janestreet.com>
parents:
38705
diff
changeset
|
782 |
for r in startrevs: |
38624
5460926352ee
revsets: add commonancestors revset
Sean Farley <sean@farley.io>
parents:
38588
diff
changeset
|
783 |
subset &= dagop.revancestors(repo, baseset([r])) |
5460926352ee
revsets: add commonancestors revset
Sean Farley <sean@farley.io>
parents:
38588
diff
changeset
|
784 |
return subset |
5460926352ee
revsets: add commonancestors revset
Sean Farley <sean@farley.io>
parents:
38588
diff
changeset
|
785 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
786 |
|
44343
8561ad49915d
revset: add a revset for parents in merge state
Martin von Zweigbergk <martinvonz@google.com>
parents:
43997
diff
changeset
|
787 |
@predicate(b'conflictlocal()', safe=True) |
8561ad49915d
revset: add a revset for parents in merge state
Martin von Zweigbergk <martinvonz@google.com>
parents:
43997
diff
changeset
|
788 |
def conflictlocal(repo, subset, x): |
8561ad49915d
revset: add a revset for parents in merge state
Martin von Zweigbergk <martinvonz@google.com>
parents:
43997
diff
changeset
|
789 |
"""The local side of the merge, if currently in an unresolved merge. |
8561ad49915d
revset: add a revset for parents in merge state
Martin von Zweigbergk <martinvonz@google.com>
parents:
43997
diff
changeset
|
790 |
|
8561ad49915d
revset: add a revset for parents in merge state
Martin von Zweigbergk <martinvonz@google.com>
parents:
43997
diff
changeset
|
791 |
"merge" here includes merge conflicts from e.g. 'hg rebase' or 'hg graft'. |
8561ad49915d
revset: add a revset for parents in merge state
Martin von Zweigbergk <martinvonz@google.com>
parents:
43997
diff
changeset
|
792 |
""" |
8561ad49915d
revset: add a revset for parents in merge state
Martin von Zweigbergk <martinvonz@google.com>
parents:
43997
diff
changeset
|
793 |
getargs(x, 0, 0, _(b"conflictlocal takes no arguments")) |
44856
b7808443ed6a
mergestate: split out merge state handling code from main merge module
Augie Fackler <augie@google.com>
parents:
44711
diff
changeset
|
794 |
from . import mergestate as mergestatemod |
b7808443ed6a
mergestate: split out merge state handling code from main merge module
Augie Fackler <augie@google.com>
parents:
44711
diff
changeset
|
795 |
|
b7808443ed6a
mergestate: split out merge state handling code from main merge module
Augie Fackler <augie@google.com>
parents:
44711
diff
changeset
|
796 |
mergestate = mergestatemod.mergestate.read(repo) |
44343
8561ad49915d
revset: add a revset for parents in merge state
Martin von Zweigbergk <martinvonz@google.com>
parents:
43997
diff
changeset
|
797 |
if mergestate.active() and repo.changelog.hasnode(mergestate.local): |
8561ad49915d
revset: add a revset for parents in merge state
Martin von Zweigbergk <martinvonz@google.com>
parents:
43997
diff
changeset
|
798 |
return subset & {repo.changelog.rev(mergestate.local)} |
8561ad49915d
revset: add a revset for parents in merge state
Martin von Zweigbergk <martinvonz@google.com>
parents:
43997
diff
changeset
|
799 |
|
8561ad49915d
revset: add a revset for parents in merge state
Martin von Zweigbergk <martinvonz@google.com>
parents:
43997
diff
changeset
|
800 |
return baseset() |
8561ad49915d
revset: add a revset for parents in merge state
Martin von Zweigbergk <martinvonz@google.com>
parents:
43997
diff
changeset
|
801 |
|
8561ad49915d
revset: add a revset for parents in merge state
Martin von Zweigbergk <martinvonz@google.com>
parents:
43997
diff
changeset
|
802 |
|
8561ad49915d
revset: add a revset for parents in merge state
Martin von Zweigbergk <martinvonz@google.com>
parents:
43997
diff
changeset
|
803 |
@predicate(b'conflictother()', safe=True) |
8561ad49915d
revset: add a revset for parents in merge state
Martin von Zweigbergk <martinvonz@google.com>
parents:
43997
diff
changeset
|
804 |
def conflictother(repo, subset, x): |
8561ad49915d
revset: add a revset for parents in merge state
Martin von Zweigbergk <martinvonz@google.com>
parents:
43997
diff
changeset
|
805 |
"""The other side of the merge, if currently in an unresolved merge. |
8561ad49915d
revset: add a revset for parents in merge state
Martin von Zweigbergk <martinvonz@google.com>
parents:
43997
diff
changeset
|
806 |
|
8561ad49915d
revset: add a revset for parents in merge state
Martin von Zweigbergk <martinvonz@google.com>
parents:
43997
diff
changeset
|
807 |
"merge" here includes merge conflicts from e.g. 'hg rebase' or 'hg graft'. |
8561ad49915d
revset: add a revset for parents in merge state
Martin von Zweigbergk <martinvonz@google.com>
parents:
43997
diff
changeset
|
808 |
""" |
8561ad49915d
revset: add a revset for parents in merge state
Martin von Zweigbergk <martinvonz@google.com>
parents:
43997
diff
changeset
|
809 |
getargs(x, 0, 0, _(b"conflictother takes no arguments")) |
44856
b7808443ed6a
mergestate: split out merge state handling code from main merge module
Augie Fackler <augie@google.com>
parents:
44711
diff
changeset
|
810 |
from . import mergestate as mergestatemod |
b7808443ed6a
mergestate: split out merge state handling code from main merge module
Augie Fackler <augie@google.com>
parents:
44711
diff
changeset
|
811 |
|
b7808443ed6a
mergestate: split out merge state handling code from main merge module
Augie Fackler <augie@google.com>
parents:
44711
diff
changeset
|
812 |
mergestate = mergestatemod.mergestate.read(repo) |
44343
8561ad49915d
revset: add a revset for parents in merge state
Martin von Zweigbergk <martinvonz@google.com>
parents:
43997
diff
changeset
|
813 |
if mergestate.active() and repo.changelog.hasnode(mergestate.other): |
8561ad49915d
revset: add a revset for parents in merge state
Martin von Zweigbergk <martinvonz@google.com>
parents:
43997
diff
changeset
|
814 |
return subset & {repo.changelog.rev(mergestate.other)} |
8561ad49915d
revset: add a revset for parents in merge state
Martin von Zweigbergk <martinvonz@google.com>
parents:
43997
diff
changeset
|
815 |
|
8561ad49915d
revset: add a revset for parents in merge state
Martin von Zweigbergk <martinvonz@google.com>
parents:
43997
diff
changeset
|
816 |
return baseset() |
8561ad49915d
revset: add a revset for parents in merge state
Martin von Zweigbergk <martinvonz@google.com>
parents:
43997
diff
changeset
|
817 |
|
8561ad49915d
revset: add a revset for parents in merge state
Martin von Zweigbergk <martinvonz@google.com>
parents:
43997
diff
changeset
|
818 |
|
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
819 |
@predicate(b'contains(pattern)', weight=100) |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
820 |
def contains(repo, subset, x): |
27584
fc7c8cac6a4b
revset: use decorator to register a function as revset predicate
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27517
diff
changeset
|
821 |
"""The revision's manifest contains a file matching pattern (but might not |
21199
e9c2f76be74b
help: clarify distinction among `contains`/`file`/`filelog`
Greg Hurrell <glh@fb.com>
parents:
21173
diff
changeset
|
822 |
modify it). See :hg:`help patterns` for information about file patterns. |
20289
96be25f1da45
revset: add explanation about the pattern without explicit kind
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20288
diff
changeset
|
823 |
|
96be25f1da45
revset: add explanation about the pattern without explicit kind
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20288
diff
changeset
|
824 |
The pattern without explicit kind like ``glob:`` is expected to be |
96be25f1da45
revset: add explanation about the pattern without explicit kind
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20288
diff
changeset
|
825 |
relative to the current directory and match against a file exactly |
96be25f1da45
revset: add explanation about the pattern without explicit kind
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20288
diff
changeset
|
826 |
for efficiency. |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
827 |
""" |
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
828 |
# i18n: "contains" is a keyword |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
829 |
pat = getstring(x, _(b"contains requires a pattern")) |
20461
abd8e56a1038
revset: added lazyset implementation to contains revset
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20460
diff
changeset
|
830 |
|
abd8e56a1038
revset: added lazyset implementation to contains revset
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20460
diff
changeset
|
831 |
def matches(x): |
abd8e56a1038
revset: added lazyset implementation to contains revset
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20460
diff
changeset
|
832 |
if not matchmod.patkind(pat): |
abd8e56a1038
revset: added lazyset implementation to contains revset
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20460
diff
changeset
|
833 |
pats = pathutil.canonpath(repo.root, repo.getcwd(), pat) |
abd8e56a1038
revset: added lazyset implementation to contains revset
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20460
diff
changeset
|
834 |
if pats in repo[x]: |
abd8e56a1038
revset: added lazyset implementation to contains revset
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20460
diff
changeset
|
835 |
return True |
abd8e56a1038
revset: added lazyset implementation to contains revset
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20460
diff
changeset
|
836 |
else: |
abd8e56a1038
revset: added lazyset implementation to contains revset
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20460
diff
changeset
|
837 |
c = repo[x] |
abd8e56a1038
revset: added lazyset implementation to contains revset
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20460
diff
changeset
|
838 |
m = matchmod.match(repo.root, repo.getcwd(), [pat], ctx=c) |
15964
6e37b8282aa2
revsets: provide contexts for filesets
Matt Mackall <mpm@selenic.com>
parents:
15949
diff
changeset
|
839 |
for f in c.manifest(): |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
840 |
if m(f): |
20461
abd8e56a1038
revset: added lazyset implementation to contains revset
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20460
diff
changeset
|
841 |
return True |
abd8e56a1038
revset: added lazyset implementation to contains revset
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20460
diff
changeset
|
842 |
return False |
abd8e56a1038
revset: added lazyset implementation to contains revset
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20460
diff
changeset
|
843 |
|
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
844 |
return subset.filter(matches, condrepr=(b'<contains %r>', pat)) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
845 |
|
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
846 |
|
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
847 |
@predicate(b'converted([id])', safe=True) |
17002
0eb522625eb2
revset: add a predicate for finding converted changesets
Matt Harbison <matt_harbison@yahoo.com>
parents:
16862
diff
changeset
|
848 |
def converted(repo, subset, x): |
27584
fc7c8cac6a4b
revset: use decorator to register a function as revset predicate
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27517
diff
changeset
|
849 |
"""Changesets converted from the given identifier in the old repository if |
17002
0eb522625eb2
revset: add a predicate for finding converted changesets
Matt Harbison <matt_harbison@yahoo.com>
parents:
16862
diff
changeset
|
850 |
present, or all converted changesets if no identifier is specified. |
0eb522625eb2
revset: add a predicate for finding converted changesets
Matt Harbison <matt_harbison@yahoo.com>
parents:
16862
diff
changeset
|
851 |
""" |
0eb522625eb2
revset: add a predicate for finding converted changesets
Matt Harbison <matt_harbison@yahoo.com>
parents:
16862
diff
changeset
|
852 |
|
0eb522625eb2
revset: add a predicate for finding converted changesets
Matt Harbison <matt_harbison@yahoo.com>
parents:
16862
diff
changeset
|
853 |
# There is exactly no chance of resolving the revision, so do a simple |
0eb522625eb2
revset: add a predicate for finding converted changesets
Matt Harbison <matt_harbison@yahoo.com>
parents:
16862
diff
changeset
|
854 |
# string compare and hope for the best |
0eb522625eb2
revset: add a predicate for finding converted changesets
Matt Harbison <matt_harbison@yahoo.com>
parents:
16862
diff
changeset
|
855 |
|
17259
e96ad092fb18
i18n: add/relocate "i18n keyword" comments for i18n messages in revset.py
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
17258
diff
changeset
|
856 |
rev = None |
17002
0eb522625eb2
revset: add a predicate for finding converted changesets
Matt Harbison <matt_harbison@yahoo.com>
parents:
16862
diff
changeset
|
857 |
# i18n: "converted" is a keyword |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
858 |
l = getargs(x, 0, 1, _(b'converted takes one or no arguments')) |
17002
0eb522625eb2
revset: add a predicate for finding converted changesets
Matt Harbison <matt_harbison@yahoo.com>
parents:
16862
diff
changeset
|
859 |
if l: |
17259
e96ad092fb18
i18n: add/relocate "i18n keyword" comments for i18n messages in revset.py
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
17258
diff
changeset
|
860 |
# i18n: "converted" is a keyword |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
861 |
rev = getstring(l[0], _(b'converted requires a revision')) |
17002
0eb522625eb2
revset: add a predicate for finding converted changesets
Matt Harbison <matt_harbison@yahoo.com>
parents:
16862
diff
changeset
|
862 |
|
0eb522625eb2
revset: add a predicate for finding converted changesets
Matt Harbison <matt_harbison@yahoo.com>
parents:
16862
diff
changeset
|
863 |
def _matchvalue(r): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
864 |
source = repo[r].extra().get(b'convert_revision', None) |
17002
0eb522625eb2
revset: add a predicate for finding converted changesets
Matt Harbison <matt_harbison@yahoo.com>
parents:
16862
diff
changeset
|
865 |
return source is not None and (rev is None or source.startswith(rev)) |
0eb522625eb2
revset: add a predicate for finding converted changesets
Matt Harbison <matt_harbison@yahoo.com>
parents:
16862
diff
changeset
|
866 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
867 |
return subset.filter( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
868 |
lambda r: _matchvalue(r), condrepr=(b'<converted %r>', rev) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
869 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
870 |
|
17002
0eb522625eb2
revset: add a predicate for finding converted changesets
Matt Harbison <matt_harbison@yahoo.com>
parents:
16862
diff
changeset
|
871 |
|
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
872 |
@predicate(b'date(interval)', safe=True, weight=10) |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
873 |
def date(repo, subset, x): |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45750
diff
changeset
|
874 |
"""Changesets within the interval, see :hg:`help dates`.""" |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
875 |
# i18n: "date" is a keyword |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
876 |
ds = getstring(x, _(b"date requires a string")) |
36607
c6061cadb400
util: extract all date-related utils in utils/dateutil module
Boris Feld <boris.feld@octobus.net>
parents:
36581
diff
changeset
|
877 |
dm = dateutil.matchdate(ds) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
878 |
return subset.filter( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
879 |
lambda x: dm(repo[x].date()[0]), condrepr=(b'<date %r>', ds) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
880 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
881 |
|
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
882 |
|
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
883 |
@predicate(b'desc(string)', safe=True, weight=10) |
14650
93731b3efd0d
revset: add desc(string) to search in commit messages
Thomas Arendsen Hein <thomas@intevation.de>
parents:
14649
diff
changeset
|
884 |
def desc(repo, subset, x): |
27584
fc7c8cac6a4b
revset: use decorator to register a function as revset predicate
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27517
diff
changeset
|
885 |
"""Search commit message for string. The match is case-insensitive. |
30783
931a60880df4
revset: add regular expression support to 'desc'
Matt Harbison <matt_harbison@yahoo.com>
parents:
30782
diff
changeset
|
886 |
|
30784
5dd67f0993ce
help: eliminate duplicate text for revset string patterns
Matt Harbison <matt_harbison@yahoo.com>
parents:
30783
diff
changeset
|
887 |
Pattern matching is supported for `string`. See |
30799
0b49449a01f4
help: use :hg: role and canonical name to point to revset string patterns
Yuya Nishihara <yuya@tcha.org>
parents:
30784
diff
changeset
|
888 |
:hg:`help revisions.patterns`. |
14650
93731b3efd0d
revset: add desc(string) to search in commit messages
Thomas Arendsen Hein <thomas@intevation.de>
parents:
14649
diff
changeset
|
889 |
""" |
93731b3efd0d
revset: add desc(string) to search in commit messages
Thomas Arendsen Hein <thomas@intevation.de>
parents:
14649
diff
changeset
|
890 |
# i18n: "desc" is a keyword |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
891 |
ds = getstring(x, _(b"desc requires a string")) |
30783
931a60880df4
revset: add regular expression support to 'desc'
Matt Harbison <matt_harbison@yahoo.com>
parents:
30782
diff
changeset
|
892 |
|
931a60880df4
revset: add regular expression support to 'desc'
Matt Harbison <matt_harbison@yahoo.com>
parents:
30782
diff
changeset
|
893 |
kind, pattern, matcher = _substringmatcher(ds, casesensitive=False) |
931a60880df4
revset: add regular expression support to 'desc'
Matt Harbison <matt_harbison@yahoo.com>
parents:
30782
diff
changeset
|
894 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
895 |
return subset.filter( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
896 |
lambda r: matcher(repo[r].description()), condrepr=(b'<desc %r>', ds) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
897 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
898 |
|
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
899 |
|
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
900 |
def _descendants( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
901 |
repo, subset, x, followfirst=False, startdepth=None, stopdepth=None |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
902 |
): |
24115
ff24af40728b
revset: specify fullreposet without using spanset factory
Yuya Nishihara <yuya@tcha.org>
parents:
24114
diff
changeset
|
903 |
roots = getset(repo, fullreposet(repo), x) |
22944
5aae3dea8044
revset: better naming of variables containing the value of a single argument
Mads Kiilerich <madski@unity3d.com>
parents:
22891
diff
changeset
|
904 |
if not roots: |
22802
1fcd361efaf4
baseset: use default value instead of [] when possible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22801
diff
changeset
|
905 |
return baseset() |
33080
a53bfc2845f2
revset: add depth limit to descendants() (issue5374)
Yuya Nishihara <yuya@tcha.org>
parents:
33075
diff
changeset
|
906 |
s = dagop.revdescendants(repo, roots, followfirst, startdepth, stopdepth) |
33075
d83b189aef83
dagop: change revdescendants() to include all root revisions
Yuya Nishihara <yuya@tcha.org>
parents:
33003
diff
changeset
|
907 |
return subset & s |
16409
2cbd7dd0cc1f
graphlog: fix --follow-first --rev combinations
Patrick Mezard <patrick@mezard.eu>
parents:
16402
diff
changeset
|
908 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
909 |
|
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
910 |
@predicate(b'descendants(set[, depth])', safe=True) |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
911 |
def descendants(repo, subset, x): |
32905
2851b24eecc4
help: clarify ancestors() and descendants() include given set (issue5594)
Yuya Nishihara <yuya@tcha.org>
parents:
32904
diff
changeset
|
912 |
"""Changesets which are descendants of changesets in set, including the |
2851b24eecc4
help: clarify ancestors() and descendants() include given set (issue5594)
Yuya Nishihara <yuya@tcha.org>
parents:
32904
diff
changeset
|
913 |
given changesets themselves. |
33080
a53bfc2845f2
revset: add depth limit to descendants() (issue5374)
Yuya Nishihara <yuya@tcha.org>
parents:
33075
diff
changeset
|
914 |
|
a53bfc2845f2
revset: add depth limit to descendants() (issue5374)
Yuya Nishihara <yuya@tcha.org>
parents:
33075
diff
changeset
|
915 |
If depth is specified, the result only includes changesets up to |
a53bfc2845f2
revset: add depth limit to descendants() (issue5374)
Yuya Nishihara <yuya@tcha.org>
parents:
33075
diff
changeset
|
916 |
the specified generation. |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
917 |
""" |
33080
a53bfc2845f2
revset: add depth limit to descendants() (issue5374)
Yuya Nishihara <yuya@tcha.org>
parents:
33075
diff
changeset
|
918 |
# startdepth is for internal use only until we can decide the UI |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
919 |
args = getargsdict(x, b'descendants', b'set depth startdepth') |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
920 |
if b'set' not in args: |
32914
577759ef2ed2
revset: add support of keyword arguments to ancestors() and descendants()
Yuya Nishihara <yuya@tcha.org>
parents:
32905
diff
changeset
|
921 |
# i18n: "descendants" is a keyword |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
922 |
raise error.ParseError(_(b'descendants takes at least 1 argument')) |
33080
a53bfc2845f2
revset: add depth limit to descendants() (issue5374)
Yuya Nishihara <yuya@tcha.org>
parents:
33075
diff
changeset
|
923 |
startdepth = stopdepth = None |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
924 |
if b'startdepth' in args: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
925 |
n = getinteger( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
926 |
args[b'startdepth'], b"descendants expects an integer startdepth" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
927 |
) |
33080
a53bfc2845f2
revset: add depth limit to descendants() (issue5374)
Yuya Nishihara <yuya@tcha.org>
parents:
33075
diff
changeset
|
928 |
if n < 0: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
929 |
raise error.ParseError(b"negative startdepth") |
33080
a53bfc2845f2
revset: add depth limit to descendants() (issue5374)
Yuya Nishihara <yuya@tcha.org>
parents:
33075
diff
changeset
|
930 |
startdepth = n |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
931 |
if b'depth' in args: |
33080
a53bfc2845f2
revset: add depth limit to descendants() (issue5374)
Yuya Nishihara <yuya@tcha.org>
parents:
33075
diff
changeset
|
932 |
# i18n: "descendants" is a keyword |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
933 |
n = getinteger( |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
934 |
args[b'depth'], _(b"descendants expects an integer depth") |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
935 |
) |
33080
a53bfc2845f2
revset: add depth limit to descendants() (issue5374)
Yuya Nishihara <yuya@tcha.org>
parents:
33075
diff
changeset
|
936 |
if n < 0: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
937 |
raise error.ParseError(_(b"negative depth")) |
33080
a53bfc2845f2
revset: add depth limit to descendants() (issue5374)
Yuya Nishihara <yuya@tcha.org>
parents:
33075
diff
changeset
|
938 |
stopdepth = n + 1 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
939 |
return _descendants( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
940 |
repo, subset, args[b'set'], startdepth=startdepth, stopdepth=stopdepth |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
941 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
942 |
|
16409
2cbd7dd0cc1f
graphlog: fix --follow-first --rev combinations
Patrick Mezard <patrick@mezard.eu>
parents:
16402
diff
changeset
|
943 |
|
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
944 |
@predicate(b'_firstdescendants', safe=True) |
16409
2cbd7dd0cc1f
graphlog: fix --follow-first --rev combinations
Patrick Mezard <patrick@mezard.eu>
parents:
16402
diff
changeset
|
945 |
def _firstdescendants(repo, subset, x): |
2cbd7dd0cc1f
graphlog: fix --follow-first --rev combinations
Patrick Mezard <patrick@mezard.eu>
parents:
16402
diff
changeset
|
946 |
# ``_firstdescendants(set)`` |
2cbd7dd0cc1f
graphlog: fix --follow-first --rev combinations
Patrick Mezard <patrick@mezard.eu>
parents:
16402
diff
changeset
|
947 |
# Like ``descendants(set)`` but follows only the first parents. |
2cbd7dd0cc1f
graphlog: fix --follow-first --rev combinations
Patrick Mezard <patrick@mezard.eu>
parents:
16402
diff
changeset
|
948 |
return _descendants(repo, subset, x, followfirst=True) |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
949 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
950 |
|
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
951 |
@predicate(b'destination([set])', safe=True, weight=10) |
17186
a3da6f298592
revset: add destination() predicate
Matt Harbison <matt_harbison@yahoo.com>
parents:
17185
diff
changeset
|
952 |
def destination(repo, subset, x): |
27584
fc7c8cac6a4b
revset: use decorator to register a function as revset predicate
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27517
diff
changeset
|
953 |
"""Changesets that were created by a graft, transplant or rebase operation, |
17186
a3da6f298592
revset: add destination() predicate
Matt Harbison <matt_harbison@yahoo.com>
parents:
17185
diff
changeset
|
954 |
with the given revisions specified as the source. Omitting the optional set |
a3da6f298592
revset: add destination() predicate
Matt Harbison <matt_harbison@yahoo.com>
parents:
17185
diff
changeset
|
955 |
is the same as passing all(). |
a3da6f298592
revset: add destination() predicate
Matt Harbison <matt_harbison@yahoo.com>
parents:
17185
diff
changeset
|
956 |
""" |
a3da6f298592
revset: add destination() predicate
Matt Harbison <matt_harbison@yahoo.com>
parents:
17185
diff
changeset
|
957 |
if x is not None: |
24115
ff24af40728b
revset: specify fullreposet without using spanset factory
Yuya Nishihara <yuya@tcha.org>
parents:
24114
diff
changeset
|
958 |
sources = getset(repo, fullreposet(repo), x) |
17186
a3da6f298592
revset: add destination() predicate
Matt Harbison <matt_harbison@yahoo.com>
parents:
17185
diff
changeset
|
959 |
else: |
24201
77ef059b3317
revset: drop unnecessary calls of getall() with empty argument
Yuya Nishihara <yuya@tcha.org>
parents:
24163
diff
changeset
|
960 |
sources = fullreposet(repo) |
17186
a3da6f298592
revset: add destination() predicate
Matt Harbison <matt_harbison@yahoo.com>
parents:
17185
diff
changeset
|
961 |
|
a3da6f298592
revset: add destination() predicate
Matt Harbison <matt_harbison@yahoo.com>
parents:
17185
diff
changeset
|
962 |
dests = set() |
a3da6f298592
revset: add destination() predicate
Matt Harbison <matt_harbison@yahoo.com>
parents:
17185
diff
changeset
|
963 |
|
a3da6f298592
revset: add destination() predicate
Matt Harbison <matt_harbison@yahoo.com>
parents:
17185
diff
changeset
|
964 |
# subset contains all of the possible destinations that can be returned, so |
22944
5aae3dea8044
revset: better naming of variables containing the value of a single argument
Mads Kiilerich <madski@unity3d.com>
parents:
22891
diff
changeset
|
965 |
# iterate over them and see if their source(s) were provided in the arg set. |
5aae3dea8044
revset: better naming of variables containing the value of a single argument
Mads Kiilerich <madski@unity3d.com>
parents:
22891
diff
changeset
|
966 |
# Even if the immediate src of r is not in the arg set, src's source (or |
17186
a3da6f298592
revset: add destination() predicate
Matt Harbison <matt_harbison@yahoo.com>
parents:
17185
diff
changeset
|
967 |
# further back) may be. Scanning back further than the immediate src allows |
a3da6f298592
revset: add destination() predicate
Matt Harbison <matt_harbison@yahoo.com>
parents:
17185
diff
changeset
|
968 |
# transitive transplants and rebases to yield the same results as transitive |
a3da6f298592
revset: add destination() predicate
Matt Harbison <matt_harbison@yahoo.com>
parents:
17185
diff
changeset
|
969 |
# grafts. |
a3da6f298592
revset: add destination() predicate
Matt Harbison <matt_harbison@yahoo.com>
parents:
17185
diff
changeset
|
970 |
for r in subset: |
a3da6f298592
revset: add destination() predicate
Matt Harbison <matt_harbison@yahoo.com>
parents:
17185
diff
changeset
|
971 |
src = _getrevsource(repo, r) |
a3da6f298592
revset: add destination() predicate
Matt Harbison <matt_harbison@yahoo.com>
parents:
17185
diff
changeset
|
972 |
lineage = None |
a3da6f298592
revset: add destination() predicate
Matt Harbison <matt_harbison@yahoo.com>
parents:
17185
diff
changeset
|
973 |
|
a3da6f298592
revset: add destination() predicate
Matt Harbison <matt_harbison@yahoo.com>
parents:
17185
diff
changeset
|
974 |
while src is not None: |
a3da6f298592
revset: add destination() predicate
Matt Harbison <matt_harbison@yahoo.com>
parents:
17185
diff
changeset
|
975 |
if lineage is None: |
a3da6f298592
revset: add destination() predicate
Matt Harbison <matt_harbison@yahoo.com>
parents:
17185
diff
changeset
|
976 |
lineage = list() |
a3da6f298592
revset: add destination() predicate
Matt Harbison <matt_harbison@yahoo.com>
parents:
17185
diff
changeset
|
977 |
|
a3da6f298592
revset: add destination() predicate
Matt Harbison <matt_harbison@yahoo.com>
parents:
17185
diff
changeset
|
978 |
lineage.append(r) |
a3da6f298592
revset: add destination() predicate
Matt Harbison <matt_harbison@yahoo.com>
parents:
17185
diff
changeset
|
979 |
|
a3da6f298592
revset: add destination() predicate
Matt Harbison <matt_harbison@yahoo.com>
parents:
17185
diff
changeset
|
980 |
# The visited lineage is a match if the current source is in the arg |
a3da6f298592
revset: add destination() predicate
Matt Harbison <matt_harbison@yahoo.com>
parents:
17185
diff
changeset
|
981 |
# set. Since every candidate dest is visited by way of iterating |
17494 | 982 |
# subset, any dests further back in the lineage will be tested by a |
17186
a3da6f298592
revset: add destination() predicate
Matt Harbison <matt_harbison@yahoo.com>
parents:
17185
diff
changeset
|
983 |
# different iteration over subset. Likewise, if the src was already |
a3da6f298592
revset: add destination() predicate
Matt Harbison <matt_harbison@yahoo.com>
parents:
17185
diff
changeset
|
984 |
# selected, the current lineage can be selected without going back |
a3da6f298592
revset: add destination() predicate
Matt Harbison <matt_harbison@yahoo.com>
parents:
17185
diff
changeset
|
985 |
# further. |
22944
5aae3dea8044
revset: better naming of variables containing the value of a single argument
Mads Kiilerich <madski@unity3d.com>
parents:
22891
diff
changeset
|
986 |
if src in sources or src in dests: |
17186
a3da6f298592
revset: add destination() predicate
Matt Harbison <matt_harbison@yahoo.com>
parents:
17185
diff
changeset
|
987 |
dests.update(lineage) |
a3da6f298592
revset: add destination() predicate
Matt Harbison <matt_harbison@yahoo.com>
parents:
17185
diff
changeset
|
988 |
break |
a3da6f298592
revset: add destination() predicate
Matt Harbison <matt_harbison@yahoo.com>
parents:
17185
diff
changeset
|
989 |
|
a3da6f298592
revset: add destination() predicate
Matt Harbison <matt_harbison@yahoo.com>
parents:
17185
diff
changeset
|
990 |
r = src |
a3da6f298592
revset: add destination() predicate
Matt Harbison <matt_harbison@yahoo.com>
parents:
17185
diff
changeset
|
991 |
src = _getrevsource(repo, r) |
a3da6f298592
revset: add destination() predicate
Matt Harbison <matt_harbison@yahoo.com>
parents:
17185
diff
changeset
|
992 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
993 |
return subset.filter( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
994 |
dests.__contains__, |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
995 |
condrepr=lambda: b'<destination %r>' % _sortedb(dests), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
996 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
997 |
|
17186
a3da6f298592
revset: add destination() predicate
Matt Harbison <matt_harbison@yahoo.com>
parents:
17185
diff
changeset
|
998 |
|
45750
c00595736595
revset: rename diff(pattern) to diffcontains(pattern)
Yuya Nishihara <yuya@tcha.org>
parents:
45725
diff
changeset
|
999 |
@predicate(b'diffcontains(pattern)', weight=110) |
c00595736595
revset: rename diff(pattern) to diffcontains(pattern)
Yuya Nishihara <yuya@tcha.org>
parents:
45725
diff
changeset
|
1000 |
def diffcontains(repo, subset, x): |
45725
99b8b73eb622
revset: add diff(pattern) predicate for "grep --diff"
Yuya Nishihara <yuya@tcha.org>
parents:
45701
diff
changeset
|
1001 |
"""Search revision differences for when the pattern was added or removed. |
99b8b73eb622
revset: add diff(pattern) predicate for "grep --diff"
Yuya Nishihara <yuya@tcha.org>
parents:
45701
diff
changeset
|
1002 |
|
99b8b73eb622
revset: add diff(pattern) predicate for "grep --diff"
Yuya Nishihara <yuya@tcha.org>
parents:
45701
diff
changeset
|
1003 |
The pattern may be a substring literal or a regular expression. See |
99b8b73eb622
revset: add diff(pattern) predicate for "grep --diff"
Yuya Nishihara <yuya@tcha.org>
parents:
45701
diff
changeset
|
1004 |
:hg:`help revisions.patterns`. |
99b8b73eb622
revset: add diff(pattern) predicate for "grep --diff"
Yuya Nishihara <yuya@tcha.org>
parents:
45701
diff
changeset
|
1005 |
""" |
45750
c00595736595
revset: rename diff(pattern) to diffcontains(pattern)
Yuya Nishihara <yuya@tcha.org>
parents:
45725
diff
changeset
|
1006 |
args = getargsdict(x, b'diffcontains', b'pattern') |
45725
99b8b73eb622
revset: add diff(pattern) predicate for "grep --diff"
Yuya Nishihara <yuya@tcha.org>
parents:
45701
diff
changeset
|
1007 |
if b'pattern' not in args: |
45750
c00595736595
revset: rename diff(pattern) to diffcontains(pattern)
Yuya Nishihara <yuya@tcha.org>
parents:
45725
diff
changeset
|
1008 |
# i18n: "diffcontains" is a keyword |
c00595736595
revset: rename diff(pattern) to diffcontains(pattern)
Yuya Nishihara <yuya@tcha.org>
parents:
45725
diff
changeset
|
1009 |
raise error.ParseError(_(b'diffcontains takes at least 1 argument')) |
c00595736595
revset: rename diff(pattern) to diffcontains(pattern)
Yuya Nishihara <yuya@tcha.org>
parents:
45725
diff
changeset
|
1010 |
|
c00595736595
revset: rename diff(pattern) to diffcontains(pattern)
Yuya Nishihara <yuya@tcha.org>
parents:
45725
diff
changeset
|
1011 |
pattern = getstring( |
c00595736595
revset: rename diff(pattern) to diffcontains(pattern)
Yuya Nishihara <yuya@tcha.org>
parents:
45725
diff
changeset
|
1012 |
args[b'pattern'], _(b'diffcontains requires a string pattern') |
c00595736595
revset: rename diff(pattern) to diffcontains(pattern)
Yuya Nishihara <yuya@tcha.org>
parents:
45725
diff
changeset
|
1013 |
) |
45725
99b8b73eb622
revset: add diff(pattern) predicate for "grep --diff"
Yuya Nishihara <yuya@tcha.org>
parents:
45701
diff
changeset
|
1014 |
regexp = stringutil.substringregexp(pattern, re.M) |
99b8b73eb622
revset: add diff(pattern) predicate for "grep --diff"
Yuya Nishihara <yuya@tcha.org>
parents:
45701
diff
changeset
|
1015 |
|
99b8b73eb622
revset: add diff(pattern) predicate for "grep --diff"
Yuya Nishihara <yuya@tcha.org>
parents:
45701
diff
changeset
|
1016 |
# TODO: add support for file pattern and --follow. For example, |
45750
c00595736595
revset: rename diff(pattern) to diffcontains(pattern)
Yuya Nishihara <yuya@tcha.org>
parents:
45725
diff
changeset
|
1017 |
# diffcontains(pattern[, set]) where set may be file(pattern) or |
c00595736595
revset: rename diff(pattern) to diffcontains(pattern)
Yuya Nishihara <yuya@tcha.org>
parents:
45725
diff
changeset
|
1018 |
# follow(pattern), and we'll eventually add a support for narrowing |
c00595736595
revset: rename diff(pattern) to diffcontains(pattern)
Yuya Nishihara <yuya@tcha.org>
parents:
45725
diff
changeset
|
1019 |
# files by revset? |
45725
99b8b73eb622
revset: add diff(pattern) predicate for "grep --diff"
Yuya Nishihara <yuya@tcha.org>
parents:
45701
diff
changeset
|
1020 |
fmatch = matchmod.always() |
99b8b73eb622
revset: add diff(pattern) predicate for "grep --diff"
Yuya Nishihara <yuya@tcha.org>
parents:
45701
diff
changeset
|
1021 |
|
99b8b73eb622
revset: add diff(pattern) predicate for "grep --diff"
Yuya Nishihara <yuya@tcha.org>
parents:
45701
diff
changeset
|
1022 |
def makefilematcher(ctx): |
99b8b73eb622
revset: add diff(pattern) predicate for "grep --diff"
Yuya Nishihara <yuya@tcha.org>
parents:
45701
diff
changeset
|
1023 |
return fmatch |
99b8b73eb622
revset: add diff(pattern) predicate for "grep --diff"
Yuya Nishihara <yuya@tcha.org>
parents:
45701
diff
changeset
|
1024 |
|
99b8b73eb622
revset: add diff(pattern) predicate for "grep --diff"
Yuya Nishihara <yuya@tcha.org>
parents:
45701
diff
changeset
|
1025 |
# TODO: search in a windowed way |
99b8b73eb622
revset: add diff(pattern) predicate for "grep --diff"
Yuya Nishihara <yuya@tcha.org>
parents:
45701
diff
changeset
|
1026 |
searcher = grepmod.grepsearcher(repo.ui, repo, regexp, diff=True) |
99b8b73eb622
revset: add diff(pattern) predicate for "grep --diff"
Yuya Nishihara <yuya@tcha.org>
parents:
45701
diff
changeset
|
1027 |
|
99b8b73eb622
revset: add diff(pattern) predicate for "grep --diff"
Yuya Nishihara <yuya@tcha.org>
parents:
45701
diff
changeset
|
1028 |
def testdiff(rev): |
99b8b73eb622
revset: add diff(pattern) predicate for "grep --diff"
Yuya Nishihara <yuya@tcha.org>
parents:
45701
diff
changeset
|
1029 |
# consume the generator to discard revfiles/matches cache |
99b8b73eb622
revset: add diff(pattern) predicate for "grep --diff"
Yuya Nishihara <yuya@tcha.org>
parents:
45701
diff
changeset
|
1030 |
found = False |
99b8b73eb622
revset: add diff(pattern) predicate for "grep --diff"
Yuya Nishihara <yuya@tcha.org>
parents:
45701
diff
changeset
|
1031 |
for fn, ctx, pstates, states in searcher.searchfiles( |
99b8b73eb622
revset: add diff(pattern) predicate for "grep --diff"
Yuya Nishihara <yuya@tcha.org>
parents:
45701
diff
changeset
|
1032 |
baseset([rev]), makefilematcher |
99b8b73eb622
revset: add diff(pattern) predicate for "grep --diff"
Yuya Nishihara <yuya@tcha.org>
parents:
45701
diff
changeset
|
1033 |
): |
99b8b73eb622
revset: add diff(pattern) predicate for "grep --diff"
Yuya Nishihara <yuya@tcha.org>
parents:
45701
diff
changeset
|
1034 |
if next(grepmod.difflinestates(pstates, states), None): |
99b8b73eb622
revset: add diff(pattern) predicate for "grep --diff"
Yuya Nishihara <yuya@tcha.org>
parents:
45701
diff
changeset
|
1035 |
found = True |
99b8b73eb622
revset: add diff(pattern) predicate for "grep --diff"
Yuya Nishihara <yuya@tcha.org>
parents:
45701
diff
changeset
|
1036 |
return found |
99b8b73eb622
revset: add diff(pattern) predicate for "grep --diff"
Yuya Nishihara <yuya@tcha.org>
parents:
45701
diff
changeset
|
1037 |
|
45750
c00595736595
revset: rename diff(pattern) to diffcontains(pattern)
Yuya Nishihara <yuya@tcha.org>
parents:
45725
diff
changeset
|
1038 |
return subset.filter(testdiff, condrepr=(b'<diffcontains %r>', pattern)) |
45725
99b8b73eb622
revset: add diff(pattern) predicate for "grep --diff"
Yuya Nishihara <yuya@tcha.org>
parents:
45701
diff
changeset
|
1039 |
|
99b8b73eb622
revset: add diff(pattern) predicate for "grep --diff"
Yuya Nishihara <yuya@tcha.org>
parents:
45701
diff
changeset
|
1040 |
|
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1041 |
@predicate(b'contentdivergent()', safe=True) |
33775
f078d7358e90
revset: remane divergent into contentdivergent
Boris Feld <boris.feld@octobus.net>
parents:
33774
diff
changeset
|
1042 |
def contentdivergent(repo, subset, x): |
27584
fc7c8cac6a4b
revset: use decorator to register a function as revset predicate
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27517
diff
changeset
|
1043 |
""" |
33855
457d1ebf151b
revset: mark evolution-related revsets as experimental
Boris Feld <boris.feld@octobus.net>
parents:
33779
diff
changeset
|
1044 |
Final successors of changesets with an alternative set of final |
457d1ebf151b
revset: mark evolution-related revsets as experimental
Boris Feld <boris.feld@octobus.net>
parents:
33779
diff
changeset
|
1045 |
successors. (EXPERIMENTAL) |
18071
bea754715961
obsolete: add revset and test for divergent changesets
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
18063
diff
changeset
|
1046 |
""" |
33775
f078d7358e90
revset: remane divergent into contentdivergent
Boris Feld <boris.feld@octobus.net>
parents:
33774
diff
changeset
|
1047 |
# i18n: "contentdivergent" is a keyword |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1048 |
getargs(x, 0, 0, _(b"contentdivergent takes no arguments")) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1049 |
contentdivergent = obsmod.getrevs(repo, b'contentdivergent') |
33778
f3f06c260e9e
obsolete: rename divergent volatile set into contentdivergent volatile set
Boris Feld <boris.feld@octobus.net>
parents:
33777
diff
changeset
|
1050 |
return subset & contentdivergent |
18071
bea754715961
obsolete: add revset and test for divergent changesets
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
18063
diff
changeset
|
1051 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
1052 |
|
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1053 |
@predicate(b'expectsize(set[, size])', safe=True, takeorder=True) |
41680
8185c8abce87
revset: add expectsize to check the size of a set
Navaneeth Suresh <navaneeths1998@gmail.com>
parents:
41676
diff
changeset
|
1054 |
def expectsize(repo, subset, x, order): |
41698
5fe4de392edb
revset: improve documentation on expectsize()
Navaneeth Suresh <navaneeths1998@gmail.com>
parents:
41680
diff
changeset
|
1055 |
"""Return the given revset if size matches the revset size. |
5fe4de392edb
revset: improve documentation on expectsize()
Navaneeth Suresh <navaneeths1998@gmail.com>
parents:
41680
diff
changeset
|
1056 |
Abort if the revset doesn't expect given size. |
5fe4de392edb
revset: improve documentation on expectsize()
Navaneeth Suresh <navaneeths1998@gmail.com>
parents:
41680
diff
changeset
|
1057 |
size can either be an integer range or an integer. |
5fe4de392edb
revset: improve documentation on expectsize()
Navaneeth Suresh <navaneeths1998@gmail.com>
parents:
41680
diff
changeset
|
1058 |
|
5fe4de392edb
revset: improve documentation on expectsize()
Navaneeth Suresh <navaneeths1998@gmail.com>
parents:
41680
diff
changeset
|
1059 |
For example, ``expectsize(0:1, 3:5)`` will abort as revset size is 2 and |
5fe4de392edb
revset: improve documentation on expectsize()
Navaneeth Suresh <navaneeths1998@gmail.com>
parents:
41680
diff
changeset
|
1060 |
2 is not between 3 and 5 inclusive.""" |
5fe4de392edb
revset: improve documentation on expectsize()
Navaneeth Suresh <navaneeths1998@gmail.com>
parents:
41680
diff
changeset
|
1061 |
|
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1062 |
args = getargsdict(x, b'expectsize', b'set size') |
41680
8185c8abce87
revset: add expectsize to check the size of a set
Navaneeth Suresh <navaneeths1998@gmail.com>
parents:
41676
diff
changeset
|
1063 |
minsize = 0 |
8185c8abce87
revset: add expectsize to check the size of a set
Navaneeth Suresh <navaneeths1998@gmail.com>
parents:
41676
diff
changeset
|
1064 |
maxsize = len(repo) + 1 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1065 |
err = b'' |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1066 |
if b'size' not in args or b'set' not in args: |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1067 |
raise error.ParseError(_(b'invalid set of arguments')) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
1068 |
minsize, maxsize = getintrange( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1069 |
args[b'size'], |
43117
8ff1ecfadcd1
cleanup: join string literals that are already on one line
Martin von Zweigbergk <martinvonz@google.com>
parents:
43106
diff
changeset
|
1070 |
_(b'expectsize requires a size range or a positive integer'), |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1071 |
_(b'size range bounds must be integers'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
1072 |
minsize, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
1073 |
maxsize, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
1074 |
) |
41680
8185c8abce87
revset: add expectsize to check the size of a set
Navaneeth Suresh <navaneeths1998@gmail.com>
parents:
41676
diff
changeset
|
1075 |
if minsize < 0 or maxsize < 0: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1076 |
raise error.ParseError(_(b'negative size')) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1077 |
rev = getset(repo, fullreposet(repo), args[b'set'], order=order) |
41680
8185c8abce87
revset: add expectsize to check the size of a set
Navaneeth Suresh <navaneeths1998@gmail.com>
parents:
41676
diff
changeset
|
1078 |
if minsize != maxsize and (len(rev) < minsize or len(rev) > maxsize): |
43117
8ff1ecfadcd1
cleanup: join string literals that are already on one line
Martin von Zweigbergk <martinvonz@google.com>
parents:
43106
diff
changeset
|
1079 |
err = _(b'revset size mismatch. expected between %d and %d, got %d') % ( |
8ff1ecfadcd1
cleanup: join string literals that are already on one line
Martin von Zweigbergk <martinvonz@google.com>
parents:
43106
diff
changeset
|
1080 |
minsize, |
8ff1ecfadcd1
cleanup: join string literals that are already on one line
Martin von Zweigbergk <martinvonz@google.com>
parents:
43106
diff
changeset
|
1081 |
maxsize, |
8ff1ecfadcd1
cleanup: join string literals that are already on one line
Martin von Zweigbergk <martinvonz@google.com>
parents:
43106
diff
changeset
|
1082 |
len(rev), |
8ff1ecfadcd1
cleanup: join string literals that are already on one line
Martin von Zweigbergk <martinvonz@google.com>
parents:
43106
diff
changeset
|
1083 |
) |
41680
8185c8abce87
revset: add expectsize to check the size of a set
Navaneeth Suresh <navaneeths1998@gmail.com>
parents:
41676
diff
changeset
|
1084 |
elif minsize == maxsize and len(rev) != minsize: |
43117
8ff1ecfadcd1
cleanup: join string literals that are already on one line
Martin von Zweigbergk <martinvonz@google.com>
parents:
43106
diff
changeset
|
1085 |
err = _(b'revset size mismatch. expected %d, got %d') % ( |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
1086 |
minsize, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
1087 |
len(rev), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
1088 |
) |
41680
8185c8abce87
revset: add expectsize to check the size of a set
Navaneeth Suresh <navaneeths1998@gmail.com>
parents:
41676
diff
changeset
|
1089 |
if err: |
8185c8abce87
revset: add expectsize to check the size of a set
Navaneeth Suresh <navaneeths1998@gmail.com>
parents:
41676
diff
changeset
|
1090 |
raise error.RepoLookupError(err) |
8185c8abce87
revset: add expectsize to check the size of a set
Navaneeth Suresh <navaneeths1998@gmail.com>
parents:
41676
diff
changeset
|
1091 |
if order == followorder: |
8185c8abce87
revset: add expectsize to check the size of a set
Navaneeth Suresh <navaneeths1998@gmail.com>
parents:
41676
diff
changeset
|
1092 |
return subset & rev |
8185c8abce87
revset: add expectsize to check the size of a set
Navaneeth Suresh <navaneeths1998@gmail.com>
parents:
41676
diff
changeset
|
1093 |
else: |
8185c8abce87
revset: add expectsize to check the size of a set
Navaneeth Suresh <navaneeths1998@gmail.com>
parents:
41676
diff
changeset
|
1094 |
return rev & subset |
8185c8abce87
revset: add expectsize to check the size of a set
Navaneeth Suresh <navaneeths1998@gmail.com>
parents:
41676
diff
changeset
|
1095 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
1096 |
|
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1097 |
@predicate(b'extdata(source)', safe=False, weight=100) |
34457
2c3b8fa3211b
revset: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents:
34273
diff
changeset
|
1098 |
def extdata(repo, subset, x): |
2c3b8fa3211b
revset: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents:
34273
diff
changeset
|
1099 |
"""Changesets in the specified extdata source. (EXPERIMENTAL)""" |
2c3b8fa3211b
revset: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents:
34273
diff
changeset
|
1100 |
# i18n: "extdata" is a keyword |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1101 |
args = getargsdict(x, b'extdata', b'source') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
1102 |
source = getstring( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1103 |
args.get(b'source'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
1104 |
# i18n: "extdata" is a keyword |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1105 |
_(b'extdata takes at least 1 string argument'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
1106 |
) |
34457
2c3b8fa3211b
revset: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents:
34273
diff
changeset
|
1107 |
data = scmutil.extdatasource(repo, source) |
2c3b8fa3211b
revset: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents:
34273
diff
changeset
|
1108 |
return subset & baseset(data) |
2c3b8fa3211b
revset: add experimental support for extdata
Yuya Nishihara <yuya@tcha.org>
parents:
34273
diff
changeset
|
1109 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
1110 |
|
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1111 |
@predicate(b'extinct()', safe=True) |
17173
c621f84dbb35
obsolete: compute extinct changesets
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17171
diff
changeset
|
1112 |
def extinct(repo, subset, x): |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45750
diff
changeset
|
1113 |
"""Obsolete changesets with obsolete descendants only. (EXPERIMENTAL)""" |
17259
e96ad092fb18
i18n: add/relocate "i18n keyword" comments for i18n messages in revset.py
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
17258
diff
changeset
|
1114 |
# i18n: "extinct" is a keyword |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1115 |
getargs(x, 0, 0, _(b"extinct takes no arguments")) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1116 |
extincts = obsmod.getrevs(repo, b'extinct') |
20367
2ac278aab2b4
revset: added intersection to baseset class
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20366
diff
changeset
|
1117 |
return subset & extincts |
17173
c621f84dbb35
obsolete: compute extinct changesets
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17171
diff
changeset
|
1118 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
1119 |
|
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1120 |
@predicate(b'extra(label, [value])', safe=True) |
16661
de4b42daf396
revset: add function for matching extra data (issue2767)
Henrik Stuart <hg@hstuart.dk>
parents:
16657
diff
changeset
|
1121 |
def extra(repo, subset, x): |
27584
fc7c8cac6a4b
revset: use decorator to register a function as revset predicate
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27517
diff
changeset
|
1122 |
"""Changesets with the given label in the extra metadata, with the given |
16824
f3b8c82a559c
revset: add pattern matching to 'extra' revset expression
Simon King <simon@simonking.org.uk>
parents:
16823
diff
changeset
|
1123 |
optional value. |
f3b8c82a559c
revset: add pattern matching to 'extra' revset expression
Simon King <simon@simonking.org.uk>
parents:
16823
diff
changeset
|
1124 |
|
30784
5dd67f0993ce
help: eliminate duplicate text for revset string patterns
Matt Harbison <matt_harbison@yahoo.com>
parents:
30783
diff
changeset
|
1125 |
Pattern matching is supported for `value`. See |
30799
0b49449a01f4
help: use :hg: role and canonical name to point to revset string patterns
Yuya Nishihara <yuya@tcha.org>
parents:
30784
diff
changeset
|
1126 |
:hg:`help revisions.patterns`. |
16824
f3b8c82a559c
revset: add pattern matching to 'extra' revset expression
Simon King <simon@simonking.org.uk>
parents:
16823
diff
changeset
|
1127 |
""" |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1128 |
args = getargsdict(x, b'extra', b'label value') |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1129 |
if b'label' not in args: |
25706
b7f53c474e2c
revset: port extra() to support keyword arguments
Yuya Nishihara <yuya@tcha.org>
parents:
25705
diff
changeset
|
1130 |
# i18n: "extra" is a keyword |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1131 |
raise error.ParseError(_(b'extra takes at least 1 argument')) |
17259
e96ad092fb18
i18n: add/relocate "i18n keyword" comments for i18n messages in revset.py
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
17258
diff
changeset
|
1132 |
# i18n: "extra" is a keyword |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
1133 |
label = getstring( |
43117
8ff1ecfadcd1
cleanup: join string literals that are already on one line
Martin von Zweigbergk <martinvonz@google.com>
parents:
43106
diff
changeset
|
1134 |
args[b'label'], _(b'first argument to extra must be a string') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
1135 |
) |
16661
de4b42daf396
revset: add function for matching extra data (issue2767)
Henrik Stuart <hg@hstuart.dk>
parents:
16657
diff
changeset
|
1136 |
value = None |
de4b42daf396
revset: add function for matching extra data (issue2767)
Henrik Stuart <hg@hstuart.dk>
parents:
16657
diff
changeset
|
1137 |
|
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1138 |
if b'value' in args: |
17259
e96ad092fb18
i18n: add/relocate "i18n keyword" comments for i18n messages in revset.py
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
17258
diff
changeset
|
1139 |
# i18n: "extra" is a keyword |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
1140 |
value = getstring( |
43117
8ff1ecfadcd1
cleanup: join string literals that are already on one line
Martin von Zweigbergk <martinvonz@google.com>
parents:
43106
diff
changeset
|
1141 |
args[b'value'], _(b'second argument to extra must be a string') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
1142 |
) |
37084
f0b6fbea00cf
stringutil: bulk-replace call sites to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
37001
diff
changeset
|
1143 |
kind, value, matcher = stringutil.stringmatcher(value) |
16661
de4b42daf396
revset: add function for matching extra data (issue2767)
Henrik Stuart <hg@hstuart.dk>
parents:
16657
diff
changeset
|
1144 |
|
de4b42daf396
revset: add function for matching extra data (issue2767)
Henrik Stuart <hg@hstuart.dk>
parents:
16657
diff
changeset
|
1145 |
def _matchvalue(r): |
de4b42daf396
revset: add function for matching extra data (issue2767)
Henrik Stuart <hg@hstuart.dk>
parents:
16657
diff
changeset
|
1146 |
extra = repo[r].extra() |
16824
f3b8c82a559c
revset: add pattern matching to 'extra' revset expression
Simon King <simon@simonking.org.uk>
parents:
16823
diff
changeset
|
1147 |
return label in extra and (value is None or matcher(extra[label])) |
16661
de4b42daf396
revset: add function for matching extra data (issue2767)
Henrik Stuart <hg@hstuart.dk>
parents:
16657
diff
changeset
|
1148 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
1149 |
return subset.filter( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1150 |
lambda r: _matchvalue(r), condrepr=(b'<extra[%r] %r>', label, value) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
1151 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
1152 |
|
15819
33ca11b010e2
phases: implements simple revset symbol
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15791
diff
changeset
|
1153 |
|
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1154 |
@predicate(b'filelog(pattern)', safe=True) |
14342
c0b6a734b4f3
revset: introduce filelog() to emulate log's fast path
Matt Mackall <mpm@selenic.com>
parents:
14318
diff
changeset
|
1155 |
def filelog(repo, subset, x): |
27584
fc7c8cac6a4b
revset: use decorator to register a function as revset predicate
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27517
diff
changeset
|
1156 |
"""Changesets connected to the specified filelog. |
17244
483aa765f6c4
revset: add explanation about difference between 'filelog()' and 'file()'
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
17186
diff
changeset
|
1157 |
|
21199
e9c2f76be74b
help: clarify distinction among `contains`/`file`/`filelog`
Greg Hurrell <glh@fb.com>
parents:
21173
diff
changeset
|
1158 |
For performance reasons, visits only revisions mentioned in the file-level |
e9c2f76be74b
help: clarify distinction among `contains`/`file`/`filelog`
Greg Hurrell <glh@fb.com>
parents:
21173
diff
changeset
|
1159 |
filelog, rather than filtering through all changesets (much faster, but |
e9c2f76be74b
help: clarify distinction among `contains`/`file`/`filelog`
Greg Hurrell <glh@fb.com>
parents:
21173
diff
changeset
|
1160 |
doesn't include deletes or duplicate changes). For a slower, more accurate |
e9c2f76be74b
help: clarify distinction among `contains`/`file`/`filelog`
Greg Hurrell <glh@fb.com>
parents:
21173
diff
changeset
|
1161 |
result, use ``file()``. |
20289
96be25f1da45
revset: add explanation about the pattern without explicit kind
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20288
diff
changeset
|
1162 |
|
96be25f1da45
revset: add explanation about the pattern without explicit kind
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20288
diff
changeset
|
1163 |
The pattern without explicit kind like ``glob:`` is expected to be |
96be25f1da45
revset: add explanation about the pattern without explicit kind
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20288
diff
changeset
|
1164 |
relative to the current directory and match against a file exactly |
96be25f1da45
revset: add explanation about the pattern without explicit kind
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20288
diff
changeset
|
1165 |
for efficiency. |
14342
c0b6a734b4f3
revset: introduce filelog() to emulate log's fast path
Matt Mackall <mpm@selenic.com>
parents:
14318
diff
changeset
|
1166 |
""" |
c0b6a734b4f3
revset: introduce filelog() to emulate log's fast path
Matt Mackall <mpm@selenic.com>
parents:
14318
diff
changeset
|
1167 |
|
17259
e96ad092fb18
i18n: add/relocate "i18n keyword" comments for i18n messages in revset.py
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
17258
diff
changeset
|
1168 |
# i18n: "filelog" is a keyword |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1169 |
pat = getstring(x, _(b"filelog requires a pattern")) |
14342
c0b6a734b4f3
revset: introduce filelog() to emulate log's fast path
Matt Mackall <mpm@selenic.com>
parents:
14318
diff
changeset
|
1170 |
s = set() |
23719
34364a4b25eb
linkrev: work around linkrev to filtered entry in 'filelog' revset
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23704
diff
changeset
|
1171 |
cl = repo.changelog |
14342
c0b6a734b4f3
revset: introduce filelog() to emulate log's fast path
Matt Mackall <mpm@selenic.com>
parents:
14318
diff
changeset
|
1172 |
|
15964
6e37b8282aa2
revsets: provide contexts for filesets
Matt Mackall <mpm@selenic.com>
parents:
15949
diff
changeset
|
1173 |
if not matchmod.patkind(pat): |
20288
b61ad01c4e73
revset: use "canonpath()" for "filelog()" pattern without explicit kind
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20287
diff
changeset
|
1174 |
f = pathutil.canonpath(repo.root, repo.getcwd(), pat) |
23719
34364a4b25eb
linkrev: work around linkrev to filtered entry in 'filelog' revset
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23704
diff
changeset
|
1175 |
files = [f] |
14342
c0b6a734b4f3
revset: introduce filelog() to emulate log's fast path
Matt Mackall <mpm@selenic.com>
parents:
14318
diff
changeset
|
1176 |
else: |
20288
b61ad01c4e73
revset: use "canonpath()" for "filelog()" pattern without explicit kind
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20287
diff
changeset
|
1177 |
m = matchmod.match(repo.root, repo.getcwd(), [pat], ctx=repo[None]) |
23719
34364a4b25eb
linkrev: work around linkrev to filtered entry in 'filelog' revset
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23704
diff
changeset
|
1178 |
files = (f for f in repo[None] if m(f)) |
34364a4b25eb
linkrev: work around linkrev to filtered entry in 'filelog' revset
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23704
diff
changeset
|
1179 |
|
34364a4b25eb
linkrev: work around linkrev to filtered entry in 'filelog' revset
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23704
diff
changeset
|
1180 |
for f in files: |
34364a4b25eb
linkrev: work around linkrev to filtered entry in 'filelog' revset
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23704
diff
changeset
|
1181 |
fl = repo.file(f) |
27945
4186d359046a
log: speed up single file log with hidden revs (issue4747)
Matt Mackall <mpm@selenic.com>
parents:
27637
diff
changeset
|
1182 |
known = {} |
4186d359046a
log: speed up single file log with hidden revs (issue4747)
Matt Mackall <mpm@selenic.com>
parents:
27637
diff
changeset
|
1183 |
scanpos = 0 |
23719
34364a4b25eb
linkrev: work around linkrev to filtered entry in 'filelog' revset
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23704
diff
changeset
|
1184 |
for fr in list(fl): |
27945
4186d359046a
log: speed up single file log with hidden revs (issue4747)
Matt Mackall <mpm@selenic.com>
parents:
27637
diff
changeset
|
1185 |
fn = fl.node(fr) |
4186d359046a
log: speed up single file log with hidden revs (issue4747)
Matt Mackall <mpm@selenic.com>
parents:
27637
diff
changeset
|
1186 |
if fn in known: |
4186d359046a
log: speed up single file log with hidden revs (issue4747)
Matt Mackall <mpm@selenic.com>
parents:
27637
diff
changeset
|
1187 |
s.add(known[fn]) |
23821
7a7f437ab63d
filelog: remove trailing "form feed" character
Martin von Zweigbergk <martinvonz@google.com>
parents:
23820
diff
changeset
|
1188 |
continue |
27945
4186d359046a
log: speed up single file log with hidden revs (issue4747)
Matt Mackall <mpm@selenic.com>
parents:
27637
diff
changeset
|
1189 |
|
4186d359046a
log: speed up single file log with hidden revs (issue4747)
Matt Mackall <mpm@selenic.com>
parents:
27637
diff
changeset
|
1190 |
lr = fl.linkrev(fr) |
4186d359046a
log: speed up single file log with hidden revs (issue4747)
Matt Mackall <mpm@selenic.com>
parents:
27637
diff
changeset
|
1191 |
if lr in cl: |
4186d359046a
log: speed up single file log with hidden revs (issue4747)
Matt Mackall <mpm@selenic.com>
parents:
27637
diff
changeset
|
1192 |
s.add(lr) |
4186d359046a
log: speed up single file log with hidden revs (issue4747)
Matt Mackall <mpm@selenic.com>
parents:
27637
diff
changeset
|
1193 |
elif scanpos is not None: |
4186d359046a
log: speed up single file log with hidden revs (issue4747)
Matt Mackall <mpm@selenic.com>
parents:
27637
diff
changeset
|
1194 |
# lowest matching changeset is filtered, scan further |
4186d359046a
log: speed up single file log with hidden revs (issue4747)
Matt Mackall <mpm@selenic.com>
parents:
27637
diff
changeset
|
1195 |
# ahead in changelog |
4186d359046a
log: speed up single file log with hidden revs (issue4747)
Matt Mackall <mpm@selenic.com>
parents:
27637
diff
changeset
|
1196 |
start = max(lr, scanpos) + 1 |
4186d359046a
log: speed up single file log with hidden revs (issue4747)
Matt Mackall <mpm@selenic.com>
parents:
27637
diff
changeset
|
1197 |
scanpos = None |
4186d359046a
log: speed up single file log with hidden revs (issue4747)
Matt Mackall <mpm@selenic.com>
parents:
27637
diff
changeset
|
1198 |
for r in cl.revs(start): |
4186d359046a
log: speed up single file log with hidden revs (issue4747)
Matt Mackall <mpm@selenic.com>
parents:
27637
diff
changeset
|
1199 |
# minimize parsing of non-matching entries |
4186d359046a
log: speed up single file log with hidden revs (issue4747)
Matt Mackall <mpm@selenic.com>
parents:
27637
diff
changeset
|
1200 |
if f in cl.revision(r) and f in cl.readfiles(r): |
4186d359046a
log: speed up single file log with hidden revs (issue4747)
Matt Mackall <mpm@selenic.com>
parents:
27637
diff
changeset
|
1201 |
try: |
4186d359046a
log: speed up single file log with hidden revs (issue4747)
Matt Mackall <mpm@selenic.com>
parents:
27637
diff
changeset
|
1202 |
# try to use manifest delta fastpath |
4186d359046a
log: speed up single file log with hidden revs (issue4747)
Matt Mackall <mpm@selenic.com>
parents:
27637
diff
changeset
|
1203 |
n = repo[r].filenode(f) |
4186d359046a
log: speed up single file log with hidden revs (issue4747)
Matt Mackall <mpm@selenic.com>
parents:
27637
diff
changeset
|
1204 |
if n not in known: |
4186d359046a
log: speed up single file log with hidden revs (issue4747)
Matt Mackall <mpm@selenic.com>
parents:
27637
diff
changeset
|
1205 |
if n == fn: |
4186d359046a
log: speed up single file log with hidden revs (issue4747)
Matt Mackall <mpm@selenic.com>
parents:
27637
diff
changeset
|
1206 |
s.add(r) |
4186d359046a
log: speed up single file log with hidden revs (issue4747)
Matt Mackall <mpm@selenic.com>
parents:
27637
diff
changeset
|
1207 |
scanpos = r |
4186d359046a
log: speed up single file log with hidden revs (issue4747)
Matt Mackall <mpm@selenic.com>
parents:
27637
diff
changeset
|
1208 |
break |
4186d359046a
log: speed up single file log with hidden revs (issue4747)
Matt Mackall <mpm@selenic.com>
parents:
27637
diff
changeset
|
1209 |
else: |
4186d359046a
log: speed up single file log with hidden revs (issue4747)
Matt Mackall <mpm@selenic.com>
parents:
27637
diff
changeset
|
1210 |
known[n] = r |
4186d359046a
log: speed up single file log with hidden revs (issue4747)
Matt Mackall <mpm@selenic.com>
parents:
27637
diff
changeset
|
1211 |
except error.ManifestLookupError: |
4186d359046a
log: speed up single file log with hidden revs (issue4747)
Matt Mackall <mpm@selenic.com>
parents:
27637
diff
changeset
|
1212 |
# deletion in changelog |
4186d359046a
log: speed up single file log with hidden revs (issue4747)
Matt Mackall <mpm@selenic.com>
parents:
27637
diff
changeset
|
1213 |
continue |
14342
c0b6a734b4f3
revset: introduce filelog() to emulate log's fast path
Matt Mackall <mpm@selenic.com>
parents:
14318
diff
changeset
|
1214 |
|
22534
6261b9c549a2
revset: use `subset &` in `filelog`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22533
diff
changeset
|
1215 |
return subset & s |
14342
c0b6a734b4f3
revset: introduce filelog() to emulate log's fast path
Matt Mackall <mpm@selenic.com>
parents:
14318
diff
changeset
|
1216 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
1217 |
|
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1218 |
@predicate(b'first(set, [n])', safe=True, takeorder=True, weight=0) |
32801
348b491c0934
revset: fix order of first/last members in compound expression (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
32800
diff
changeset
|
1219 |
def first(repo, subset, x, order): |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45750
diff
changeset
|
1220 |
"""An alias for limit().""" |
32801
348b491c0934
revset: fix order of first/last members in compound expression (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
32800
diff
changeset
|
1221 |
return limit(repo, subset, x, order) |
15117
0ab1c3a1f3b2
revsets: add first alias for last
Matt Mackall <mpm@selenic.com>
parents:
15116
diff
changeset
|
1222 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
1223 |
|
16185
352053e6cd8e
context: add followfirst arg to filectx and workingfilectx
Patrick Mezard <patrick@mezard.eu>
parents:
16181
diff
changeset
|
1224 |
def _follow(repo, subset, x, name, followfirst=False): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1225 |
args = getargsdict(x, name, b'file startrev') |
35300
d36eda8896cc
revset: alias follow(startrev=rev) to ancestors(rev)
Yuya Nishihara <yuya@tcha.org>
parents:
35299
diff
changeset
|
1226 |
revs = None |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1227 |
if b'startrev' in args: |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1228 |
revs = getset(repo, fullreposet(repo), args[b'startrev']) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1229 |
if b'file' in args: |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1230 |
x = getstring(args[b'file'], _(b"%s expected a pattern") % name) |
35300
d36eda8896cc
revset: alias follow(startrev=rev) to ancestors(rev)
Yuya Nishihara <yuya@tcha.org>
parents:
35299
diff
changeset
|
1231 |
if revs is None: |
d36eda8896cc
revset: alias follow(startrev=rev) to ancestors(rev)
Yuya Nishihara <yuya@tcha.org>
parents:
35299
diff
changeset
|
1232 |
revs = [None] |
35298
921680c3e2ea
revset: make follow() accept multiple startrevs
Yuya Nishihara <yuya@tcha.org>
parents:
35296
diff
changeset
|
1233 |
fctxs = [] |
921680c3e2ea
revset: make follow() accept multiple startrevs
Yuya Nishihara <yuya@tcha.org>
parents:
35296
diff
changeset
|
1234 |
for r in revs: |
921680c3e2ea
revset: make follow() accept multiple startrevs
Yuya Nishihara <yuya@tcha.org>
parents:
35296
diff
changeset
|
1235 |
ctx = mctx = repo[r] |
921680c3e2ea
revset: make follow() accept multiple startrevs
Yuya Nishihara <yuya@tcha.org>
parents:
35296
diff
changeset
|
1236 |
if r is None: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1237 |
ctx = repo[b'.'] |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
1238 |
m = matchmod.match( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1239 |
repo.root, repo.getcwd(), [x], ctx=mctx, default=b'path' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
1240 |
) |
35298
921680c3e2ea
revset: make follow() accept multiple startrevs
Yuya Nishihara <yuya@tcha.org>
parents:
35296
diff
changeset
|
1241 |
fctxs.extend(ctx[f].introfilectx() for f in ctx.manifest().walk(m)) |
35296
2cb05e6043be
dagop: add smartset interface to filectxancestors()
Yuya Nishihara <yuya@tcha.org>
parents:
35276
diff
changeset
|
1242 |
s = dagop.filerevancestors(fctxs, followfirst) |
16185
352053e6cd8e
context: add followfirst arg to filectx and workingfilectx
Patrick Mezard <patrick@mezard.eu>
parents:
16181
diff
changeset
|
1243 |
else: |
35300
d36eda8896cc
revset: alias follow(startrev=rev) to ancestors(rev)
Yuya Nishihara <yuya@tcha.org>
parents:
35299
diff
changeset
|
1244 |
if revs is None: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1245 |
revs = baseset([repo[b'.'].rev()]) |
35300
d36eda8896cc
revset: alias follow(startrev=rev) to ancestors(rev)
Yuya Nishihara <yuya@tcha.org>
parents:
35299
diff
changeset
|
1246 |
s = dagop.revancestors(repo, revs, followfirst) |
16185
352053e6cd8e
context: add followfirst arg to filectx and workingfilectx
Patrick Mezard <patrick@mezard.eu>
parents:
16181
diff
changeset
|
1247 |
|
22535
44f471102f3a
revset: use `subset &` in `follow`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22534
diff
changeset
|
1248 |
return subset & s |
16185
352053e6cd8e
context: add followfirst arg to filectx and workingfilectx
Patrick Mezard <patrick@mezard.eu>
parents:
16181
diff
changeset
|
1249 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
1250 |
|
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1251 |
@predicate(b'follow([file[, startrev]])', safe=True) |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
1252 |
def follow(repo, subset, x): |
27584
fc7c8cac6a4b
revset: use decorator to register a function as revset predicate
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27517
diff
changeset
|
1253 |
""" |
24366
e8ea31131705
revset: replace "working copy" with "working directory" in function help
Yuya Nishihara <yuya@tcha.org>
parents:
24306
diff
changeset
|
1254 |
An alias for ``::.`` (ancestors of the working directory's first parent). |
35299
89b5c2ae1980
revset: make follow() accept keyword arguments
Yuya Nishihara <yuya@tcha.org>
parents:
35298
diff
changeset
|
1255 |
If file pattern is specified, the histories of files matching given |
29814
cbf9984a7957
revset: support "follow(renamed.py, e22f4f3f06c3)" (issue5334)
Gábor Stefanik <gabor.stefanik@nng.com>
parents:
29780
diff
changeset
|
1256 |
pattern in the revision given by startrev are followed, including copies. |
14343
9ed227f79e47
revset: add follow(filename) to follow a filename's history across copies
Matt Mackall <mpm@selenic.com>
parents:
14342
diff
changeset
|
1257 |
""" |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1258 |
return _follow(repo, subset, x, b'follow') |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1259 |
|
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1260 |
|
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1261 |
@predicate(b'_followfirst', safe=True) |
16174
0a73c4bd9f47
graphlog: implement --follow-first
Patrick Mezard <patrick@mezard.eu>
parents:
16161
diff
changeset
|
1262 |
def _followfirst(repo, subset, x): |
35299
89b5c2ae1980
revset: make follow() accept keyword arguments
Yuya Nishihara <yuya@tcha.org>
parents:
35298
diff
changeset
|
1263 |
# ``followfirst([file[, startrev]])`` |
89b5c2ae1980
revset: make follow() accept keyword arguments
Yuya Nishihara <yuya@tcha.org>
parents:
35298
diff
changeset
|
1264 |
# Like ``follow([file[, startrev]])`` but follows only the first parent |
29814
cbf9984a7957
revset: support "follow(renamed.py, e22f4f3f06c3)" (issue5334)
Gábor Stefanik <gabor.stefanik@nng.com>
parents:
29780
diff
changeset
|
1265 |
# of every revisions or files revisions. |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1266 |
return _follow(repo, subset, x, b'_followfirst', followfirst=True) |
14343
9ed227f79e47
revset: add follow(filename) to follow a filename's history across copies
Matt Mackall <mpm@selenic.com>
parents:
14342
diff
changeset
|
1267 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
1268 |
|
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
1269 |
@predicate( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1270 |
b'followlines(file, fromline:toline[, startrev=., descend=False])', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1271 |
safe=True, |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
1272 |
) |
30719
42c75b4fa46a
revset: add a followlines(file, fromline, toline[, rev]) revset
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
30702
diff
changeset
|
1273 |
def followlines(repo, subset, x): |
42c75b4fa46a
revset: add a followlines(file, fromline, toline[, rev]) revset
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
30702
diff
changeset
|
1274 |
"""Changesets modifying `file` in line range ('fromline', 'toline'). |
42c75b4fa46a
revset: add a followlines(file, fromline, toline[, rev]) revset
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
30702
diff
changeset
|
1275 |
|
30800
cd23879cbac7
revset: rename rev argument of followlines() to startrev
Yuya Nishihara <yuya@tcha.org>
parents:
30799
diff
changeset
|
1276 |
Line range corresponds to 'file' content at 'startrev' and should hence be |
cd23879cbac7
revset: rename rev argument of followlines() to startrev
Yuya Nishihara <yuya@tcha.org>
parents:
30799
diff
changeset
|
1277 |
consistent with file size. If startrev is not specified, working directory's |
30719
42c75b4fa46a
revset: add a followlines(file, fromline, toline[, rev]) revset
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
30702
diff
changeset
|
1278 |
parent is used. |
31938
5e3b49defbff
revset: add a 'descend' argument to followlines to return descendants
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
31810
diff
changeset
|
1279 |
|
5e3b49defbff
revset: add a 'descend' argument to followlines to return descendants
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
31810
diff
changeset
|
1280 |
By default, ancestors of 'startrev' are returned. If 'descend' is True, |
5e3b49defbff
revset: add a 'descend' argument to followlines to return descendants
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
31810
diff
changeset
|
1281 |
descendants of 'startrev' are returned though renames are (currently) not |
5e3b49defbff
revset: add a 'descend' argument to followlines to return descendants
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
31810
diff
changeset
|
1282 |
followed in this direction. |
30719
42c75b4fa46a
revset: add a followlines(file, fromline, toline[, rev]) revset
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
30702
diff
changeset
|
1283 |
""" |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1284 |
args = getargsdict(x, b'followlines', b'file *lines startrev descend') |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1285 |
if len(args[b'lines']) != 1: |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1286 |
raise error.ParseError(_(b"followlines requires a line range")) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1287 |
|
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1288 |
rev = b'.' |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1289 |
if b'startrev' in args: |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1290 |
revs = getset(repo, fullreposet(repo), args[b'startrev']) |
30754
26209cb7184e
revset: parse variable-length arguments of followlines() by getargsdict()
Yuya Nishihara <yuya@tcha.org>
parents:
30753
diff
changeset
|
1291 |
if len(revs) != 1: |
26209cb7184e
revset: parse variable-length arguments of followlines() by getargsdict()
Yuya Nishihara <yuya@tcha.org>
parents:
30753
diff
changeset
|
1292 |
raise error.ParseError( |
32085
2a2744dffecf
revset: add i18n comments to error messages for followlines predicate
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
31998
diff
changeset
|
1293 |
# i18n: "followlines" is a keyword |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1294 |
_(b"followlines expects exactly one revision") |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
1295 |
) |
30754
26209cb7184e
revset: parse variable-length arguments of followlines() by getargsdict()
Yuya Nishihara <yuya@tcha.org>
parents:
30753
diff
changeset
|
1296 |
rev = revs.last() |
26209cb7184e
revset: parse variable-length arguments of followlines() by getargsdict()
Yuya Nishihara <yuya@tcha.org>
parents:
30753
diff
changeset
|
1297 |
|
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1298 |
pat = getstring(args[b'file'], _(b"followlines requires a pattern")) |
34854
39b094e4ae2c
revset: extract a parsefollowlinespattern helper function
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
34457
diff
changeset
|
1299 |
# i18n: "followlines" is a keyword |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1300 |
msg = _(b"followlines expects exactly one file") |
34854
39b094e4ae2c
revset: extract a parsefollowlinespattern helper function
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
34457
diff
changeset
|
1301 |
fname = scmutil.parsefollowlinespattern(repo, rev, pat, msg) |
41561
59638c6fcb70
revset: extract a helper to parse integer range
Yuya Nishihara <yuya@tcha.org>
parents:
41397
diff
changeset
|
1302 |
fromline, toline = util.processlinerange( |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
1303 |
*getintrange( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1304 |
args[b'lines'][0], |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
1305 |
# i18n: "followlines" is a keyword |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1306 |
_(b"followlines expects a line number or a range"), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1307 |
_(b"line range bounds must be integers"), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
1308 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
1309 |
) |
30719
42c75b4fa46a
revset: add a followlines(file, fromline, toline[, rev]) revset
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
30702
diff
changeset
|
1310 |
|
42c75b4fa46a
revset: add a followlines(file, fromline, toline[, rev]) revset
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
30702
diff
changeset
|
1311 |
fctx = repo[rev].filectx(fname) |
31998
83527d9f1f13
revset: properly parse "descend" argument of followlines()
Denis Laxalde <denis@laxalde.org>
parents:
31938
diff
changeset
|
1312 |
descend = False |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1313 |
if b'descend' in args: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
1314 |
descend = getboolean( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1315 |
args[b'descend'], |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
1316 |
# i18n: "descend" is a keyword |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1317 |
_(b"descend argument must be a boolean"), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
1318 |
) |
31998
83527d9f1f13
revset: properly parse "descend" argument of followlines()
Denis Laxalde <denis@laxalde.org>
parents:
31938
diff
changeset
|
1319 |
if descend: |
31938
5e3b49defbff
revset: add a 'descend' argument to followlines to return descendants
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
31810
diff
changeset
|
1320 |
rs = generatorset( |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
1321 |
( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
1322 |
c.rev() |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
1323 |
for c, _linerange in dagop.blockdescendants( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
1324 |
fctx, fromline, toline |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
1325 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
1326 |
), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
1327 |
iterasc=True, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
1328 |
) |
31938
5e3b49defbff
revset: add a 'descend' argument to followlines to return descendants
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
31810
diff
changeset
|
1329 |
else: |
5e3b49defbff
revset: add a 'descend' argument to followlines to return descendants
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
31810
diff
changeset
|
1330 |
rs = generatorset( |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
1331 |
( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
1332 |
c.rev() |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
1333 |
for c, _linerange in dagop.blockancestors( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
1334 |
fctx, fromline, toline |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
1335 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
1336 |
), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
1337 |
iterasc=False, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
1338 |
) |
31938
5e3b49defbff
revset: add a 'descend' argument to followlines to return descendants
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
31810
diff
changeset
|
1339 |
return subset & rs |
30719
42c75b4fa46a
revset: add a followlines(file, fromline, toline[, rev]) revset
Denis Laxalde <denis.laxalde@logilab.fr>
parents:
30702
diff
changeset
|
1340 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
1341 |
|
46809
56d441256e82
revset: introduce a `nodefromfile` revset
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46720
diff
changeset
|
1342 |
@predicate(b'nodefromfile(path)') |
56d441256e82
revset: introduce a `nodefromfile` revset
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46720
diff
changeset
|
1343 |
def nodefromfile(repo, subset, x): |
49276
3b102efde517
revset: fix the doc of "nodefromfile"
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47437
diff
changeset
|
1344 |
"""Read a list of nodes from the file at `path`. |
3b102efde517
revset: fix the doc of "nodefromfile"
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47437
diff
changeset
|
1345 |
|
3b102efde517
revset: fix the doc of "nodefromfile"
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47437
diff
changeset
|
1346 |
This applies `id(LINE)` to each line of the file. |
3b102efde517
revset: fix the doc of "nodefromfile"
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47437
diff
changeset
|
1347 |
|
3b102efde517
revset: fix the doc of "nodefromfile"
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47437
diff
changeset
|
1348 |
This is useful when the amount of nodes you need to specify gets too large |
3b102efde517
revset: fix the doc of "nodefromfile"
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47437
diff
changeset
|
1349 |
for the command line. |
46809
56d441256e82
revset: introduce a `nodefromfile` revset
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46720
diff
changeset
|
1350 |
""" |
56d441256e82
revset: introduce a `nodefromfile` revset
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46720
diff
changeset
|
1351 |
path = getstring(x, _(b"nodefromfile require a file path")) |
56d441256e82
revset: introduce a `nodefromfile` revset
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46720
diff
changeset
|
1352 |
listed_rev = set() |
56d441256e82
revset: introduce a `nodefromfile` revset
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46720
diff
changeset
|
1353 |
try: |
56d441256e82
revset: introduce a `nodefromfile` revset
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46720
diff
changeset
|
1354 |
with pycompat.open(path, 'rb') as f: |
56d441256e82
revset: introduce a `nodefromfile` revset
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46720
diff
changeset
|
1355 |
for line in f: |
56d441256e82
revset: introduce a `nodefromfile` revset
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46720
diff
changeset
|
1356 |
n = line.strip() |
56d441256e82
revset: introduce a `nodefromfile` revset
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46720
diff
changeset
|
1357 |
rn = _node(repo, n) |
56d441256e82
revset: introduce a `nodefromfile` revset
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46720
diff
changeset
|
1358 |
if rn is not None: |
56d441256e82
revset: introduce a `nodefromfile` revset
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46720
diff
changeset
|
1359 |
listed_rev.add(rn) |
56d441256e82
revset: introduce a `nodefromfile` revset
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46720
diff
changeset
|
1360 |
except IOError as exc: |
56d441256e82
revset: introduce a `nodefromfile` revset
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46720
diff
changeset
|
1361 |
m = _(b'cannot open nodes file "%s": %s') |
56d441256e82
revset: introduce a `nodefromfile` revset
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46720
diff
changeset
|
1362 |
m %= (path, encoding.strtolocal(exc.strerror)) |
56d441256e82
revset: introduce a `nodefromfile` revset
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46720
diff
changeset
|
1363 |
raise error.Abort(m) |
56d441256e82
revset: introduce a `nodefromfile` revset
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46720
diff
changeset
|
1364 |
return subset & baseset(listed_rev) |
56d441256e82
revset: introduce a `nodefromfile` revset
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46720
diff
changeset
|
1365 |
|
56d441256e82
revset: introduce a `nodefromfile` revset
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46720
diff
changeset
|
1366 |
|
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1367 |
@predicate(b'all()', safe=True) |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
1368 |
def getall(repo, subset, x): |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45750
diff
changeset
|
1369 |
"""All changesets, the same as ``0:tip``.""" |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
1370 |
# i18n: "all" is a keyword |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1371 |
getargs(x, 0, 0, _(b"all takes no arguments")) |
24202
2de9ee016425
revset: have all() filter out null revision
Yuya Nishihara <yuya@tcha.org>
parents:
24201
diff
changeset
|
1372 |
return subset & spanset(repo) # drop "null" if any |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
1373 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
1374 |
|
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1375 |
@predicate(b'grep(regex)', weight=10) |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
1376 |
def grep(repo, subset, x): |
27584
fc7c8cac6a4b
revset: use decorator to register a function as revset predicate
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27517
diff
changeset
|
1377 |
"""Like ``keyword(string)`` but accepts a regex. Use ``grep(r'...')`` |
14357 | 1378 |
to ensure special escape characters are handled correctly. Unlike |
1379 |
``keyword(string)``, the match is case-sensitive. |
|
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
1380 |
""" |
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
1381 |
try: |
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
1382 |
# i18n: "grep" is a keyword |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1383 |
gr = re.compile(getstring(x, _(b"grep requires a string"))) |
25660
328739ea70c3
global: mass rewrite to use modern exception syntax
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25654
diff
changeset
|
1384 |
except re.error as e: |
36580
04e50037d957
revset: use {force,}bytestr to fix some %r formatting issues
Augie Fackler <augie@google.com>
parents:
35914
diff
changeset
|
1385 |
raise error.ParseError( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1386 |
_(b'invalid match pattern: %s') % stringutil.forcebytestr(e) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
1387 |
) |
20453
6aa7dcae6bd8
revset: added lazyset implementation to grep revset
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20452
diff
changeset
|
1388 |
|
6aa7dcae6bd8
revset: added lazyset implementation to grep revset
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20452
diff
changeset
|
1389 |
def matches(x): |
6aa7dcae6bd8
revset: added lazyset implementation to grep revset
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20452
diff
changeset
|
1390 |
c = repo[x] |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
1391 |
for e in c.files() + [c.user(), c.description()]: |
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
1392 |
if gr.search(e): |
20453
6aa7dcae6bd8
revset: added lazyset implementation to grep revset
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20452
diff
changeset
|
1393 |
return True |
6aa7dcae6bd8
revset: added lazyset implementation to grep revset
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20452
diff
changeset
|
1394 |
return False |
6aa7dcae6bd8
revset: added lazyset implementation to grep revset
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20452
diff
changeset
|
1395 |
|
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1396 |
return subset.filter(matches, condrepr=(b'<grep %r>', gr.pattern)) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1397 |
|
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1398 |
|
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1399 |
@predicate(b'_matchfiles', safe=True) |
16161
5a627b49b4d9
graphlog: paths/-I/-X handling requires a new revset
Patrick Mezard <patrick@mezard.eu>
parents:
16096
diff
changeset
|
1400 |
def _matchfiles(repo, subset, x): |
5a627b49b4d9
graphlog: paths/-I/-X handling requires a new revset
Patrick Mezard <patrick@mezard.eu>
parents:
16096
diff
changeset
|
1401 |
# _matchfiles takes a revset list of prefixed arguments: |
5a627b49b4d9
graphlog: paths/-I/-X handling requires a new revset
Patrick Mezard <patrick@mezard.eu>
parents:
16096
diff
changeset
|
1402 |
# |
5a627b49b4d9
graphlog: paths/-I/-X handling requires a new revset
Patrick Mezard <patrick@mezard.eu>
parents:
16096
diff
changeset
|
1403 |
# [p:foo, i:bar, x:baz] |
5a627b49b4d9
graphlog: paths/-I/-X handling requires a new revset
Patrick Mezard <patrick@mezard.eu>
parents:
16096
diff
changeset
|
1404 |
# |
5a627b49b4d9
graphlog: paths/-I/-X handling requires a new revset
Patrick Mezard <patrick@mezard.eu>
parents:
16096
diff
changeset
|
1405 |
# builds a match object from them and filters subset. Allowed |
5a627b49b4d9
graphlog: paths/-I/-X handling requires a new revset
Patrick Mezard <patrick@mezard.eu>
parents:
16096
diff
changeset
|
1406 |
# prefixes are 'p:' for regular patterns, 'i:' for include |
16181
1fd352aa08fc
graphlog: evaluate FILE/-I/-X filesets on the working dir
Patrick Mezard <patrick@mezard.eu>
parents:
16174
diff
changeset
|
1407 |
# patterns and 'x:' for exclude patterns. Use 'r:' prefix to pass |
1fd352aa08fc
graphlog: evaluate FILE/-I/-X filesets on the working dir
Patrick Mezard <patrick@mezard.eu>
parents:
16174
diff
changeset
|
1408 |
# a revision identifier, or the empty string to reference the |
1fd352aa08fc
graphlog: evaluate FILE/-I/-X filesets on the working dir
Patrick Mezard <patrick@mezard.eu>
parents:
16174
diff
changeset
|
1409 |
# working directory, from which the match object is |
16411
4c2edcd84175
graphlog: correctly handle calls in subdirectories
Patrick Mezard <patrick@mezard.eu>
parents:
16409
diff
changeset
|
1410 |
# initialized. Use 'd:' to set the default matching mode, default |
4c2edcd84175
graphlog: correctly handle calls in subdirectories
Patrick Mezard <patrick@mezard.eu>
parents:
16409
diff
changeset
|
1411 |
# to 'glob'. At most one 'r:' and 'd:' argument can be passed. |
16161
5a627b49b4d9
graphlog: paths/-I/-X handling requires a new revset
Patrick Mezard <patrick@mezard.eu>
parents:
16096
diff
changeset
|
1412 |
|
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1413 |
l = getargs(x, 1, -1, b"_matchfiles requires at least one argument") |
16161
5a627b49b4d9
graphlog: paths/-I/-X handling requires a new revset
Patrick Mezard <patrick@mezard.eu>
parents:
16096
diff
changeset
|
1414 |
pats, inc, exc = [], [], [] |
16411
4c2edcd84175
graphlog: correctly handle calls in subdirectories
Patrick Mezard <patrick@mezard.eu>
parents:
16409
diff
changeset
|
1415 |
rev, default = None, None |
16161
5a627b49b4d9
graphlog: paths/-I/-X handling requires a new revset
Patrick Mezard <patrick@mezard.eu>
parents:
16096
diff
changeset
|
1416 |
for arg in l: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1417 |
s = getstring(arg, b"_matchfiles requires string arguments") |
16161
5a627b49b4d9
graphlog: paths/-I/-X handling requires a new revset
Patrick Mezard <patrick@mezard.eu>
parents:
16096
diff
changeset
|
1418 |
prefix, value = s[:2], s[2:] |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1419 |
if prefix == b'p:': |
16161
5a627b49b4d9
graphlog: paths/-I/-X handling requires a new revset
Patrick Mezard <patrick@mezard.eu>
parents:
16096
diff
changeset
|
1420 |
pats.append(value) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1421 |
elif prefix == b'i:': |
16161
5a627b49b4d9
graphlog: paths/-I/-X handling requires a new revset
Patrick Mezard <patrick@mezard.eu>
parents:
16096
diff
changeset
|
1422 |
inc.append(value) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1423 |
elif prefix == b'x:': |
16161
5a627b49b4d9
graphlog: paths/-I/-X handling requires a new revset
Patrick Mezard <patrick@mezard.eu>
parents:
16096
diff
changeset
|
1424 |
exc.append(value) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1425 |
elif prefix == b'r:': |
16181
1fd352aa08fc
graphlog: evaluate FILE/-I/-X filesets on the working dir
Patrick Mezard <patrick@mezard.eu>
parents:
16174
diff
changeset
|
1426 |
if rev is not None: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
1427 |
raise error.ParseError( |
43117
8ff1ecfadcd1
cleanup: join string literals that are already on one line
Martin von Zweigbergk <martinvonz@google.com>
parents:
43106
diff
changeset
|
1428 |
b'_matchfiles expected at most one revision' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
1429 |
) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1430 |
if value == b'': # empty means working directory |
46113
59fa3890d40a
node: import symbols explicitly
Joerg Sonnenberger <joerg@bec.de>
parents:
45942
diff
changeset
|
1431 |
rev = wdirrev |
35816
f6ca1e11d8b4
revset: evaluate filesets against each revision for 'file()' (issue5778)
Matt Harbison <matt_harbison@yahoo.com>
parents:
35673
diff
changeset
|
1432 |
else: |
23950
caff3675cba5
log: evaluate filesets on working copy, not its parent
Martin von Zweigbergk <martinvonz@google.com>
parents:
23847
diff
changeset
|
1433 |
rev = value |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1434 |
elif prefix == b'd:': |
16411
4c2edcd84175
graphlog: correctly handle calls in subdirectories
Patrick Mezard <patrick@mezard.eu>
parents:
16409
diff
changeset
|
1435 |
if default is not None: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
1436 |
raise error.ParseError( |
43117
8ff1ecfadcd1
cleanup: join string literals that are already on one line
Martin von Zweigbergk <martinvonz@google.com>
parents:
43106
diff
changeset
|
1437 |
b'_matchfiles expected at most one default mode' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
1438 |
) |
16411
4c2edcd84175
graphlog: correctly handle calls in subdirectories
Patrick Mezard <patrick@mezard.eu>
parents:
16409
diff
changeset
|
1439 |
default = value |
16161
5a627b49b4d9
graphlog: paths/-I/-X handling requires a new revset
Patrick Mezard <patrick@mezard.eu>
parents:
16096
diff
changeset
|
1440 |
else: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1441 |
raise error.ParseError(b'invalid _matchfiles prefix: %s' % prefix) |
16411
4c2edcd84175
graphlog: correctly handle calls in subdirectories
Patrick Mezard <patrick@mezard.eu>
parents:
16409
diff
changeset
|
1442 |
if not default: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1443 |
default = b'glob' |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1444 |
hasset = any(matchmod.patkind(p) == b'set' for p in pats + inc + exc) |
20458
8dabcc889e33
revset: added lazyset implementation to _matchfiles
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20457
diff
changeset
|
1445 |
|
35816
f6ca1e11d8b4
revset: evaluate filesets against each revision for 'file()' (issue5778)
Matt Harbison <matt_harbison@yahoo.com>
parents:
35673
diff
changeset
|
1446 |
mcache = [None] |
23061
f2aeff8a87b6
revset: avoid recalculating filesets
Matt Mackall <mpm@selenic.com>
parents:
23019
diff
changeset
|
1447 |
|
27028
f92053df8f0b
revset: speed up '_matchfiles'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26778
diff
changeset
|
1448 |
# This directly read the changelog data as creating changectx for all |
f92053df8f0b
revset: speed up '_matchfiles'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26778
diff
changeset
|
1449 |
# revisions is quite expensive. |
27440
ff305ab2e0d7
log: speed up hg log <file|folder>
Laurent Charignon <lcharignon@fb.com>
parents:
27293
diff
changeset
|
1450 |
getfiles = repo.changelog.readfiles |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
1451 |
|
20458
8dabcc889e33
revset: added lazyset implementation to _matchfiles
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20457
diff
changeset
|
1452 |
def matches(x): |
27028
f92053df8f0b
revset: speed up '_matchfiles'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26778
diff
changeset
|
1453 |
if x == wdirrev: |
f92053df8f0b
revset: speed up '_matchfiles'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26778
diff
changeset
|
1454 |
files = repo[x].files() |
f92053df8f0b
revset: speed up '_matchfiles'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26778
diff
changeset
|
1455 |
else: |
27440
ff305ab2e0d7
log: speed up hg log <file|folder>
Laurent Charignon <lcharignon@fb.com>
parents:
27293
diff
changeset
|
1456 |
files = getfiles(x) |
35816
f6ca1e11d8b4
revset: evaluate filesets against each revision for 'file()' (issue5778)
Matt Harbison <matt_harbison@yahoo.com>
parents:
35673
diff
changeset
|
1457 |
|
f6ca1e11d8b4
revset: evaluate filesets against each revision for 'file()' (issue5778)
Matt Harbison <matt_harbison@yahoo.com>
parents:
35673
diff
changeset
|
1458 |
if not mcache[0] or (hasset and rev is None): |
f6ca1e11d8b4
revset: evaluate filesets against each revision for 'file()' (issue5778)
Matt Harbison <matt_harbison@yahoo.com>
parents:
35673
diff
changeset
|
1459 |
r = x if rev is None else rev |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
1460 |
mcache[0] = matchmod.match( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
1461 |
repo.root, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
1462 |
repo.getcwd(), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
1463 |
pats, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
1464 |
include=inc, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
1465 |
exclude=exc, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
1466 |
ctx=repo[r], |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
1467 |
default=default, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
1468 |
) |
35816
f6ca1e11d8b4
revset: evaluate filesets against each revision for 'file()' (issue5778)
Matt Harbison <matt_harbison@yahoo.com>
parents:
35673
diff
changeset
|
1469 |
m = mcache[0] |
f6ca1e11d8b4
revset: evaluate filesets against each revision for 'file()' (issue5778)
Matt Harbison <matt_harbison@yahoo.com>
parents:
35673
diff
changeset
|
1470 |
|
27028
f92053df8f0b
revset: speed up '_matchfiles'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
26778
diff
changeset
|
1471 |
for f in files: |
16161
5a627b49b4d9
graphlog: paths/-I/-X handling requires a new revset
Patrick Mezard <patrick@mezard.eu>
parents:
16096
diff
changeset
|
1472 |
if m(f): |
20458
8dabcc889e33
revset: added lazyset implementation to _matchfiles
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20457
diff
changeset
|
1473 |
return True |
8dabcc889e33
revset: added lazyset implementation to _matchfiles
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20457
diff
changeset
|
1474 |
return False |
8dabcc889e33
revset: added lazyset implementation to _matchfiles
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20457
diff
changeset
|
1475 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
1476 |
return subset.filter( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
1477 |
matches, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
1478 |
condrepr=( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1479 |
b'<matchfiles patterns=%r, include=%r ' |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1480 |
b'exclude=%r, default=%r, rev=%r>', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
1481 |
pats, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
1482 |
inc, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
1483 |
exc, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
1484 |
default, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
1485 |
rev, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
1486 |
), |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
1487 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
1488 |
|
16161
5a627b49b4d9
graphlog: paths/-I/-X handling requires a new revset
Patrick Mezard <patrick@mezard.eu>
parents:
16096
diff
changeset
|
1489 |
|
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1490 |
@predicate(b'file(pattern)', safe=True, weight=10) |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
1491 |
def hasfile(repo, subset, x): |
27584
fc7c8cac6a4b
revset: use decorator to register a function as revset predicate
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27517
diff
changeset
|
1492 |
"""Changesets affecting files matched by pattern. |
17244
483aa765f6c4
revset: add explanation about difference between 'filelog()' and 'file()'
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
17186
diff
changeset
|
1493 |
|
17265
c30307eeec4b
revset: polish explanation of the difference between file() and filelog()
Greg Ward <greg@gerg.ca>
parents:
17259
diff
changeset
|
1494 |
For a faster but less accurate result, consider using ``filelog()`` |
c30307eeec4b
revset: polish explanation of the difference between file() and filelog()
Greg Ward <greg@gerg.ca>
parents:
17259
diff
changeset
|
1495 |
instead. |
20289
96be25f1da45
revset: add explanation about the pattern without explicit kind
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20288
diff
changeset
|
1496 |
|
96be25f1da45
revset: add explanation about the pattern without explicit kind
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20288
diff
changeset
|
1497 |
This predicate uses ``glob:`` as the default kind of pattern. |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
1498 |
""" |
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
1499 |
# i18n: "file" is a keyword |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1500 |
pat = getstring(x, _(b"file requires a pattern")) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1501 |
return _matchfiles(repo, subset, (b'string', b'p:' + pat)) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1502 |
|
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1503 |
|
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1504 |
@predicate(b'head()', safe=True) |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
1505 |
def head(repo, subset, x): |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45750
diff
changeset
|
1506 |
"""Changeset is a named branch head.""" |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
1507 |
# i18n: "head" is a keyword |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1508 |
getargs(x, 0, 0, _(b"head takes no arguments")) |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
1509 |
hs = set() |
25620
5f87f2305ad0
revset: translate node directly with changelog in 'head'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25619
diff
changeset
|
1510 |
cl = repo.changelog |
42002
662ffdde5adf
branchcache: rename itervalues() to iterheads()
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
41698
diff
changeset
|
1511 |
for ls in repo.branchmap().iterheads(): |
25620
5f87f2305ad0
revset: translate node directly with changelog in 'head'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25619
diff
changeset
|
1512 |
hs.update(cl.rev(h) for h in ls) |
29408
785cadec2091
revset: make head() honor order of subset
Martin von Zweigbergk <martinvonz@google.com>
parents:
29407
diff
changeset
|
1513 |
return subset & baseset(hs) |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
1514 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
1515 |
|
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1516 |
@predicate(b'heads(set)', safe=True, takeorder=True) |
38479
72621094505f
revset: fix heads() order to always follow the input set (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
38275
diff
changeset
|
1517 |
def heads(repo, subset, x, order): |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45750
diff
changeset
|
1518 |
"""Members of set with no children in set.""" |
38479
72621094505f
revset: fix heads() order to always follow the input set (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
38275
diff
changeset
|
1519 |
# argument set should never define order |
72621094505f
revset: fix heads() order to always follow the input set (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
38275
diff
changeset
|
1520 |
if order == defineorder: |
72621094505f
revset: fix heads() order to always follow the input set (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
38275
diff
changeset
|
1521 |
order = followorder |
41274
4c6fdc7e2e7d
revset: inline parents computation to reuse the input argument
Boris Feld <boris.feld@octobus.net>
parents:
41222
diff
changeset
|
1522 |
inputset = getset(repo, fullreposet(repo), x, order=order) |
41276
5affe1583e1d
revset: use changelog's `headrevs` method to compute heads
Boris Feld <boris.feld@octobus.net>
parents:
41274
diff
changeset
|
1523 |
wdirparents = None |
46113
59fa3890d40a
node: import symbols explicitly
Joerg Sonnenberger <joerg@bec.de>
parents:
45942
diff
changeset
|
1524 |
if wdirrev in inputset: |
41276
5affe1583e1d
revset: use changelog's `headrevs` method to compute heads
Boris Feld <boris.feld@octobus.net>
parents:
41274
diff
changeset
|
1525 |
# a bit slower, but not common so good enough for now |
5affe1583e1d
revset: use changelog's `headrevs` method to compute heads
Boris Feld <boris.feld@octobus.net>
parents:
41274
diff
changeset
|
1526 |
wdirparents = [p.rev() for p in repo[None].parents()] |
5affe1583e1d
revset: use changelog's `headrevs` method to compute heads
Boris Feld <boris.feld@octobus.net>
parents:
41274
diff
changeset
|
1527 |
inputset = set(inputset) |
46113
59fa3890d40a
node: import symbols explicitly
Joerg Sonnenberger <joerg@bec.de>
parents:
45942
diff
changeset
|
1528 |
inputset.discard(wdirrev) |
41276
5affe1583e1d
revset: use changelog's `headrevs` method to compute heads
Boris Feld <boris.feld@octobus.net>
parents:
41274
diff
changeset
|
1529 |
heads = repo.changelog.headrevs(inputset) |
5affe1583e1d
revset: use changelog's `headrevs` method to compute heads
Boris Feld <boris.feld@octobus.net>
parents:
41274
diff
changeset
|
1530 |
if wdirparents is not None: |
5affe1583e1d
revset: use changelog's `headrevs` method to compute heads
Boris Feld <boris.feld@octobus.net>
parents:
41274
diff
changeset
|
1531 |
heads.difference_update(wdirparents) |
46113
59fa3890d40a
node: import symbols explicitly
Joerg Sonnenberger <joerg@bec.de>
parents:
45942
diff
changeset
|
1532 |
heads.add(wdirrev) |
41276
5affe1583e1d
revset: use changelog's `headrevs` method to compute heads
Boris Feld <boris.feld@octobus.net>
parents:
41274
diff
changeset
|
1533 |
heads = baseset(heads) |
5affe1583e1d
revset: use changelog's `headrevs` method to compute heads
Boris Feld <boris.feld@octobus.net>
parents:
41274
diff
changeset
|
1534 |
return subset & heads |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
1535 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
1536 |
|
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1537 |
@predicate(b'hidden()', safe=True) |
17390
74b44f25b4b1
revset: add hidden() revset
Patrick Mezard <patrick@mezard.eu>
parents:
17291
diff
changeset
|
1538 |
def hidden(repo, subset, x): |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45750
diff
changeset
|
1539 |
"""Hidden changesets.""" |
17390
74b44f25b4b1
revset: add hidden() revset
Patrick Mezard <patrick@mezard.eu>
parents:
17291
diff
changeset
|
1540 |
# i18n: "hidden" is a keyword |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1541 |
getargs(x, 0, 0, _(b"hidden takes no arguments")) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1542 |
hiddenrevs = repoview.filterrevs(repo, b'visible') |
20367
2ac278aab2b4
revset: added intersection to baseset class
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20366
diff
changeset
|
1543 |
return subset & hiddenrevs |
17390
74b44f25b4b1
revset: add hidden() revset
Patrick Mezard <patrick@mezard.eu>
parents:
17291
diff
changeset
|
1544 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
1545 |
|
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1546 |
@predicate(b'keyword(string)', safe=True, weight=10) |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
1547 |
def keyword(repo, subset, x): |
27584
fc7c8cac6a4b
revset: use decorator to register a function as revset predicate
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27517
diff
changeset
|
1548 |
"""Search commit message, user name, and names of changed files for |
14357 | 1549 |
string. The match is case-insensitive. |
30772
b1012cb1bec3
revset: point to 'grep' in the 'keyword' help for regex searches
Matt Harbison <matt_harbison@yahoo.com>
parents:
30754
diff
changeset
|
1550 |
|
b1012cb1bec3
revset: point to 'grep' in the 'keyword' help for regex searches
Matt Harbison <matt_harbison@yahoo.com>
parents:
30754
diff
changeset
|
1551 |
For a regular expression or case sensitive search of these fields, use |
b1012cb1bec3
revset: point to 'grep' in the 'keyword' help for regex searches
Matt Harbison <matt_harbison@yahoo.com>
parents:
30754
diff
changeset
|
1552 |
``grep(regex)``. |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
1553 |
""" |
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
1554 |
# i18n: "keyword" is a keyword |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1555 |
kw = encoding.lower(getstring(x, _(b"keyword requires a string"))) |
20447
abb91b74f758
revset: added lazyset implementation to keyword revset
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20446
diff
changeset
|
1556 |
|
abb91b74f758
revset: added lazyset implementation to keyword revset
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20446
diff
changeset
|
1557 |
def matches(r): |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
1558 |
c = repo[r] |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
1559 |
return any( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
1560 |
kw in encoding.lower(t) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
1561 |
for t in c.files() + [c.user(), c.description()] |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
1562 |
) |
20447
abb91b74f758
revset: added lazyset implementation to keyword revset
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20446
diff
changeset
|
1563 |
|
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1564 |
return subset.filter(matches, condrepr=(b'<keyword %r>', kw)) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1565 |
|
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1566 |
|
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1567 |
@predicate(b'limit(set[, n[, offset]])', safe=True, takeorder=True, weight=0) |
32801
348b491c0934
revset: fix order of first/last members in compound expression (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
32800
diff
changeset
|
1568 |
def limit(repo, subset, x, order): |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45750
diff
changeset
|
1569 |
"""First n members of set, defaulting to 1, starting from offset.""" |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1570 |
args = getargsdict(x, b'limit', b'set n offset') |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1571 |
if b'set' not in args: |
26637
179764469754
revset: port limit() to support keyword arguments
Yuya Nishihara <yuya@tcha.org>
parents:
26636
diff
changeset
|
1572 |
# i18n: "limit" is a keyword |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1573 |
raise error.ParseError(_(b"limit requires one to three arguments")) |
30802
5eb3e4568c94
revset: add default value to getinteger() helper
Yuya Nishihara <yuya@tcha.org>
parents:
30801
diff
changeset
|
1574 |
# i18n: "limit" is a keyword |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1575 |
lim = getinteger(args.get(b'n'), _(b"limit expects a number"), default=1) |
32799
b36ec65ea583
revset: reject negative number to select first/last n members
Yuya Nishihara <yuya@tcha.org>
parents:
32798
diff
changeset
|
1576 |
if lim < 0: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1577 |
raise error.ParseError(_(b"negative number to select")) |
30802
5eb3e4568c94
revset: add default value to getinteger() helper
Yuya Nishihara <yuya@tcha.org>
parents:
30801
diff
changeset
|
1578 |
# i18n: "limit" is a keyword |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1579 |
ofs = getinteger( |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1580 |
args.get(b'offset'), _(b"limit expects a number"), default=0 |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1581 |
) |
30801
67ee7874e53b
revset: factor out getinteger() helper
Yuya Nishihara <yuya@tcha.org>
parents:
30800
diff
changeset
|
1582 |
if ofs < 0: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1583 |
raise error.ParseError(_(b"negative offset")) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1584 |
os = getset(repo, fullreposet(repo), args[b'set']) |
32819
4710cc4dac99
smartset: extract method to slice abstractsmartset
Yuya Nishihara <yuya@tcha.org>
parents:
32801
diff
changeset
|
1585 |
ls = os.slice(ofs, ofs + lim) |
32801
348b491c0934
revset: fix order of first/last members in compound expression (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
32800
diff
changeset
|
1586 |
if order == followorder and lim > 1: |
348b491c0934
revset: fix order of first/last members in compound expression (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
32800
diff
changeset
|
1587 |
return subset & ls |
32800
3e6f9bff7e3f
revset: filter first/last members by __and__ operation
Yuya Nishihara <yuya@tcha.org>
parents:
32799
diff
changeset
|
1588 |
return ls & subset |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
1589 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
1590 |
|
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1591 |
@predicate(b'last(set, [n])', safe=True, takeorder=True) |
32801
348b491c0934
revset: fix order of first/last members in compound expression (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
32800
diff
changeset
|
1592 |
def last(repo, subset, x, order): |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45750
diff
changeset
|
1593 |
"""Last n members of set, defaulting to 1.""" |
14061
611d2f8a4ba2
revsets: add a last function
Matt Mackall <mpm@selenic.com>
parents:
14057
diff
changeset
|
1594 |
# i18n: "last" is a keyword |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1595 |
l = getargs(x, 1, 2, _(b"last requires one or two arguments")) |
30801
67ee7874e53b
revset: factor out getinteger() helper
Yuya Nishihara <yuya@tcha.org>
parents:
30800
diff
changeset
|
1596 |
lim = 1 |
67ee7874e53b
revset: factor out getinteger() helper
Yuya Nishihara <yuya@tcha.org>
parents:
30800
diff
changeset
|
1597 |
if len(l) == 2: |
14061
611d2f8a4ba2
revsets: add a last function
Matt Mackall <mpm@selenic.com>
parents:
14057
diff
changeset
|
1598 |
# i18n: "last" is a keyword |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1599 |
lim = getinteger(l[1], _(b"last expects a number")) |
32799
b36ec65ea583
revset: reject negative number to select first/last n members
Yuya Nishihara <yuya@tcha.org>
parents:
32798
diff
changeset
|
1600 |
if lim < 0: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1601 |
raise error.ParseError(_(b"negative number to select")) |
24115
ff24af40728b
revset: specify fullreposet without using spanset factory
Yuya Nishihara <yuya@tcha.org>
parents:
24114
diff
changeset
|
1602 |
os = getset(repo, fullreposet(repo), l[0]) |
20534
4849f574aa24
revset: changed last implementation to use lazy classes
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20527
diff
changeset
|
1603 |
os.reverse() |
32819
4710cc4dac99
smartset: extract method to slice abstractsmartset
Yuya Nishihara <yuya@tcha.org>
parents:
32801
diff
changeset
|
1604 |
ls = os.slice(0, lim) |
32801
348b491c0934
revset: fix order of first/last members in compound expression (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
32800
diff
changeset
|
1605 |
if order == followorder and lim > 1: |
348b491c0934
revset: fix order of first/last members in compound expression (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
32800
diff
changeset
|
1606 |
return subset & ls |
32800
3e6f9bff7e3f
revset: filter first/last members by __and__ operation
Yuya Nishihara <yuya@tcha.org>
parents:
32799
diff
changeset
|
1607 |
ls.reverse() |
3e6f9bff7e3f
revset: filter first/last members by __and__ operation
Yuya Nishihara <yuya@tcha.org>
parents:
32799
diff
changeset
|
1608 |
return ls & subset |
14061
611d2f8a4ba2
revsets: add a last function
Matt Mackall <mpm@selenic.com>
parents:
14057
diff
changeset
|
1609 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
1610 |
|
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1611 |
@predicate(b'max(set)', safe=True) |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
1612 |
def maxrev(repo, subset, x): |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45750
diff
changeset
|
1613 |
"""Changeset with highest revision number in set.""" |
24115
ff24af40728b
revset: specify fullreposet without using spanset factory
Yuya Nishihara <yuya@tcha.org>
parents:
24114
diff
changeset
|
1614 |
os = getset(repo, fullreposet(repo), x) |
26305
ade5c488d622
revset: remove existence check from min() and max()
Durham Goode <durham@fb.com>
parents:
26304
diff
changeset
|
1615 |
try: |
20754
f15ff553b762
revset: changed minrev and maxrev implementations to use ordered sets
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20753
diff
changeset
|
1616 |
m = os.max() |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
1617 |
if m in subset: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1618 |
return baseset([m], datarepr=(b'<max %r, %r>', subset, os)) |
26305
ade5c488d622
revset: remove existence check from min() and max()
Durham Goode <durham@fb.com>
parents:
26304
diff
changeset
|
1619 |
except ValueError: |
ade5c488d622
revset: remove existence check from min() and max()
Durham Goode <durham@fb.com>
parents:
26304
diff
changeset
|
1620 |
# os.max() throws a ValueError when the collection is empty. |
ade5c488d622
revset: remove existence check from min() and max()
Durham Goode <durham@fb.com>
parents:
26304
diff
changeset
|
1621 |
# Same as python's max(). |
ade5c488d622
revset: remove existence check from min() and max()
Durham Goode <durham@fb.com>
parents:
26304
diff
changeset
|
1622 |
pass |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1623 |
return baseset(datarepr=(b'<max %r, %r>', subset, os)) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1624 |
|
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1625 |
|
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1626 |
@predicate(b'merge()', safe=True) |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
1627 |
def merge(repo, subset, x): |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45750
diff
changeset
|
1628 |
"""Changeset is a merge changeset.""" |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
1629 |
# i18n: "merge" is a keyword |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1630 |
getargs(x, 0, 0, _(b"merge takes no arguments")) |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
1631 |
cl = repo.changelog |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
1632 |
|
42441
43c8f72184f4
revset: fix merge() to fall back to changectx API if wdir specified
Yuya Nishihara <yuya@tcha.org>
parents:
42440
diff
changeset
|
1633 |
def ismerge(r): |
43c8f72184f4
revset: fix merge() to fall back to changectx API if wdir specified
Yuya Nishihara <yuya@tcha.org>
parents:
42440
diff
changeset
|
1634 |
try: |
43c8f72184f4
revset: fix merge() to fall back to changectx API if wdir specified
Yuya Nishihara <yuya@tcha.org>
parents:
42440
diff
changeset
|
1635 |
return cl.parentrevs(r)[1] != nullrev |
43c8f72184f4
revset: fix merge() to fall back to changectx API if wdir specified
Yuya Nishihara <yuya@tcha.org>
parents:
42440
diff
changeset
|
1636 |
except error.WdirUnsupported: |
43c8f72184f4
revset: fix merge() to fall back to changectx API if wdir specified
Yuya Nishihara <yuya@tcha.org>
parents:
42440
diff
changeset
|
1637 |
return bool(repo[r].p2()) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
1638 |
|
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1639 |
return subset.filter(ismerge, condrepr=b'<merge>') |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1640 |
|
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1641 |
|
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1642 |
@predicate(b'branchpoint()', safe=True) |
17753
69d5078d760d
revsets: add branchpoint() function
Ivan Andrus <darthandrus@gmail.com>
parents:
17675
diff
changeset
|
1643 |
def branchpoint(repo, subset, x): |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45750
diff
changeset
|
1644 |
"""Changesets with more than one child.""" |
17753
69d5078d760d
revsets: add branchpoint() function
Ivan Andrus <darthandrus@gmail.com>
parents:
17675
diff
changeset
|
1645 |
# i18n: "branchpoint" is a keyword |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1646 |
getargs(x, 0, 0, _(b"branchpoint takes no arguments")) |
17753
69d5078d760d
revsets: add branchpoint() function
Ivan Andrus <darthandrus@gmail.com>
parents:
17675
diff
changeset
|
1647 |
cl = repo.changelog |
69d5078d760d
revsets: add branchpoint() function
Ivan Andrus <darthandrus@gmail.com>
parents:
17675
diff
changeset
|
1648 |
if not subset: |
22802
1fcd361efaf4
baseset: use default value instead of [] when possible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22801
diff
changeset
|
1649 |
return baseset() |
25549
f93ff3ab8d14
revset: mark spots that should use 'smartset.min()'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25548
diff
changeset
|
1650 |
# XXX this should be 'parentset.min()' assuming 'parentset' is a smartset |
f93ff3ab8d14
revset: mark spots that should use 'smartset.min()'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25548
diff
changeset
|
1651 |
# (and if it is not, it should.) |
17753
69d5078d760d
revsets: add branchpoint() function
Ivan Andrus <darthandrus@gmail.com>
parents:
17675
diff
changeset
|
1652 |
baserev = min(subset) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
1653 |
parentscount = [0] * (len(repo) - baserev) |
17785
ac5c9c8046f7
clfilter: use changelog to iterate over the repo in branchpoint
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17753
diff
changeset
|
1654 |
for r in cl.revs(start=baserev + 1): |
17753
69d5078d760d
revsets: add branchpoint() function
Ivan Andrus <darthandrus@gmail.com>
parents:
17675
diff
changeset
|
1655 |
for p in cl.parentrevs(r): |
69d5078d760d
revsets: add branchpoint() function
Ivan Andrus <darthandrus@gmail.com>
parents:
17675
diff
changeset
|
1656 |
if p >= baserev: |
69d5078d760d
revsets: add branchpoint() function
Ivan Andrus <darthandrus@gmail.com>
parents:
17675
diff
changeset
|
1657 |
parentscount[p - baserev] += 1 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
1658 |
return subset.filter( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1659 |
lambda r: parentscount[r - baserev] > 1, condrepr=b'<branchpoint>' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
1660 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
1661 |
|
17753
69d5078d760d
revsets: add branchpoint() function
Ivan Andrus <darthandrus@gmail.com>
parents:
17675
diff
changeset
|
1662 |
|
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1663 |
@predicate(b'min(set)', safe=True) |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
1664 |
def minrev(repo, subset, x): |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45750
diff
changeset
|
1665 |
"""Changeset with lowest revision number in set.""" |
24115
ff24af40728b
revset: specify fullreposet without using spanset factory
Yuya Nishihara <yuya@tcha.org>
parents:
24114
diff
changeset
|
1666 |
os = getset(repo, fullreposet(repo), x) |
26305
ade5c488d622
revset: remove existence check from min() and max()
Durham Goode <durham@fb.com>
parents:
26304
diff
changeset
|
1667 |
try: |
20754
f15ff553b762
revset: changed minrev and maxrev implementations to use ordered sets
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20753
diff
changeset
|
1668 |
m = os.min() |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
1669 |
if m in subset: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1670 |
return baseset([m], datarepr=(b'<min %r, %r>', subset, os)) |
26305
ade5c488d622
revset: remove existence check from min() and max()
Durham Goode <durham@fb.com>
parents:
26304
diff
changeset
|
1671 |
except ValueError: |
ade5c488d622
revset: remove existence check from min() and max()
Durham Goode <durham@fb.com>
parents:
26304
diff
changeset
|
1672 |
# os.min() throws a ValueError when the collection is empty. |
ade5c488d622
revset: remove existence check from min() and max()
Durham Goode <durham@fb.com>
parents:
26304
diff
changeset
|
1673 |
# Same as python's min(). |
ade5c488d622
revset: remove existence check from min() and max()
Durham Goode <durham@fb.com>
parents:
26304
diff
changeset
|
1674 |
pass |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1675 |
return baseset(datarepr=(b'<min %r, %r>', subset, os)) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1676 |
|
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1677 |
|
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1678 |
@predicate(b'modifies(pattern)', safe=True, weight=30) |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
1679 |
def modifies(repo, subset, x): |
27584
fc7c8cac6a4b
revset: use decorator to register a function as revset predicate
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27517
diff
changeset
|
1680 |
"""Changesets modifying files matched by pattern. |
20289
96be25f1da45
revset: add explanation about the pattern without explicit kind
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20288
diff
changeset
|
1681 |
|
96be25f1da45
revset: add explanation about the pattern without explicit kind
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20288
diff
changeset
|
1682 |
The pattern without explicit kind like ``glob:`` is expected to be |
96be25f1da45
revset: add explanation about the pattern without explicit kind
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20288
diff
changeset
|
1683 |
relative to the current directory and match against a file or a |
96be25f1da45
revset: add explanation about the pattern without explicit kind
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20288
diff
changeset
|
1684 |
directory. |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
1685 |
""" |
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
1686 |
# i18n: "modifies" is a keyword |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1687 |
pat = getstring(x, _(b"modifies requires a pattern")) |
45428
9b9071fabcd3
revset: remove indirect indexing of status tuple
Yuya Nishihara <yuya@tcha.org>
parents:
44856
diff
changeset
|
1688 |
return checkstatus(repo, subset, pat, 'modified') |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
1689 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
1690 |
|
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1691 |
@predicate(b'named(namespace)') |
23836
3fb61fcbc4e4
namespaces: add revset for 'named(namespace)'
Sean Farley <sean.michael.farley@gmail.com>
parents:
23833
diff
changeset
|
1692 |
def named(repo, subset, x): |
27584
fc7c8cac6a4b
revset: use decorator to register a function as revset predicate
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27517
diff
changeset
|
1693 |
"""The changesets in a given namespace. |
23836
3fb61fcbc4e4
namespaces: add revset for 'named(namespace)'
Sean Farley <sean.michael.farley@gmail.com>
parents:
23833
diff
changeset
|
1694 |
|
30784
5dd67f0993ce
help: eliminate duplicate text for revset string patterns
Matt Harbison <matt_harbison@yahoo.com>
parents:
30783
diff
changeset
|
1695 |
Pattern matching is supported for `namespace`. See |
30799
0b49449a01f4
help: use :hg: role and canonical name to point to revset string patterns
Yuya Nishihara <yuya@tcha.org>
parents:
30784
diff
changeset
|
1696 |
:hg:`help revisions.patterns`. |
23836
3fb61fcbc4e4
namespaces: add revset for 'named(namespace)'
Sean Farley <sean.michael.farley@gmail.com>
parents:
23833
diff
changeset
|
1697 |
""" |
3fb61fcbc4e4
namespaces: add revset for 'named(namespace)'
Sean Farley <sean.michael.farley@gmail.com>
parents:
23833
diff
changeset
|
1698 |
# i18n: "named" is a keyword |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1699 |
args = getargs(x, 1, 1, _(b'named requires a namespace argument')) |
23836
3fb61fcbc4e4
namespaces: add revset for 'named(namespace)'
Sean Farley <sean.michael.farley@gmail.com>
parents:
23833
diff
changeset
|
1700 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
1701 |
ns = getstring( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
1702 |
args[0], |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
1703 |
# i18n: "named" is a keyword |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1704 |
_(b'the argument to named must be a string'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
1705 |
) |
37084
f0b6fbea00cf
stringutil: bulk-replace call sites to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
37001
diff
changeset
|
1706 |
kind, pattern, matcher = stringutil.stringmatcher(ns) |
23836
3fb61fcbc4e4
namespaces: add revset for 'named(namespace)'
Sean Farley <sean.michael.farley@gmail.com>
parents:
23833
diff
changeset
|
1707 |
namespaces = set() |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1708 |
if kind == b'literal': |
23836
3fb61fcbc4e4
namespaces: add revset for 'named(namespace)'
Sean Farley <sean.michael.farley@gmail.com>
parents:
23833
diff
changeset
|
1709 |
if pattern not in repo.names: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1710 |
raise error.RepoLookupError( |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1711 |
_(b"namespace '%s' does not exist") % ns |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1712 |
) |
23836
3fb61fcbc4e4
namespaces: add revset for 'named(namespace)'
Sean Farley <sean.michael.farley@gmail.com>
parents:
23833
diff
changeset
|
1713 |
namespaces.add(repo.names[pattern]) |
3fb61fcbc4e4
namespaces: add revset for 'named(namespace)'
Sean Farley <sean.michael.farley@gmail.com>
parents:
23833
diff
changeset
|
1714 |
else: |
48913
f254fc73d956
global: bulk replace simple pycompat.iteritems(x) with x.items()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
48875
diff
changeset
|
1715 |
for name, ns in repo.names.items(): |
23836
3fb61fcbc4e4
namespaces: add revset for 'named(namespace)'
Sean Farley <sean.michael.farley@gmail.com>
parents:
23833
diff
changeset
|
1716 |
if matcher(name): |
3fb61fcbc4e4
namespaces: add revset for 'named(namespace)'
Sean Farley <sean.michael.farley@gmail.com>
parents:
23833
diff
changeset
|
1717 |
namespaces.add(ns) |
3fb61fcbc4e4
namespaces: add revset for 'named(namespace)'
Sean Farley <sean.michael.farley@gmail.com>
parents:
23833
diff
changeset
|
1718 |
|
3fb61fcbc4e4
namespaces: add revset for 'named(namespace)'
Sean Farley <sean.michael.farley@gmail.com>
parents:
23833
diff
changeset
|
1719 |
names = set() |
3fb61fcbc4e4
namespaces: add revset for 'named(namespace)'
Sean Farley <sean.michael.farley@gmail.com>
parents:
23833
diff
changeset
|
1720 |
for ns in namespaces: |
3fb61fcbc4e4
namespaces: add revset for 'named(namespace)'
Sean Farley <sean.michael.farley@gmail.com>
parents:
23833
diff
changeset
|
1721 |
for name in ns.listnames(repo): |
24151
38824c53c2f1
revset: mask specific names for named() predicate
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24008
diff
changeset
|
1722 |
if name not in ns.deprecated: |
38824c53c2f1
revset: mask specific names for named() predicate
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
24008
diff
changeset
|
1723 |
names.update(repo[n].rev() for n in ns.nodes(repo, name)) |
23836
3fb61fcbc4e4
namespaces: add revset for 'named(namespace)'
Sean Farley <sean.michael.farley@gmail.com>
parents:
23833
diff
changeset
|
1724 |
|
46113
59fa3890d40a
node: import symbols explicitly
Joerg Sonnenberger <joerg@bec.de>
parents:
45942
diff
changeset
|
1725 |
names -= {nullrev} |
23836
3fb61fcbc4e4
namespaces: add revset for 'named(namespace)'
Sean Farley <sean.michael.farley@gmail.com>
parents:
23833
diff
changeset
|
1726 |
return subset & names |
3fb61fcbc4e4
namespaces: add revset for 'named(namespace)'
Sean Farley <sean.michael.farley@gmail.com>
parents:
23833
diff
changeset
|
1727 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
1728 |
|
46809
56d441256e82
revset: introduce a `nodefromfile` revset
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46720
diff
changeset
|
1729 |
def _node(repo, n): |
56d441256e82
revset: introduce a `nodefromfile` revset
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46720
diff
changeset
|
1730 |
"""process a node input""" |
56d441256e82
revset: introduce a `nodefromfile` revset
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46720
diff
changeset
|
1731 |
rn = None |
47041
a407fe56d6e8
core: don't hard-code hex node lengths
Joerg Sonnenberger <joerg@bec.de>
parents:
46966
diff
changeset
|
1732 |
if len(n) == 2 * repo.nodeconstants.nodelen: |
24904
b5c227f3e461
revset: id() called with 40-byte strings should give the same results as for short strings
Alexander Drozdov <al.drozdov@gmail.com>
parents:
24777
diff
changeset
|
1733 |
try: |
46113
59fa3890d40a
node: import symbols explicitly
Joerg Sonnenberger <joerg@bec.de>
parents:
45942
diff
changeset
|
1734 |
rn = repo.changelog.rev(bin(n)) |
32661
a3064fe3e495
revset: add support for integer and hex wdir identifiers
Yuya Nishihara <yuya@tcha.org>
parents:
32442
diff
changeset
|
1735 |
except error.WdirUnsupported: |
46113
59fa3890d40a
node: import symbols explicitly
Joerg Sonnenberger <joerg@bec.de>
parents:
45942
diff
changeset
|
1736 |
rn = wdirrev |
49248
63fd0282ad40
node: stop converting binascii.Error to TypeError in bin()
Manuel Jacob <me@manueljacob.de>
parents:
48913
diff
changeset
|
1737 |
except (binascii.Error, LookupError): |
24904
b5c227f3e461
revset: id() called with 40-byte strings should give the same results as for short strings
Alexander Drozdov <al.drozdov@gmail.com>
parents:
24777
diff
changeset
|
1738 |
rn = None |
12716
c7e619e30ba3
revset: add id() and rev() to allow explicitly referring to changes by hash or rev
Augie Fackler <durin42@gmail.com>
parents:
12715
diff
changeset
|
1739 |
else: |
32684
af854b1b36f8
revlog: add support for partial matching of wdir node id
Yuya Nishihara <yuya@tcha.org>
parents:
32683
diff
changeset
|
1740 |
try: |
37867
0a79fb64118e
revset: use resolvehexnodeidprefix() in id() predicate (BC)
Martin von Zweigbergk <martinvonz@google.com>
parents:
37866
diff
changeset
|
1741 |
pm = scmutil.resolvehexnodeidprefix(repo, n) |
32684
af854b1b36f8
revlog: add support for partial matching of wdir node id
Yuya Nishihara <yuya@tcha.org>
parents:
32683
diff
changeset
|
1742 |
if pm is not None: |
32661
a3064fe3e495
revset: add support for integer and hex wdir identifiers
Yuya Nishihara <yuya@tcha.org>
parents:
32442
diff
changeset
|
1743 |
rn = repo.changelog.rev(pm) |
37866
37e7ae332e90
revset: make id() an empty set for ambiguous nodeid (BC)
Martin von Zweigbergk <martinvonz@google.com>
parents:
37674
diff
changeset
|
1744 |
except LookupError: |
37e7ae332e90
revset: make id() an empty set for ambiguous nodeid (BC)
Martin von Zweigbergk <martinvonz@google.com>
parents:
37674
diff
changeset
|
1745 |
pass |
32684
af854b1b36f8
revlog: add support for partial matching of wdir node id
Yuya Nishihara <yuya@tcha.org>
parents:
32683
diff
changeset
|
1746 |
except error.WdirUnsupported: |
46113
59fa3890d40a
node: import symbols explicitly
Joerg Sonnenberger <joerg@bec.de>
parents:
45942
diff
changeset
|
1747 |
rn = wdirrev |
46809
56d441256e82
revset: introduce a `nodefromfile` revset
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46720
diff
changeset
|
1748 |
return rn |
56d441256e82
revset: introduce a `nodefromfile` revset
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46720
diff
changeset
|
1749 |
|
56d441256e82
revset: introduce a `nodefromfile` revset
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46720
diff
changeset
|
1750 |
|
56d441256e82
revset: introduce a `nodefromfile` revset
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46720
diff
changeset
|
1751 |
@predicate(b'id(string)', safe=True) |
56d441256e82
revset: introduce a `nodefromfile` revset
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46720
diff
changeset
|
1752 |
def node_(repo, subset, x): |
56d441256e82
revset: introduce a `nodefromfile` revset
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46720
diff
changeset
|
1753 |
"""Revision non-ambiguously specified by the given hex string prefix.""" |
56d441256e82
revset: introduce a `nodefromfile` revset
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46720
diff
changeset
|
1754 |
# i18n: "id" is a keyword |
56d441256e82
revset: introduce a `nodefromfile` revset
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46720
diff
changeset
|
1755 |
l = getargs(x, 1, 1, _(b"id requires one argument")) |
56d441256e82
revset: introduce a `nodefromfile` revset
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46720
diff
changeset
|
1756 |
# i18n: "id" is a keyword |
56d441256e82
revset: introduce a `nodefromfile` revset
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46720
diff
changeset
|
1757 |
n = getstring(l[0], _(b"id requires a string")) |
56d441256e82
revset: introduce a `nodefromfile` revset
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46720
diff
changeset
|
1758 |
rn = _node(repo, n) |
16735
47b8ec0eb7fb
revset: fix traceback for bogus revisions in id(rev)
Matt Harbison <matt_harbison@yahoo.com>
parents:
16640
diff
changeset
|
1759 |
|
23005
9bfe68357c01
revset-node: speedup by a few hundred fold
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23004
diff
changeset
|
1760 |
if rn is None: |
9bfe68357c01
revset-node: speedup by a few hundred fold
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23004
diff
changeset
|
1761 |
return baseset() |
9bfe68357c01
revset-node: speedup by a few hundred fold
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23004
diff
changeset
|
1762 |
result = baseset([rn]) |
9bfe68357c01
revset-node: speedup by a few hundred fold
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23004
diff
changeset
|
1763 |
return result & subset |
12716
c7e619e30ba3
revset: add id() and rev() to allow explicitly referring to changes by hash or rev
Augie Fackler <durin42@gmail.com>
parents:
12715
diff
changeset
|
1764 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
1765 |
|
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1766 |
@predicate(b'none()', safe=True) |
38275
f1d55ae2c5c8
revsets: define a none() revset
Martin von Zweigbergk <martinvonz@google.com>
parents:
38239
diff
changeset
|
1767 |
def none(repo, subset, x): |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45750
diff
changeset
|
1768 |
"""No changesets.""" |
38275
f1d55ae2c5c8
revsets: define a none() revset
Martin von Zweigbergk <martinvonz@google.com>
parents:
38239
diff
changeset
|
1769 |
# i18n: "none" is a keyword |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1770 |
getargs(x, 0, 0, _(b"none takes no arguments")) |
38275
f1d55ae2c5c8
revsets: define a none() revset
Martin von Zweigbergk <martinvonz@google.com>
parents:
38239
diff
changeset
|
1771 |
return baseset() |
f1d55ae2c5c8
revsets: define a none() revset
Martin von Zweigbergk <martinvonz@google.com>
parents:
38239
diff
changeset
|
1772 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
1773 |
|
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1774 |
@predicate(b'obsolete()', safe=True) |
17170
63a4a3871607
revset: add an `obsolete` symbol
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17102
diff
changeset
|
1775 |
def obsolete(repo, subset, x): |
44698
1ac74f653fa5
revset: mark `obsolete()` experimental
Matt Harbison <matt_harbison@yahoo.com>
parents:
44691
diff
changeset
|
1776 |
"""Mutable changeset with a newer version. (EXPERIMENTAL)""" |
17259
e96ad092fb18
i18n: add/relocate "i18n keyword" comments for i18n messages in revset.py
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
17258
diff
changeset
|
1777 |
# i18n: "obsolete" is a keyword |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1778 |
getargs(x, 0, 0, _(b"obsolete takes no arguments")) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1779 |
obsoletes = obsmod.getrevs(repo, b'obsolete') |
20367
2ac278aab2b4
revset: added intersection to baseset class
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20366
diff
changeset
|
1780 |
return subset & obsoletes |
17170
63a4a3871607
revset: add an `obsolete` symbol
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17102
diff
changeset
|
1781 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
1782 |
|
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1783 |
@predicate(b'only(set, [set])', safe=True) |
23466
d5b1a452cc32
revset: move 'only' so that functions are sorted alphabetically
Yuya Nishihara <yuya@tcha.org>
parents:
23426
diff
changeset
|
1784 |
def only(repo, subset, x): |
27584
fc7c8cac6a4b
revset: use decorator to register a function as revset predicate
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27517
diff
changeset
|
1785 |
"""Changesets that are ancestors of the first set that are not ancestors |
23466
d5b1a452cc32
revset: move 'only' so that functions are sorted alphabetically
Yuya Nishihara <yuya@tcha.org>
parents:
23426
diff
changeset
|
1786 |
of any other head in the repo. If a second set is specified, the result |
d5b1a452cc32
revset: move 'only' so that functions are sorted alphabetically
Yuya Nishihara <yuya@tcha.org>
parents:
23426
diff
changeset
|
1787 |
is ancestors of the first set that are not ancestors of the second set |
d5b1a452cc32
revset: move 'only' so that functions are sorted alphabetically
Yuya Nishihara <yuya@tcha.org>
parents:
23426
diff
changeset
|
1788 |
(i.e. ::<set1> - ::<set2>). |
d5b1a452cc32
revset: move 'only' so that functions are sorted alphabetically
Yuya Nishihara <yuya@tcha.org>
parents:
23426
diff
changeset
|
1789 |
""" |
d5b1a452cc32
revset: move 'only' so that functions are sorted alphabetically
Yuya Nishihara <yuya@tcha.org>
parents:
23426
diff
changeset
|
1790 |
cl = repo.changelog |
d5b1a452cc32
revset: move 'only' so that functions are sorted alphabetically
Yuya Nishihara <yuya@tcha.org>
parents:
23426
diff
changeset
|
1791 |
# i18n: "only" is a keyword |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1792 |
args = getargs(x, 1, 2, _(b'only takes one or two arguments')) |
24115
ff24af40728b
revset: specify fullreposet without using spanset factory
Yuya Nishihara <yuya@tcha.org>
parents:
24114
diff
changeset
|
1793 |
include = getset(repo, fullreposet(repo), args[0]) |
23466
d5b1a452cc32
revset: move 'only' so that functions are sorted alphabetically
Yuya Nishihara <yuya@tcha.org>
parents:
23426
diff
changeset
|
1794 |
if len(args) == 1: |
d5b1a452cc32
revset: move 'only' so that functions are sorted alphabetically
Yuya Nishihara <yuya@tcha.org>
parents:
23426
diff
changeset
|
1795 |
if not include: |
d5b1a452cc32
revset: move 'only' so that functions are sorted alphabetically
Yuya Nishihara <yuya@tcha.org>
parents:
23426
diff
changeset
|
1796 |
return baseset() |
d5b1a452cc32
revset: move 'only' so that functions are sorted alphabetically
Yuya Nishihara <yuya@tcha.org>
parents:
23426
diff
changeset
|
1797 |
|
32903
27932a76a88d
dagop: split module hosting DAG-related algorithms from revset
Yuya Nishihara <yuya@tcha.org>
parents:
32885
diff
changeset
|
1798 |
descendants = set(dagop.revdescendants(repo, include, False)) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
1799 |
exclude = [ |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
1800 |
rev |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
1801 |
for rev in cl.headrevs() |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
1802 |
if not rev in descendants and not rev in include |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
1803 |
] |
23466
d5b1a452cc32
revset: move 'only' so that functions are sorted alphabetically
Yuya Nishihara <yuya@tcha.org>
parents:
23426
diff
changeset
|
1804 |
else: |
24115
ff24af40728b
revset: specify fullreposet without using spanset factory
Yuya Nishihara <yuya@tcha.org>
parents:
24114
diff
changeset
|
1805 |
exclude = getset(repo, fullreposet(repo), args[1]) |
23466
d5b1a452cc32
revset: move 'only' so that functions are sorted alphabetically
Yuya Nishihara <yuya@tcha.org>
parents:
23426
diff
changeset
|
1806 |
|
d5b1a452cc32
revset: move 'only' so that functions are sorted alphabetically
Yuya Nishihara <yuya@tcha.org>
parents:
23426
diff
changeset
|
1807 |
results = set(cl.findmissingrevs(common=exclude, heads=include)) |
25554
94441df6206c
revset: mark spots that use 'set' instead of 'smartset'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25553
diff
changeset
|
1808 |
# XXX we should turn this into a baseset instead of a set, smartset may do |
30332
318a24b52eeb
spelling: fixes of non-dictionary words
Mads Kiilerich <madski@unity3d.com>
parents:
30227
diff
changeset
|
1809 |
# some optimizations from the fact this is a baseset. |
23466
d5b1a452cc32
revset: move 'only' so that functions are sorted alphabetically
Yuya Nishihara <yuya@tcha.org>
parents:
23426
diff
changeset
|
1810 |
return subset & results |
d5b1a452cc32
revset: move 'only' so that functions are sorted alphabetically
Yuya Nishihara <yuya@tcha.org>
parents:
23426
diff
changeset
|
1811 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
1812 |
|
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1813 |
@predicate(b'origin([set])', safe=True) |
17185
2c7c4824969e
revset: add origin() predicate
Matt Harbison <matt_harbison@yahoo.com>
parents:
17173
diff
changeset
|
1814 |
def origin(repo, subset, x): |
27584
fc7c8cac6a4b
revset: use decorator to register a function as revset predicate
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27517
diff
changeset
|
1815 |
""" |
17185
2c7c4824969e
revset: add origin() predicate
Matt Harbison <matt_harbison@yahoo.com>
parents:
17173
diff
changeset
|
1816 |
Changesets that were specified as a source for the grafts, transplants or |
2c7c4824969e
revset: add origin() predicate
Matt Harbison <matt_harbison@yahoo.com>
parents:
17173
diff
changeset
|
1817 |
rebases that created the given revisions. Omitting the optional set is the |
2c7c4824969e
revset: add origin() predicate
Matt Harbison <matt_harbison@yahoo.com>
parents:
17173
diff
changeset
|
1818 |
same as passing all(). If a changeset created by these operations is itself |
2c7c4824969e
revset: add origin() predicate
Matt Harbison <matt_harbison@yahoo.com>
parents:
17173
diff
changeset
|
1819 |
specified as a source for one of these operations, only the source changeset |
2c7c4824969e
revset: add origin() predicate
Matt Harbison <matt_harbison@yahoo.com>
parents:
17173
diff
changeset
|
1820 |
for the first operation is selected. |
2c7c4824969e
revset: add origin() predicate
Matt Harbison <matt_harbison@yahoo.com>
parents:
17173
diff
changeset
|
1821 |
""" |
2c7c4824969e
revset: add origin() predicate
Matt Harbison <matt_harbison@yahoo.com>
parents:
17173
diff
changeset
|
1822 |
if x is not None: |
24115
ff24af40728b
revset: specify fullreposet without using spanset factory
Yuya Nishihara <yuya@tcha.org>
parents:
24114
diff
changeset
|
1823 |
dests = getset(repo, fullreposet(repo), x) |
17185
2c7c4824969e
revset: add origin() predicate
Matt Harbison <matt_harbison@yahoo.com>
parents:
17173
diff
changeset
|
1824 |
else: |
24201
77ef059b3317
revset: drop unnecessary calls of getall() with empty argument
Yuya Nishihara <yuya@tcha.org>
parents:
24163
diff
changeset
|
1825 |
dests = fullreposet(repo) |
17185
2c7c4824969e
revset: add origin() predicate
Matt Harbison <matt_harbison@yahoo.com>
parents:
17173
diff
changeset
|
1826 |
|
2c7c4824969e
revset: add origin() predicate
Matt Harbison <matt_harbison@yahoo.com>
parents:
17173
diff
changeset
|
1827 |
def _firstsrc(rev): |
2c7c4824969e
revset: add origin() predicate
Matt Harbison <matt_harbison@yahoo.com>
parents:
17173
diff
changeset
|
1828 |
src = _getrevsource(repo, rev) |
2c7c4824969e
revset: add origin() predicate
Matt Harbison <matt_harbison@yahoo.com>
parents:
17173
diff
changeset
|
1829 |
if src is None: |
2c7c4824969e
revset: add origin() predicate
Matt Harbison <matt_harbison@yahoo.com>
parents:
17173
diff
changeset
|
1830 |
return None |
2c7c4824969e
revset: add origin() predicate
Matt Harbison <matt_harbison@yahoo.com>
parents:
17173
diff
changeset
|
1831 |
|
2c7c4824969e
revset: add origin() predicate
Matt Harbison <matt_harbison@yahoo.com>
parents:
17173
diff
changeset
|
1832 |
while True: |
2c7c4824969e
revset: add origin() predicate
Matt Harbison <matt_harbison@yahoo.com>
parents:
17173
diff
changeset
|
1833 |
prev = _getrevsource(repo, src) |
2c7c4824969e
revset: add origin() predicate
Matt Harbison <matt_harbison@yahoo.com>
parents:
17173
diff
changeset
|
1834 |
|
2c7c4824969e
revset: add origin() predicate
Matt Harbison <matt_harbison@yahoo.com>
parents:
17173
diff
changeset
|
1835 |
if prev is None: |
2c7c4824969e
revset: add origin() predicate
Matt Harbison <matt_harbison@yahoo.com>
parents:
17173
diff
changeset
|
1836 |
return src |
2c7c4824969e
revset: add origin() predicate
Matt Harbison <matt_harbison@yahoo.com>
parents:
17173
diff
changeset
|
1837 |
src = prev |
2c7c4824969e
revset: add origin() predicate
Matt Harbison <matt_harbison@yahoo.com>
parents:
17173
diff
changeset
|
1838 |
|
32291
bd872f64a8ba
cleanup: use set literals
Martin von Zweigbergk <martinvonz@google.com>
parents:
32085
diff
changeset
|
1839 |
o = {_firstsrc(r) for r in dests} |
bd872f64a8ba
cleanup: use set literals
Martin von Zweigbergk <martinvonz@google.com>
parents:
32085
diff
changeset
|
1840 |
o -= {None} |
25554
94441df6206c
revset: mark spots that use 'set' instead of 'smartset'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25553
diff
changeset
|
1841 |
# XXX we should turn this into a baseset instead of a set, smartset may do |
30332
318a24b52eeb
spelling: fixes of non-dictionary words
Mads Kiilerich <madski@unity3d.com>
parents:
30227
diff
changeset
|
1842 |
# some optimizations from the fact this is a baseset. |
22536
8040a44aab1c
revset: use `subset &` in `origin`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22535
diff
changeset
|
1843 |
return subset & o |
17185
2c7c4824969e
revset: add origin() predicate
Matt Harbison <matt_harbison@yahoo.com>
parents:
17173
diff
changeset
|
1844 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
1845 |
|
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1846 |
@predicate(b'outgoing([path])', safe=False, weight=10) |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
1847 |
def outgoing(repo, subset, x): |
27584
fc7c8cac6a4b
revset: use decorator to register a function as revset predicate
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27517
diff
changeset
|
1848 |
"""Changesets not found in the specified destination repository, or the |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
1849 |
default push location. |
47275
ba673c821b9d
revset: document the `outgoing` behavior if the path resolve to multiple urls
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47041
diff
changeset
|
1850 |
|
ba673c821b9d
revset: document the `outgoing` behavior if the path resolve to multiple urls
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47041
diff
changeset
|
1851 |
If the location resolve to multiple repositories, the union of all |
ba673c821b9d
revset: document the `outgoing` behavior if the path resolve to multiple urls
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
47041
diff
changeset
|
1852 |
outgoing changeset will be used. |
12821
165079e564f0
revsets: generate predicate help dynamically
Patrick Mezard <pmezard@gmail.com>
parents:
12815
diff
changeset
|
1853 |
""" |
24722
02a5618e2fbf
revset: don't import discovery at module level
Gregory Szorc <gregory.szorc@gmail.com>
parents:
24708
diff
changeset
|
1854 |
# Avoid cycles. |
25971
e9cd028f2dff
revset: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25929
diff
changeset
|
1855 |
from . import ( |
e9cd028f2dff
revset: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25929
diff
changeset
|
1856 |
discovery, |
e9cd028f2dff
revset: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25929
diff
changeset
|
1857 |
hg, |
e9cd028f2dff
revset: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25929
diff
changeset
|
1858 |
) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
1859 |
|
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
1860 |
# i18n: "outgoing" is a keyword |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1861 |
l = getargs(x, 0, 1, _(b"outgoing takes one or no arguments")) |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
1862 |
# i18n: "outgoing" is a keyword |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1863 |
dest = ( |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1864 |
l and getstring(l[0], _(b"outgoing requires a repository path")) or b'' |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1865 |
) |
46933
9519312ecd81
outgoing: use `get_push_paths` in the revset too
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46908
diff
changeset
|
1866 |
if dest: |
9519312ecd81
outgoing: use `get_push_paths` in the revset too
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46908
diff
changeset
|
1867 |
dests = [dest] |
9519312ecd81
outgoing: use `get_push_paths` in the revset too
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46908
diff
changeset
|
1868 |
else: |
9519312ecd81
outgoing: use `get_push_paths` in the revset too
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46908
diff
changeset
|
1869 |
dests = [] |
9519312ecd81
outgoing: use `get_push_paths` in the revset too
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46908
diff
changeset
|
1870 |
missing = set() |
9519312ecd81
outgoing: use `get_push_paths` in the revset too
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46908
diff
changeset
|
1871 |
for path in urlutil.get_push_paths(repo, repo.ui, dests): |
9519312ecd81
outgoing: use `get_push_paths` in the revset too
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46908
diff
changeset
|
1872 |
branches = path.branch, [] |
9519312ecd81
outgoing: use `get_push_paths` in the revset too
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46908
diff
changeset
|
1873 |
|
9519312ecd81
outgoing: use `get_push_paths` in the revset too
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46908
diff
changeset
|
1874 |
revs, checkout = hg.addbranchrevs(repo, repo, branches, []) |
9519312ecd81
outgoing: use `get_push_paths` in the revset too
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46908
diff
changeset
|
1875 |
if revs: |
9519312ecd81
outgoing: use `get_push_paths` in the revset too
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46908
diff
changeset
|
1876 |
revs = [repo.lookup(rev) for rev in revs] |
49711
e2a31b0bc5d0
path: pass `path` to `peer` in the `outgoing` revset
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49702
diff
changeset
|
1877 |
other = hg.peer(repo, {}, path) |
46933
9519312ecd81
outgoing: use `get_push_paths` in the revset too
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46908
diff
changeset
|
1878 |
try: |
47437
7a430116f639
ui: add a context manager for silencing the ui (pushbuffer+popbuffer)
Martin von Zweigbergk <martinvonz@google.com>
parents:
47275
diff
changeset
|
1879 |
with repo.ui.silent(): |
7a430116f639
ui: add a context manager for silencing the ui (pushbuffer+popbuffer)
Martin von Zweigbergk <martinvonz@google.com>
parents:
47275
diff
changeset
|
1880 |
outgoing = discovery.findcommonoutgoing( |
7a430116f639
ui: add a context manager for silencing the ui (pushbuffer+popbuffer)
Martin von Zweigbergk <martinvonz@google.com>
parents:
47275
diff
changeset
|
1881 |
repo, other, onlyheads=revs |
7a430116f639
ui: add a context manager for silencing the ui (pushbuffer+popbuffer)
Martin von Zweigbergk <martinvonz@google.com>
parents:
47275
diff
changeset
|
1882 |
) |
46933
9519312ecd81
outgoing: use `get_push_paths` in the revset too
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46908
diff
changeset
|
1883 |
finally: |
9519312ecd81
outgoing: use `get_push_paths` in the revset too
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46908
diff
changeset
|
1884 |
other.close() |
9519312ecd81
outgoing: use `get_push_paths` in the revset too
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46908
diff
changeset
|
1885 |
missing.update(outgoing.missing) |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
1886 |
cl = repo.changelog |
46933
9519312ecd81
outgoing: use `get_push_paths` in the revset too
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46908
diff
changeset
|
1887 |
o = {cl.rev(r) for r in missing} |
22529
5c53d7888aef
revset: use `subset &` in `outgoing`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22528
diff
changeset
|
1888 |
return subset & o |
12716
c7e619e30ba3
revset: add id() and rev() to allow explicitly referring to changes by hash or rev
Augie Fackler <durin42@gmail.com>
parents:
12715
diff
changeset
|
1889 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
1890 |
|
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1891 |
@predicate(b'p1([set])', safe=True) |
11275 | 1892 |
def p1(repo, subset, x): |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45750
diff
changeset
|
1893 |
"""First parent of changesets in set, or the working directory.""" |
12928
a5f7f1e9340e
revsets: let p1() and p2() return parents of working dir
Kevin Bullock <kbullock@ringworld.org>
parents:
12859
diff
changeset
|
1894 |
if x is None: |
13878
a8d13ee0ce68
misc: replace .parents()[0] with p1()
Matt Mackall <mpm@selenic.com>
parents:
13873
diff
changeset
|
1895 |
p = repo[x].p1().rev() |
22538
a428db9ab61d
revset: use `subset &` in bare `p1()`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22537
diff
changeset
|
1896 |
if p >= 0: |
a428db9ab61d
revset: use `subset &` in bare `p1()`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22537
diff
changeset
|
1897 |
return subset & baseset([p]) |
22802
1fcd361efaf4
baseset: use default value instead of [] when possible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22801
diff
changeset
|
1898 |
return baseset() |
12928
a5f7f1e9340e
revsets: let p1() and p2() return parents of working dir
Kevin Bullock <kbullock@ringworld.org>
parents:
12859
diff
changeset
|
1899 |
|
11275 | 1900 |
ps = set() |
1901 |
cl = repo.changelog |
|
24115
ff24af40728b
revset: specify fullreposet without using spanset factory
Yuya Nishihara <yuya@tcha.org>
parents:
24114
diff
changeset
|
1902 |
for r in getset(repo, fullreposet(repo), x): |
32404
e8c043375b53
revset: make `hg log -r 'wdir()^'` work (issue4905)
Pulkit Goyal <7895pulkit@gmail.com>
parents:
32291
diff
changeset
|
1903 |
try: |
e8c043375b53
revset: make `hg log -r 'wdir()^'` work (issue4905)
Pulkit Goyal <7895pulkit@gmail.com>
parents:
32291
diff
changeset
|
1904 |
ps.add(cl.parentrevs(r)[0]) |
e8c043375b53
revset: make `hg log -r 'wdir()^'` work (issue4905)
Pulkit Goyal <7895pulkit@gmail.com>
parents:
32291
diff
changeset
|
1905 |
except error.WdirUnsupported: |
41397
0bd56c291359
cleanup: use p1() and p2() instead of parents()[0] and parents()[1]
Martin von Zweigbergk <martinvonz@google.com>
parents:
41388
diff
changeset
|
1906 |
ps.add(repo[r].p1().rev()) |
46113
59fa3890d40a
node: import symbols explicitly
Joerg Sonnenberger <joerg@bec.de>
parents:
45942
diff
changeset
|
1907 |
ps -= {nullrev} |
25554
94441df6206c
revset: mark spots that use 'set' instead of 'smartset'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25553
diff
changeset
|
1908 |
# XXX we should turn this into a baseset instead of a set, smartset may do |
30332
318a24b52eeb
spelling: fixes of non-dictionary words
Mads Kiilerich <madski@unity3d.com>
parents:
30227
diff
changeset
|
1909 |
# some optimizations from the fact this is a baseset. |
20367
2ac278aab2b4
revset: added intersection to baseset class
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20366
diff
changeset
|
1910 |
return subset & ps |
11275 | 1911 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
1912 |
|
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1913 |
@predicate(b'p2([set])', safe=True) |
11275 | 1914 |
def p2(repo, subset, x): |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45750
diff
changeset
|
1915 |
"""Second parent of changesets in set, or the working directory.""" |
12928
a5f7f1e9340e
revsets: let p1() and p2() return parents of working dir
Kevin Bullock <kbullock@ringworld.org>
parents:
12859
diff
changeset
|
1916 |
if x is None: |
a5f7f1e9340e
revsets: let p1() and p2() return parents of working dir
Kevin Bullock <kbullock@ringworld.org>
parents:
12859
diff
changeset
|
1917 |
ps = repo[x].parents() |
a5f7f1e9340e
revsets: let p1() and p2() return parents of working dir
Kevin Bullock <kbullock@ringworld.org>
parents:
12859
diff
changeset
|
1918 |
try: |
12935
98b79c892768
revset: fix p1, p2 and parents in dirstate case (a5f7f1e9340e)
Patrick Mezard <pmezard@gmail.com>
parents:
12929
diff
changeset
|
1919 |
p = ps[1].rev() |
22539
6f434ef54222
revset: use `subset &` in bare `p2()`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22538
diff
changeset
|
1920 |
if p >= 0: |
6f434ef54222
revset: use `subset &` in bare `p2()`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22538
diff
changeset
|
1921 |
return subset & baseset([p]) |
22802
1fcd361efaf4
baseset: use default value instead of [] when possible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22801
diff
changeset
|
1922 |
return baseset() |
12928
a5f7f1e9340e
revsets: let p1() and p2() return parents of working dir
Kevin Bullock <kbullock@ringworld.org>
parents:
12859
diff
changeset
|
1923 |
except IndexError: |
22802
1fcd361efaf4
baseset: use default value instead of [] when possible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22801
diff
changeset
|
1924 |
return baseset() |
12928
a5f7f1e9340e
revsets: let p1() and p2() return parents of working dir
Kevin Bullock <kbullock@ringworld.org>
parents:
12859
diff
changeset
|
1925 |
|
11275 | 1926 |
ps = set() |
1927 |
cl = repo.changelog |
|
24115
ff24af40728b
revset: specify fullreposet without using spanset factory
Yuya Nishihara <yuya@tcha.org>
parents:
24114
diff
changeset
|
1928 |
for r in getset(repo, fullreposet(repo), x): |
32440
c8fb2a82b5f9
revset: add support for p2(wdir()) to get second parent of working directory
Pulkit Goyal <7895pulkit@gmail.com>
parents:
32439
diff
changeset
|
1929 |
try: |
c8fb2a82b5f9
revset: add support for p2(wdir()) to get second parent of working directory
Pulkit Goyal <7895pulkit@gmail.com>
parents:
32439
diff
changeset
|
1930 |
ps.add(cl.parentrevs(r)[1]) |
c8fb2a82b5f9
revset: add support for p2(wdir()) to get second parent of working directory
Pulkit Goyal <7895pulkit@gmail.com>
parents:
32439
diff
changeset
|
1931 |
except error.WdirUnsupported: |
c8fb2a82b5f9
revset: add support for p2(wdir()) to get second parent of working directory
Pulkit Goyal <7895pulkit@gmail.com>
parents:
32439
diff
changeset
|
1932 |
parents = repo[r].parents() |
c8fb2a82b5f9
revset: add support for p2(wdir()) to get second parent of working directory
Pulkit Goyal <7895pulkit@gmail.com>
parents:
32439
diff
changeset
|
1933 |
if len(parents) == 2: |
c8fb2a82b5f9
revset: add support for p2(wdir()) to get second parent of working directory
Pulkit Goyal <7895pulkit@gmail.com>
parents:
32439
diff
changeset
|
1934 |
ps.add(parents[1]) |
46113
59fa3890d40a
node: import symbols explicitly
Joerg Sonnenberger <joerg@bec.de>
parents:
45942
diff
changeset
|
1935 |
ps -= {nullrev} |
25554
94441df6206c
revset: mark spots that use 'set' instead of 'smartset'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25553
diff
changeset
|
1936 |
# XXX we should turn this into a baseset instead of a set, smartset may do |
30332
318a24b52eeb
spelling: fixes of non-dictionary words
Mads Kiilerich <madski@unity3d.com>
parents:
30227
diff
changeset
|
1937 |
# some optimizations from the fact this is a baseset. |
20367
2ac278aab2b4
revset: added intersection to baseset class
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20366
diff
changeset
|
1938 |
return subset & ps |
11275 | 1939 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
1940 |
|
29932
09a84e747c88
revset: pass around ordering flags to operations
Yuya Nishihara <yuya@tcha.org>
parents:
29931
diff
changeset
|
1941 |
def parentpost(repo, subset, x, order): |
29931
d2d1be3009ca
revset: add stub to handle parentpost operation
Yuya Nishihara <yuya@tcha.org>
parents:
29930
diff
changeset
|
1942 |
return p1(repo, subset, x) |
d2d1be3009ca
revset: add stub to handle parentpost operation
Yuya Nishihara <yuya@tcha.org>
parents:
29930
diff
changeset
|
1943 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
1944 |
|
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1945 |
@predicate(b'parents([set])', safe=True) |
11275 | 1946 |
def parents(repo, subset, x): |
27584
fc7c8cac6a4b
revset: use decorator to register a function as revset predicate
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27517
diff
changeset
|
1947 |
""" |
12929
515c2786e1cf
revsets: let parents() return parents of working dir
Kevin Bullock <kbullock@ringworld.org>
parents:
12928
diff
changeset
|
1948 |
The set of all parents for all changesets in set, or the working directory. |
12821
165079e564f0
revsets: generate predicate help dynamically
Patrick Mezard <pmezard@gmail.com>
parents:
12815
diff
changeset
|
1949 |
""" |
12929
515c2786e1cf
revsets: let parents() return parents of working dir
Kevin Bullock <kbullock@ringworld.org>
parents:
12928
diff
changeset
|
1950 |
if x is None: |
44452
9d2b2df2c2ba
cleanup: run pyupgrade on our source tree to clean up varying things
Augie Fackler <augie@google.com>
parents:
44343
diff
changeset
|
1951 |
ps = {p.rev() for p in repo[x].parents()} |
22496
35af9361a049
revset: refactor parents() into a single return point
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22495
diff
changeset
|
1952 |
else: |
35af9361a049
revset: refactor parents() into a single return point
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22495
diff
changeset
|
1953 |
ps = set() |
35af9361a049
revset: refactor parents() into a single return point
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22495
diff
changeset
|
1954 |
cl = repo.changelog |
25716
d50677c3bf44
revset: prefetch method in "parents"
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25706
diff
changeset
|
1955 |
up = ps.update |
d50677c3bf44
revset: prefetch method in "parents"
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25706
diff
changeset
|
1956 |
parentrevs = cl.parentrevs |
24115
ff24af40728b
revset: specify fullreposet without using spanset factory
Yuya Nishihara <yuya@tcha.org>
parents:
24114
diff
changeset
|
1957 |
for r in getset(repo, fullreposet(repo), x): |
32439
e72c5263ccaf
revset: use try-except instead of if-else because of perf
Pulkit Goyal <7895pulkit@gmail.com>
parents:
32438
diff
changeset
|
1958 |
try: |
e72c5263ccaf
revset: use try-except instead of if-else because of perf
Pulkit Goyal <7895pulkit@gmail.com>
parents:
32438
diff
changeset
|
1959 |
up(parentrevs(r)) |
e72c5263ccaf
revset: use try-except instead of if-else because of perf
Pulkit Goyal <7895pulkit@gmail.com>
parents:
32438
diff
changeset
|
1960 |
except error.WdirUnsupported: |
25716
d50677c3bf44
revset: prefetch method in "parents"
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25706
diff
changeset
|
1961 |
up(p.rev() for p in repo[r].parents()) |
46113
59fa3890d40a
node: import symbols explicitly
Joerg Sonnenberger <joerg@bec.de>
parents:
45942
diff
changeset
|
1962 |
ps -= {nullrev} |
22712
093df3b77f27
revert: bring back usage of `subset & ps` in `parents`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22692
diff
changeset
|
1963 |
return subset & ps |
11275 | 1964 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
1965 |
|
31017 | 1966 |
def _phase(repo, subset, *targets): |
1967 |
"""helper to select all rev in <targets> phases""" |
|
35330
0c1aff6d73a7
revset: use phasecache.getrevset to calculate public()
Jun Wu <quark@fb.com>
parents:
35301
diff
changeset
|
1968 |
return repo._phasecache.getrevset(repo, targets, subset) |
25621
21a874693619
revset: refactor the non-public phase code
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25620
diff
changeset
|
1969 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
1970 |
|
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1971 |
@predicate(b'_phase(idx)', safe=True) |
39274
31c0ee6eb0ac
phase: expose a `_phase(idx)` revset
Boris Feld <boris.feld@octobus.net>
parents:
38810
diff
changeset
|
1972 |
def phase(repo, subset, x): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1973 |
l = getargs(x, 1, 1, b"_phase requires one argument") |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1974 |
target = getinteger(l[0], b"_phase expects a number") |
39274
31c0ee6eb0ac
phase: expose a `_phase(idx)` revset
Boris Feld <boris.feld@octobus.net>
parents:
38810
diff
changeset
|
1975 |
return _phase(repo, subset, target) |
31c0ee6eb0ac
phase: expose a `_phase(idx)` revset
Boris Feld <boris.feld@octobus.net>
parents:
38810
diff
changeset
|
1976 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
1977 |
|
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1978 |
@predicate(b'draft()', safe=True) |
25621
21a874693619
revset: refactor the non-public phase code
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25620
diff
changeset
|
1979 |
def draft(repo, subset, x): |
27584
fc7c8cac6a4b
revset: use decorator to register a function as revset predicate
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27517
diff
changeset
|
1980 |
"""Changeset in draft phase.""" |
25621
21a874693619
revset: refactor the non-public phase code
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25620
diff
changeset
|
1981 |
# i18n: "draft" is a keyword |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1982 |
getargs(x, 0, 0, _(b"draft takes no arguments")) |
25621
21a874693619
revset: refactor the non-public phase code
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25620
diff
changeset
|
1983 |
target = phases.draft |
21a874693619
revset: refactor the non-public phase code
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25620
diff
changeset
|
1984 |
return _phase(repo, subset, target) |
21a874693619
revset: refactor the non-public phase code
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25620
diff
changeset
|
1985 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
1986 |
|
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1987 |
@predicate(b'secret()', safe=True) |
25621
21a874693619
revset: refactor the non-public phase code
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25620
diff
changeset
|
1988 |
def secret(repo, subset, x): |
27584
fc7c8cac6a4b
revset: use decorator to register a function as revset predicate
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27517
diff
changeset
|
1989 |
"""Changeset in secret phase.""" |
25621
21a874693619
revset: refactor the non-public phase code
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25620
diff
changeset
|
1990 |
# i18n: "secret" is a keyword |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1991 |
getargs(x, 0, 0, _(b"secret takes no arguments")) |
25621
21a874693619
revset: refactor the non-public phase code
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25620
diff
changeset
|
1992 |
target = phases.secret |
21a874693619
revset: refactor the non-public phase code
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25620
diff
changeset
|
1993 |
return _phase(repo, subset, target) |
21a874693619
revset: refactor the non-public phase code
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25620
diff
changeset
|
1994 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
1995 |
|
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
1996 |
@predicate(b'stack([revs])', safe=True) |
37389
bef863a09acd
stack: follow-up on the stack revset
Boris Feld <boris.feld@octobus.net>
parents:
37350
diff
changeset
|
1997 |
def stack(repo, subset, x): |
bef863a09acd
stack: follow-up on the stack revset
Boris Feld <boris.feld@octobus.net>
parents:
37350
diff
changeset
|
1998 |
"""Experimental revset for the stack of changesets or working directory |
bef863a09acd
stack: follow-up on the stack revset
Boris Feld <boris.feld@octobus.net>
parents:
37350
diff
changeset
|
1999 |
parent. (EXPERIMENTAL) |
bef863a09acd
stack: follow-up on the stack revset
Boris Feld <boris.feld@octobus.net>
parents:
37350
diff
changeset
|
2000 |
""" |
37001
407934a97bc7
stack: import Evolve stack test file
Boris Feld <boris.feld@octobus.net>
parents:
36607
diff
changeset
|
2001 |
if x is None: |
42699
911e25dc9d8c
revset: drop argument when it's None
Anton Shestakov <av6@dwimlabs.net>
parents:
42441
diff
changeset
|
2002 |
stacks = stackmod.getstack(repo) |
37001
407934a97bc7
stack: import Evolve stack test file
Boris Feld <boris.feld@octobus.net>
parents:
36607
diff
changeset
|
2003 |
else: |
407934a97bc7
stack: import Evolve stack test file
Boris Feld <boris.feld@octobus.net>
parents:
36607
diff
changeset
|
2004 |
stacks = smartset.baseset([]) |
407934a97bc7
stack: import Evolve stack test file
Boris Feld <boris.feld@octobus.net>
parents:
36607
diff
changeset
|
2005 |
for revision in getset(repo, fullreposet(repo), x): |
37389
bef863a09acd
stack: follow-up on the stack revset
Boris Feld <boris.feld@octobus.net>
parents:
37350
diff
changeset
|
2006 |
currentstack = stackmod.getstack(repo, revision) |
37001
407934a97bc7
stack: import Evolve stack test file
Boris Feld <boris.feld@octobus.net>
parents:
36607
diff
changeset
|
2007 |
stacks = stacks + currentstack |
407934a97bc7
stack: import Evolve stack test file
Boris Feld <boris.feld@octobus.net>
parents:
36607
diff
changeset
|
2008 |
|
37389
bef863a09acd
stack: follow-up on the stack revset
Boris Feld <boris.feld@octobus.net>
parents:
37350
diff
changeset
|
2009 |
return subset & stacks |
37001
407934a97bc7
stack: import Evolve stack test file
Boris Feld <boris.feld@octobus.net>
parents:
36607
diff
changeset
|
2010 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
2011 |
|
29932
09a84e747c88
revset: pass around ordering flags to operations
Yuya Nishihara <yuya@tcha.org>
parents:
29931
diff
changeset
|
2012 |
def parentspec(repo, subset, x, n, order): |
14070
305c97670d7a
revset: add ^ and ~ operators from parentrevspec extension
Kevin Gessner <kevin@kevingessner.com>
parents:
14061
diff
changeset
|
2013 |
"""``set^0`` |
305c97670d7a
revset: add ^ and ~ operators from parentrevspec extension
Kevin Gessner <kevin@kevingessner.com>
parents:
14061
diff
changeset
|
2014 |
The set. |
305c97670d7a
revset: add ^ and ~ operators from parentrevspec extension
Kevin Gessner <kevin@kevingessner.com>
parents:
14061
diff
changeset
|
2015 |
``set^1`` (or ``set^``), ``set^2`` |
305c97670d7a
revset: add ^ and ~ operators from parentrevspec extension
Kevin Gessner <kevin@kevingessner.com>
parents:
14061
diff
changeset
|
2016 |
First or second parent, respectively, of all changesets in set. |
12821
165079e564f0
revsets: generate predicate help dynamically
Patrick Mezard <pmezard@gmail.com>
parents:
12815
diff
changeset
|
2017 |
""" |
12320
40c40c6f20b8
revset: handle re.compile() errors in grep()
Brodie Rao <brodie@bitheap.org>
parents:
11882
diff
changeset
|
2018 |
try: |
14070
305c97670d7a
revset: add ^ and ~ operators from parentrevspec extension
Kevin Gessner <kevin@kevingessner.com>
parents:
14061
diff
changeset
|
2019 |
n = int(n[1]) |
14072
2e4d79dcc0a0
revset: add missing whitespace
Kevin Gessner <kevin@kevingessner.com>
parents:
14070
diff
changeset
|
2020 |
if n not in (0, 1, 2): |
14070
305c97670d7a
revset: add ^ and ~ operators from parentrevspec extension
Kevin Gessner <kevin@kevingessner.com>
parents:
14061
diff
changeset
|
2021 |
raise ValueError |
14851
f96c354493d7
revsets: actually catch type error on tip^p1(tip) (issue2884)
Matt Mackall <mpm@selenic.com>
parents:
14842
diff
changeset
|
2022 |
except (TypeError, ValueError): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2023 |
raise error.ParseError(_(b"^ expects a number 0, 1, or 2")) |
14070
305c97670d7a
revset: add ^ and ~ operators from parentrevspec extension
Kevin Gessner <kevin@kevingessner.com>
parents:
14061
diff
changeset
|
2024 |
ps = set() |
11275 | 2025 |
cl = repo.changelog |
23165
7e8737e6ab08
revset-parentspec: call 'getset' on a 'fullreposet'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23164
diff
changeset
|
2026 |
for r in getset(repo, fullreposet(repo), x): |
14070
305c97670d7a
revset: add ^ and ~ operators from parentrevspec extension
Kevin Gessner <kevin@kevingessner.com>
parents:
14061
diff
changeset
|
2027 |
if n == 0: |
305c97670d7a
revset: add ^ and ~ operators from parentrevspec extension
Kevin Gessner <kevin@kevingessner.com>
parents:
14061
diff
changeset
|
2028 |
ps.add(r) |
305c97670d7a
revset: add ^ and ~ operators from parentrevspec extension
Kevin Gessner <kevin@kevingessner.com>
parents:
14061
diff
changeset
|
2029 |
elif n == 1: |
32436
f064e2f72c49
revset: add support for "wdir()^n"
Pulkit Goyal <7895pulkit@gmail.com>
parents:
32435
diff
changeset
|
2030 |
try: |
f064e2f72c49
revset: add support for "wdir()^n"
Pulkit Goyal <7895pulkit@gmail.com>
parents:
32435
diff
changeset
|
2031 |
ps.add(cl.parentrevs(r)[0]) |
f064e2f72c49
revset: add support for "wdir()^n"
Pulkit Goyal <7895pulkit@gmail.com>
parents:
32435
diff
changeset
|
2032 |
except error.WdirUnsupported: |
41397
0bd56c291359
cleanup: use p1() and p2() instead of parents()[0] and parents()[1]
Martin von Zweigbergk <martinvonz@google.com>
parents:
41388
diff
changeset
|
2033 |
ps.add(repo[r].p1().rev()) |
32438
14482f8e6ce6
revset: remove redundant condition and change to else from elif
Pulkit Goyal <7895pulkit@gmail.com>
parents:
32436
diff
changeset
|
2034 |
else: |
32436
f064e2f72c49
revset: add support for "wdir()^n"
Pulkit Goyal <7895pulkit@gmail.com>
parents:
32435
diff
changeset
|
2035 |
try: |
f064e2f72c49
revset: add support for "wdir()^n"
Pulkit Goyal <7895pulkit@gmail.com>
parents:
32435
diff
changeset
|
2036 |
parents = cl.parentrevs(r) |
46113
59fa3890d40a
node: import symbols explicitly
Joerg Sonnenberger <joerg@bec.de>
parents:
45942
diff
changeset
|
2037 |
if parents[1] != nullrev: |
32436
f064e2f72c49
revset: add support for "wdir()^n"
Pulkit Goyal <7895pulkit@gmail.com>
parents:
32435
diff
changeset
|
2038 |
ps.add(parents[1]) |
f064e2f72c49
revset: add support for "wdir()^n"
Pulkit Goyal <7895pulkit@gmail.com>
parents:
32435
diff
changeset
|
2039 |
except error.WdirUnsupported: |
f064e2f72c49
revset: add support for "wdir()^n"
Pulkit Goyal <7895pulkit@gmail.com>
parents:
32435
diff
changeset
|
2040 |
parents = repo[r].parents() |
f064e2f72c49
revset: add support for "wdir()^n"
Pulkit Goyal <7895pulkit@gmail.com>
parents:
32435
diff
changeset
|
2041 |
if len(parents) == 2: |
f064e2f72c49
revset: add support for "wdir()^n"
Pulkit Goyal <7895pulkit@gmail.com>
parents:
32435
diff
changeset
|
2042 |
ps.add(parents[1].rev()) |
20367
2ac278aab2b4
revset: added intersection to baseset class
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20366
diff
changeset
|
2043 |
return subset & ps |
11275 | 2044 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
2045 |
|
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2046 |
@predicate(b'present(set)', safe=True, takeorder=True) |
34011
1b28525e6698
revset: remove order information from tree (API)
Jun Wu <quark@fb.com>
parents:
33855
diff
changeset
|
2047 |
def present(repo, subset, x, order): |
27584
fc7c8cac6a4b
revset: use decorator to register a function as revset predicate
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27517
diff
changeset
|
2048 |
"""An empty set, if any revision in set isn't found; otherwise, |
12821
165079e564f0
revsets: generate predicate help dynamically
Patrick Mezard <pmezard@gmail.com>
parents:
12815
diff
changeset
|
2049 |
all revisions in set. |
16748
0a730d3c5aae
doc: add detail explanation for 'present()' predicate of revsets
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
16735
diff
changeset
|
2050 |
|
0a730d3c5aae
doc: add detail explanation for 'present()' predicate of revsets
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
16735
diff
changeset
|
2051 |
If any of specified revisions is not present in the local repository, |
0a730d3c5aae
doc: add detail explanation for 'present()' predicate of revsets
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
16735
diff
changeset
|
2052 |
the query is normally aborted. But this predicate allows the query |
0a730d3c5aae
doc: add detail explanation for 'present()' predicate of revsets
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
16735
diff
changeset
|
2053 |
to continue even in such cases. |
12821
165079e564f0
revsets: generate predicate help dynamically
Patrick Mezard <pmezard@gmail.com>
parents:
12815
diff
changeset
|
2054 |
""" |
11944
df52ff0980fe
revset: predicate to avoid lookup errors
Wagner Bruna <wbruna@softwareexpress.com.br>
parents:
11886
diff
changeset
|
2055 |
try: |
34011
1b28525e6698
revset: remove order information from tree (API)
Jun Wu <quark@fb.com>
parents:
33855
diff
changeset
|
2056 |
return getset(repo, subset, x, order) |
11944
df52ff0980fe
revset: predicate to avoid lookup errors
Wagner Bruna <wbruna@softwareexpress.com.br>
parents:
11886
diff
changeset
|
2057 |
except error.RepoLookupError: |
22802
1fcd361efaf4
baseset: use default value instead of [] when possible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22801
diff
changeset
|
2058 |
return baseset() |
11944
df52ff0980fe
revset: predicate to avoid lookup errors
Wagner Bruna <wbruna@softwareexpress.com.br>
parents:
11886
diff
changeset
|
2059 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
2060 |
|
25224
d032f57936f5
revset: drop docstring from internal _notpublic() function
Yuya Nishihara <yuya@tcha.org>
parents:
25191
diff
changeset
|
2061 |
# for internal use |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2062 |
@predicate(b'_notpublic', safe=True) |
25191
08d1ef09ed37
revset: optimize not public revset
Laurent Charignon <lcharignon@fb.com>
parents:
25149
diff
changeset
|
2063 |
def _notpublic(repo, subset, x): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2064 |
getargs(x, 0, 0, b"_notpublic takes no arguments") |
31017 | 2065 |
return _phase(repo, subset, phases.draft, phases.secret) |
25191
08d1ef09ed37
revset: optimize not public revset
Laurent Charignon <lcharignon@fb.com>
parents:
25149
diff
changeset
|
2066 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
2067 |
|
34065
c6c8a52e28c9
revset: optimize "draft() & ::x" pattern
Jun Wu <quark@fb.com>
parents:
34020
diff
changeset
|
2068 |
# for internal use |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2069 |
@predicate(b'_phaseandancestors(phasename, set)', safe=True) |
34065
c6c8a52e28c9
revset: optimize "draft() & ::x" pattern
Jun Wu <quark@fb.com>
parents:
34020
diff
changeset
|
2070 |
def _phaseandancestors(repo, subset, x): |
c6c8a52e28c9
revset: optimize "draft() & ::x" pattern
Jun Wu <quark@fb.com>
parents:
34020
diff
changeset
|
2071 |
# equivalent to (phasename() & ancestors(set)) but more efficient |
c6c8a52e28c9
revset: optimize "draft() & ::x" pattern
Jun Wu <quark@fb.com>
parents:
34020
diff
changeset
|
2072 |
# phasename could be one of 'draft', 'secret', or '_notpublic' |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2073 |
args = getargs(x, 2, 2, b"_phaseandancestors requires two arguments") |
34065
c6c8a52e28c9
revset: optimize "draft() & ::x" pattern
Jun Wu <quark@fb.com>
parents:
34020
diff
changeset
|
2074 |
phasename = getsymbol(args[0]) |
c6c8a52e28c9
revset: optimize "draft() & ::x" pattern
Jun Wu <quark@fb.com>
parents:
34020
diff
changeset
|
2075 |
s = getset(repo, fullreposet(repo), args[1]) |
c6c8a52e28c9
revset: optimize "draft() & ::x" pattern
Jun Wu <quark@fb.com>
parents:
34020
diff
changeset
|
2076 |
|
c6c8a52e28c9
revset: optimize "draft() & ::x" pattern
Jun Wu <quark@fb.com>
parents:
34020
diff
changeset
|
2077 |
draft = phases.draft |
c6c8a52e28c9
revset: optimize "draft() & ::x" pattern
Jun Wu <quark@fb.com>
parents:
34020
diff
changeset
|
2078 |
secret = phases.secret |
c6c8a52e28c9
revset: optimize "draft() & ::x" pattern
Jun Wu <quark@fb.com>
parents:
34020
diff
changeset
|
2079 |
phasenamemap = { |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2080 |
b'_notpublic': draft, |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2081 |
b'draft': draft, # follow secret's ancestors |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2082 |
b'secret': secret, |
34065
c6c8a52e28c9
revset: optimize "draft() & ::x" pattern
Jun Wu <quark@fb.com>
parents:
34020
diff
changeset
|
2083 |
} |
c6c8a52e28c9
revset: optimize "draft() & ::x" pattern
Jun Wu <quark@fb.com>
parents:
34020
diff
changeset
|
2084 |
if phasename not in phasenamemap: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2085 |
raise error.ParseError(b'%r is not a valid phasename' % phasename) |
34065
c6c8a52e28c9
revset: optimize "draft() & ::x" pattern
Jun Wu <quark@fb.com>
parents:
34020
diff
changeset
|
2086 |
|
c6c8a52e28c9
revset: optimize "draft() & ::x" pattern
Jun Wu <quark@fb.com>
parents:
34020
diff
changeset
|
2087 |
minimalphase = phasenamemap[phasename] |
c6c8a52e28c9
revset: optimize "draft() & ::x" pattern
Jun Wu <quark@fb.com>
parents:
34020
diff
changeset
|
2088 |
getphase = repo._phasecache.phase |
c6c8a52e28c9
revset: optimize "draft() & ::x" pattern
Jun Wu <quark@fb.com>
parents:
34020
diff
changeset
|
2089 |
|
c6c8a52e28c9
revset: optimize "draft() & ::x" pattern
Jun Wu <quark@fb.com>
parents:
34020
diff
changeset
|
2090 |
def cutfunc(rev): |
c6c8a52e28c9
revset: optimize "draft() & ::x" pattern
Jun Wu <quark@fb.com>
parents:
34020
diff
changeset
|
2091 |
return getphase(repo, rev) < minimalphase |
c6c8a52e28c9
revset: optimize "draft() & ::x" pattern
Jun Wu <quark@fb.com>
parents:
34020
diff
changeset
|
2092 |
|
c6c8a52e28c9
revset: optimize "draft() & ::x" pattern
Jun Wu <quark@fb.com>
parents:
34020
diff
changeset
|
2093 |
revs = dagop.revancestors(repo, s, cutfunc=cutfunc) |
c6c8a52e28c9
revset: optimize "draft() & ::x" pattern
Jun Wu <quark@fb.com>
parents:
34020
diff
changeset
|
2094 |
|
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2095 |
if phasename == b'draft': # need to remove secret changesets |
34065
c6c8a52e28c9
revset: optimize "draft() & ::x" pattern
Jun Wu <quark@fb.com>
parents:
34020
diff
changeset
|
2096 |
revs = revs.filter(lambda r: getphase(repo, r) == draft) |
c6c8a52e28c9
revset: optimize "draft() & ::x" pattern
Jun Wu <quark@fb.com>
parents:
34020
diff
changeset
|
2097 |
return subset & revs |
c6c8a52e28c9
revset: optimize "draft() & ::x" pattern
Jun Wu <quark@fb.com>
parents:
34020
diff
changeset
|
2098 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
2099 |
|
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2100 |
@predicate(b'public()', safe=True) |
15819
33ca11b010e2
phases: implements simple revset symbol
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15791
diff
changeset
|
2101 |
def public(repo, subset, x): |
27584
fc7c8cac6a4b
revset: use decorator to register a function as revset predicate
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27517
diff
changeset
|
2102 |
"""Changeset in public phase.""" |
17259
e96ad092fb18
i18n: add/relocate "i18n keyword" comments for i18n messages in revset.py
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
17258
diff
changeset
|
2103 |
# i18n: "public" is a keyword |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2104 |
getargs(x, 0, 0, _(b"public takes no arguments")) |
35330
0c1aff6d73a7
revset: use phasecache.getrevset to calculate public()
Jun Wu <quark@fb.com>
parents:
35301
diff
changeset
|
2105 |
return _phase(repo, subset, phases.public) |
15819
33ca11b010e2
phases: implements simple revset symbol
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15791
diff
changeset
|
2106 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
2107 |
|
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2108 |
@predicate(b'remote([id [,path]])', safe=False) |
15936
878bc4a62a73
revset: add remote() predicate to lookup remote revisions
Matt Mackall <mpm@selenic.com>
parents:
15903
diff
changeset
|
2109 |
def remote(repo, subset, x): |
27584
fc7c8cac6a4b
revset: use decorator to register a function as revset predicate
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27517
diff
changeset
|
2110 |
"""Local revision that corresponds to the given identifier in a |
15936
878bc4a62a73
revset: add remote() predicate to lookup remote revisions
Matt Mackall <mpm@selenic.com>
parents:
15903
diff
changeset
|
2111 |
remote repository, if present. Here, the '.' identifier is a |
878bc4a62a73
revset: add remote() predicate to lookup remote revisions
Matt Mackall <mpm@selenic.com>
parents:
15903
diff
changeset
|
2112 |
synonym for the current local branch. |
878bc4a62a73
revset: add remote() predicate to lookup remote revisions
Matt Mackall <mpm@selenic.com>
parents:
15903
diff
changeset
|
2113 |
""" |
878bc4a62a73
revset: add remote() predicate to lookup remote revisions
Matt Mackall <mpm@selenic.com>
parents:
15903
diff
changeset
|
2114 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
2115 |
from . import hg # avoid start-up nasties |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
2116 |
|
15936
878bc4a62a73
revset: add remote() predicate to lookup remote revisions
Matt Mackall <mpm@selenic.com>
parents:
15903
diff
changeset
|
2117 |
# i18n: "remote" is a keyword |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2118 |
l = getargs(x, 0, 2, _(b"remote takes zero, one, or two arguments")) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2119 |
|
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2120 |
q = b'.' |
15936
878bc4a62a73
revset: add remote() predicate to lookup remote revisions
Matt Mackall <mpm@selenic.com>
parents:
15903
diff
changeset
|
2121 |
if len(l) > 0: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
2122 |
# i18n: "remote" is a keyword |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2123 |
q = getstring(l[0], _(b"remote requires a string id")) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2124 |
if q == b'.': |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2125 |
q = repo[b'.'].branch() |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2126 |
|
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2127 |
dest = b'' |
15936
878bc4a62a73
revset: add remote() predicate to lookup remote revisions
Matt Mackall <mpm@selenic.com>
parents:
15903
diff
changeset
|
2128 |
if len(l) > 1: |
878bc4a62a73
revset: add remote() predicate to lookup remote revisions
Matt Mackall <mpm@selenic.com>
parents:
15903
diff
changeset
|
2129 |
# i18n: "remote" is a keyword |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2130 |
dest = getstring(l[1], _(b"remote requires a repository path")) |
46956
c5c2936f6fb2
revset: use `get_unique_pull_path` for `remote(…)`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46933
diff
changeset
|
2131 |
if not dest: |
c5c2936f6fb2
revset: use `get_unique_pull_path` for `remote(…)`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
46933
diff
changeset
|
2132 |
dest = b'default' |
49725
f632b9e1e047
path: pass `path` to `peer` in `remote(...)` revset
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49711
diff
changeset
|
2133 |
path = urlutil.get_unique_pull_path_obj(b'remote', repo.ui, dest) |
f632b9e1e047
path: pass `path` to `peer` in `remote(...)` revset
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49711
diff
changeset
|
2134 |
|
f632b9e1e047
path: pass `path` to `peer` in `remote(...)` revset
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49711
diff
changeset
|
2135 |
other = hg.peer(repo, {}, path) |
15936
878bc4a62a73
revset: add remote() predicate to lookup remote revisions
Matt Mackall <mpm@selenic.com>
parents:
15903
diff
changeset
|
2136 |
n = other.lookup(q) |
878bc4a62a73
revset: add remote() predicate to lookup remote revisions
Matt Mackall <mpm@selenic.com>
parents:
15903
diff
changeset
|
2137 |
if n in repo: |
878bc4a62a73
revset: add remote() predicate to lookup remote revisions
Matt Mackall <mpm@selenic.com>
parents:
15903
diff
changeset
|
2138 |
r = repo[n].rev() |
16006
39e60576ac98
revset: fix 'remote()' failure when remote repo has more revs than local
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
15966
diff
changeset
|
2139 |
if r in subset: |
20364
a6cf48b2880d
revset: added baseset class (still empty) to improve revset performance
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20289
diff
changeset
|
2140 |
return baseset([r]) |
22802
1fcd361efaf4
baseset: use default value instead of [] when possible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22801
diff
changeset
|
2141 |
return baseset() |
15936
878bc4a62a73
revset: add remote() predicate to lookup remote revisions
Matt Mackall <mpm@selenic.com>
parents:
15903
diff
changeset
|
2142 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
2143 |
|
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2144 |
@predicate(b'removes(pattern)', safe=True, weight=30) |
11275 | 2145 |
def removes(repo, subset, x): |
27584
fc7c8cac6a4b
revset: use decorator to register a function as revset predicate
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27517
diff
changeset
|
2146 |
"""Changesets which remove files matching pattern. |
20289
96be25f1da45
revset: add explanation about the pattern without explicit kind
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20288
diff
changeset
|
2147 |
|
96be25f1da45
revset: add explanation about the pattern without explicit kind
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20288
diff
changeset
|
2148 |
The pattern without explicit kind like ``glob:`` is expected to be |
96be25f1da45
revset: add explanation about the pattern without explicit kind
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20288
diff
changeset
|
2149 |
relative to the current directory and match against a file or a |
96be25f1da45
revset: add explanation about the pattern without explicit kind
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
20288
diff
changeset
|
2150 |
directory. |
12821
165079e564f0
revsets: generate predicate help dynamically
Patrick Mezard <pmezard@gmail.com>
parents:
12815
diff
changeset
|
2151 |
""" |
12815
079a618ea89d
revset: add translator comments to i18n strings
Martin Geisler <mg@lazybytes.net>
parents:
12786
diff
changeset
|
2152 |
# i18n: "removes" is a keyword |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2153 |
pat = getstring(x, _(b"removes requires a pattern")) |
45428
9b9071fabcd3
revset: remove indirect indexing of status tuple
Yuya Nishihara <yuya@tcha.org>
parents:
44856
diff
changeset
|
2154 |
return checkstatus(repo, subset, pat, 'removed') |
11275 | 2155 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
2156 |
|
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2157 |
@predicate(b'rev(number)', safe=True) |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
2158 |
def rev(repo, subset, x): |
44584
f913ece27ff5
revset: leverage internal _rev() function to implement rev()
Yuya Nishihara <yuya@tcha.org>
parents:
44583
diff
changeset
|
2159 |
"""Revision with the given numeric identifier.""" |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
2160 |
try: |
44584
f913ece27ff5
revset: leverage internal _rev() function to implement rev()
Yuya Nishihara <yuya@tcha.org>
parents:
44583
diff
changeset
|
2161 |
return _rev(repo, subset, x) |
f913ece27ff5
revset: leverage internal _rev() function to implement rev()
Yuya Nishihara <yuya@tcha.org>
parents:
44583
diff
changeset
|
2162 |
except error.RepoLookupError: |
23062
ba89f7b542c9
revset: have rev() drop out-of-range or filtered rev explicitly (issue4396)
Yuya Nishihara <yuya@tcha.org>
parents:
23061
diff
changeset
|
2163 |
return baseset() |
11275 | 2164 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
2165 |
|
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2166 |
@predicate(b'_rev(number)', safe=True) |
41297
b1ea90613af3
revset: introduce an internal `_rev` predicate for '%d' usage
Boris Feld <boris.feld@octobus.net>
parents:
41276
diff
changeset
|
2167 |
def _rev(repo, subset, x): |
b1ea90613af3
revset: introduce an internal `_rev` predicate for '%d' usage
Boris Feld <boris.feld@octobus.net>
parents:
41276
diff
changeset
|
2168 |
# internal version of "rev(x)" that raise error if "x" is invalid |
b1ea90613af3
revset: introduce an internal `_rev` predicate for '%d' usage
Boris Feld <boris.feld@octobus.net>
parents:
41276
diff
changeset
|
2169 |
# i18n: "rev" is a keyword |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2170 |
l = getargs(x, 1, 1, _(b"rev requires one argument")) |
41297
b1ea90613af3
revset: introduce an internal `_rev` predicate for '%d' usage
Boris Feld <boris.feld@octobus.net>
parents:
41276
diff
changeset
|
2171 |
try: |
b1ea90613af3
revset: introduce an internal `_rev` predicate for '%d' usage
Boris Feld <boris.feld@octobus.net>
parents:
41276
diff
changeset
|
2172 |
# i18n: "rev" is a keyword |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2173 |
l = int(getstring(l[0], _(b"rev requires a number"))) |
41297
b1ea90613af3
revset: introduce an internal `_rev` predicate for '%d' usage
Boris Feld <boris.feld@octobus.net>
parents:
41276
diff
changeset
|
2174 |
except (TypeError, ValueError): |
b1ea90613af3
revset: introduce an internal `_rev` predicate for '%d' usage
Boris Feld <boris.feld@octobus.net>
parents:
41276
diff
changeset
|
2175 |
# i18n: "rev" is a keyword |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2176 |
raise error.ParseError(_(b"rev expects a number")) |
44582
482a6aac1f15
revset: allow repo.revs('%d', wdirrev)
Yuya Nishihara <yuya@tcha.org>
parents:
44452
diff
changeset
|
2177 |
if l not in _virtualrevs: |
44583
967e2e81f762
revset: fix crash by repo.revs('%d', tip + 1)
Yuya Nishihara <yuya@tcha.org>
parents:
44582
diff
changeset
|
2178 |
try: |
967e2e81f762
revset: fix crash by repo.revs('%d', tip + 1)
Yuya Nishihara <yuya@tcha.org>
parents:
44582
diff
changeset
|
2179 |
repo.changelog.node(l) # check that the rev exists |
967e2e81f762
revset: fix crash by repo.revs('%d', tip + 1)
Yuya Nishihara <yuya@tcha.org>
parents:
44582
diff
changeset
|
2180 |
except IndexError: |
967e2e81f762
revset: fix crash by repo.revs('%d', tip + 1)
Yuya Nishihara <yuya@tcha.org>
parents:
44582
diff
changeset
|
2181 |
raise error.RepoLookupError(_(b"unknown revision '%d'") % l) |
41297
b1ea90613af3
revset: introduce an internal `_rev` predicate for '%d' usage
Boris Feld <boris.feld@octobus.net>
parents:
41276
diff
changeset
|
2182 |
return subset & baseset([l]) |
b1ea90613af3
revset: introduce an internal `_rev` predicate for '%d' usage
Boris Feld <boris.feld@octobus.net>
parents:
41276
diff
changeset
|
2183 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
2184 |
|
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2185 |
@predicate(b'revset(set)', safe=True, takeorder=True) |
40310
d894d2372ffe
revset: document the `revset(...)` syntax
Boris Feld <boris.feld@octobus.net>
parents:
39832
diff
changeset
|
2186 |
def revsetpredicate(repo, subset, x, order): |
d894d2372ffe
revset: document the `revset(...)` syntax
Boris Feld <boris.feld@octobus.net>
parents:
39832
diff
changeset
|
2187 |
"""Strictly interpret the content as a revset. |
d894d2372ffe
revset: document the `revset(...)` syntax
Boris Feld <boris.feld@octobus.net>
parents:
39832
diff
changeset
|
2188 |
|
d894d2372ffe
revset: document the `revset(...)` syntax
Boris Feld <boris.feld@octobus.net>
parents:
39832
diff
changeset
|
2189 |
The content of this special predicate will be strictly interpreted as a |
d894d2372ffe
revset: document the `revset(...)` syntax
Boris Feld <boris.feld@octobus.net>
parents:
39832
diff
changeset
|
2190 |
revset. For example, ``revset(id(0))`` will be interpreted as "id(0)" |
d894d2372ffe
revset: document the `revset(...)` syntax
Boris Feld <boris.feld@octobus.net>
parents:
39832
diff
changeset
|
2191 |
without possible ambiguity with a "id(0)" bookmark or tag. |
d894d2372ffe
revset: document the `revset(...)` syntax
Boris Feld <boris.feld@octobus.net>
parents:
39832
diff
changeset
|
2192 |
""" |
d894d2372ffe
revset: document the `revset(...)` syntax
Boris Feld <boris.feld@octobus.net>
parents:
39832
diff
changeset
|
2193 |
return getset(repo, subset, x, order) |
d894d2372ffe
revset: document the `revset(...)` syntax
Boris Feld <boris.feld@octobus.net>
parents:
39832
diff
changeset
|
2194 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
2195 |
|
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2196 |
@predicate(b'matching(revision [, field])', safe=True) |
16402
1fb2f1400ea8
revset: add "matching" keyword
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
16218
diff
changeset
|
2197 |
def matching(repo, subset, x): |
27584
fc7c8cac6a4b
revset: use decorator to register a function as revset predicate
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27517
diff
changeset
|
2198 |
"""Changesets in which a given set of fields match the set of fields in the |
16402
1fb2f1400ea8
revset: add "matching" keyword
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
16218
diff
changeset
|
2199 |
selected revision or set. |
16528
5d803620ca05
doc: flatten description of 'matching()' predicate to be formatted well
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
16521
diff
changeset
|
2200 |
|
16402
1fb2f1400ea8
revset: add "matching" keyword
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
16218
diff
changeset
|
2201 |
To match more than one field pass the list of fields to match separated |
16528
5d803620ca05
doc: flatten description of 'matching()' predicate to be formatted well
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
16521
diff
changeset
|
2202 |
by spaces (e.g. ``author description``). |
5d803620ca05
doc: flatten description of 'matching()' predicate to be formatted well
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
16521
diff
changeset
|
2203 |
|
5d803620ca05
doc: flatten description of 'matching()' predicate to be formatted well
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
16521
diff
changeset
|
2204 |
Valid fields are most regular revision fields and some special fields. |
5d803620ca05
doc: flatten description of 'matching()' predicate to be formatted well
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
16521
diff
changeset
|
2205 |
|
5d803620ca05
doc: flatten description of 'matching()' predicate to be formatted well
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
16521
diff
changeset
|
2206 |
Regular revision fields are ``description``, ``author``, ``branch``, |
17102
d9a046ae4d8e
revset: add "diff" field to "matching" keyword
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
17100
diff
changeset
|
2207 |
``date``, ``files``, ``phase``, ``parents``, ``substate``, ``user`` |
d9a046ae4d8e
revset: add "diff" field to "matching" keyword
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
17100
diff
changeset
|
2208 |
and ``diff``. |
d9a046ae4d8e
revset: add "diff" field to "matching" keyword
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
17100
diff
changeset
|
2209 |
Note that ``author`` and ``user`` are synonyms. ``diff`` refers to the |
d9a046ae4d8e
revset: add "diff" field to "matching" keyword
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
17100
diff
changeset
|
2210 |
contents of the revision. Two revisions matching their ``diff`` will |
d9a046ae4d8e
revset: add "diff" field to "matching" keyword
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
17100
diff
changeset
|
2211 |
also match their ``files``. |
16528
5d803620ca05
doc: flatten description of 'matching()' predicate to be formatted well
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
16521
diff
changeset
|
2212 |
|
5d803620ca05
doc: flatten description of 'matching()' predicate to be formatted well
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
16521
diff
changeset
|
2213 |
Special fields are ``summary`` and ``metadata``: |
5d803620ca05
doc: flatten description of 'matching()' predicate to be formatted well
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
16521
diff
changeset
|
2214 |
``summary`` matches the first line of the description. |
16639
00290bd359fe
revset: documentation typo "metatadata"
Jesse Glick <jesse.glick@oracle.com>
parents:
16528
diff
changeset
|
2215 |
``metadata`` is equivalent to matching ``description user date`` |
16528
5d803620ca05
doc: flatten description of 'matching()' predicate to be formatted well
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
16521
diff
changeset
|
2216 |
(i.e. it matches the main metadata fields). |
5d803620ca05
doc: flatten description of 'matching()' predicate to be formatted well
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
16521
diff
changeset
|
2217 |
|
5d803620ca05
doc: flatten description of 'matching()' predicate to be formatted well
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
16521
diff
changeset
|
2218 |
``metadata`` is the default field which is used when no fields are |
5d803620ca05
doc: flatten description of 'matching()' predicate to be formatted well
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
16521
diff
changeset
|
2219 |
specified. You can match more than one field at a time. |
16402
1fb2f1400ea8
revset: add "matching" keyword
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
16218
diff
changeset
|
2220 |
""" |
17259
e96ad092fb18
i18n: add/relocate "i18n keyword" comments for i18n messages in revset.py
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
17258
diff
changeset
|
2221 |
# i18n: "matching" is a keyword |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2222 |
l = getargs(x, 1, 2, _(b"matching takes 1 or 2 arguments")) |
16402
1fb2f1400ea8
revset: add "matching" keyword
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
16218
diff
changeset
|
2223 |
|
23166
30e0dcd7c5ff
revset-matching: call 'getset' on a 'fullreposet'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
23165
diff
changeset
|
2224 |
revs = getset(repo, fullreposet(repo), l[0]) |
16402
1fb2f1400ea8
revset: add "matching" keyword
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
16218
diff
changeset
|
2225 |
|
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2226 |
fieldlist = [b'metadata'] |
16402
1fb2f1400ea8
revset: add "matching" keyword
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
16218
diff
changeset
|
2227 |
if len(l) > 1: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
2228 |
fieldlist = getstring( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
2229 |
l[1], |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
2230 |
# i18n: "matching" is a keyword |
43117
8ff1ecfadcd1
cleanup: join string literals that are already on one line
Martin von Zweigbergk <martinvonz@google.com>
parents:
43106
diff
changeset
|
2231 |
_(b"matching requires a string as its second argument"), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
2232 |
).split() |
16402
1fb2f1400ea8
revset: add "matching" keyword
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
16218
diff
changeset
|
2233 |
|
17102
d9a046ae4d8e
revset: add "diff" field to "matching" keyword
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
17100
diff
changeset
|
2234 |
# Make sure that there are no repeated fields, |
d9a046ae4d8e
revset: add "diff" field to "matching" keyword
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
17100
diff
changeset
|
2235 |
# expand the 'special' 'metadata' field type |
d9a046ae4d8e
revset: add "diff" field to "matching" keyword
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
17100
diff
changeset
|
2236 |
# and check the 'files' whenever we check the 'diff' |
16402
1fb2f1400ea8
revset: add "matching" keyword
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
16218
diff
changeset
|
2237 |
fields = [] |
1fb2f1400ea8
revset: add "matching" keyword
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
16218
diff
changeset
|
2238 |
for field in fieldlist: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2239 |
if field == b'metadata': |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2240 |
fields += [b'user', b'description', b'date'] |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2241 |
elif field == b'diff': |
17102
d9a046ae4d8e
revset: add "diff" field to "matching" keyword
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
17100
diff
changeset
|
2242 |
# a revision matching the diff must also match the files |
d9a046ae4d8e
revset: add "diff" field to "matching" keyword
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
17100
diff
changeset
|
2243 |
# since matching the diff is very costly, make sure to |
d9a046ae4d8e
revset: add "diff" field to "matching" keyword
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
17100
diff
changeset
|
2244 |
# also match the files first |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2245 |
fields += [b'files', b'diff'] |
16402
1fb2f1400ea8
revset: add "matching" keyword
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
16218
diff
changeset
|
2246 |
else: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2247 |
if field == b'author': |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2248 |
field = b'user' |
16402
1fb2f1400ea8
revset: add "matching" keyword
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
16218
diff
changeset
|
2249 |
fields.append(field) |
1fb2f1400ea8
revset: add "matching" keyword
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
16218
diff
changeset
|
2250 |
fields = set(fields) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2251 |
if b'summary' in fields and b'description' in fields: |
16444
432f198600c6
revset: make matching keyword not match summary when matching for description
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
16417
diff
changeset
|
2252 |
# If a revision matches its description it also matches its summary |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2253 |
fields.discard(b'summary') |
16402
1fb2f1400ea8
revset: add "matching" keyword
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
16218
diff
changeset
|
2254 |
|
1fb2f1400ea8
revset: add "matching" keyword
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
16218
diff
changeset
|
2255 |
# We may want to match more than one field |
16446
984e0412e82b
revset: speedup matching() by first matching fields that take less time to
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
16445
diff
changeset
|
2256 |
# Not all fields take the same amount of time to be matched |
984e0412e82b
revset: speedup matching() by first matching fields that take less time to
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
16445
diff
changeset
|
2257 |
# Sort the selected fields in order of increasing matching cost |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
2258 |
fieldorder = [ |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2259 |
b'phase', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2260 |
b'parents', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2261 |
b'user', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2262 |
b'date', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2263 |
b'branch', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2264 |
b'summary', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2265 |
b'files', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2266 |
b'description', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2267 |
b'substate', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2268 |
b'diff', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
2269 |
] |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
2270 |
|
16446
984e0412e82b
revset: speedup matching() by first matching fields that take less time to
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
16445
diff
changeset
|
2271 |
def fieldkeyfunc(f): |
984e0412e82b
revset: speedup matching() by first matching fields that take less time to
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
16445
diff
changeset
|
2272 |
try: |
984e0412e82b
revset: speedup matching() by first matching fields that take less time to
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
16445
diff
changeset
|
2273 |
return fieldorder.index(f) |
984e0412e82b
revset: speedup matching() by first matching fields that take less time to
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
16445
diff
changeset
|
2274 |
except ValueError: |
984e0412e82b
revset: speedup matching() by first matching fields that take less time to
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
16445
diff
changeset
|
2275 |
# assume an unknown field is very costly |
984e0412e82b
revset: speedup matching() by first matching fields that take less time to
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
16445
diff
changeset
|
2276 |
return len(fieldorder) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
2277 |
|
16446
984e0412e82b
revset: speedup matching() by first matching fields that take less time to
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
16445
diff
changeset
|
2278 |
fields = list(fields) |
984e0412e82b
revset: speedup matching() by first matching fields that take less time to
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
16445
diff
changeset
|
2279 |
fields.sort(key=fieldkeyfunc) |
984e0412e82b
revset: speedup matching() by first matching fields that take less time to
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
16445
diff
changeset
|
2280 |
|
16402
1fb2f1400ea8
revset: add "matching" keyword
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
16218
diff
changeset
|
2281 |
# Each field will be matched with its own "getfield" function |
1fb2f1400ea8
revset: add "matching" keyword
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
16218
diff
changeset
|
2282 |
# which will be added to the getfieldfuncs array of functions |
1fb2f1400ea8
revset: add "matching" keyword
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
16218
diff
changeset
|
2283 |
getfieldfuncs = [] |
1fb2f1400ea8
revset: add "matching" keyword
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
16218
diff
changeset
|
2284 |
_funcs = { |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2285 |
b'user': lambda r: repo[r].user(), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2286 |
b'branch': lambda r: repo[r].branch(), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2287 |
b'date': lambda r: repo[r].date(), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2288 |
b'description': lambda r: repo[r].description(), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2289 |
b'files': lambda r: repo[r].files(), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2290 |
b'parents': lambda r: repo[r].parents(), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2291 |
b'phase': lambda r: repo[r].phase(), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2292 |
b'substate': lambda r: repo[r].substate, |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2293 |
b'summary': lambda r: repo[r].description().splitlines()[0], |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2294 |
b'diff': lambda r: list( |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2295 |
repo[r].diff(opts=diffutil.diffallopts(repo.ui, {b'git': True})) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
2296 |
), |
16402
1fb2f1400ea8
revset: add "matching" keyword
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
16218
diff
changeset
|
2297 |
} |
1fb2f1400ea8
revset: add "matching" keyword
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
16218
diff
changeset
|
2298 |
for info in fields: |
1fb2f1400ea8
revset: add "matching" keyword
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
16218
diff
changeset
|
2299 |
getfield = _funcs.get(info, None) |
1fb2f1400ea8
revset: add "matching" keyword
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
16218
diff
changeset
|
2300 |
if getfield is None: |
1fb2f1400ea8
revset: add "matching" keyword
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
16218
diff
changeset
|
2301 |
raise error.ParseError( |
17259
e96ad092fb18
i18n: add/relocate "i18n keyword" comments for i18n messages in revset.py
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
17258
diff
changeset
|
2302 |
# i18n: "matching" is a keyword |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2303 |
_(b"unexpected field name passed to matching: %s") |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
2304 |
% info |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
2305 |
) |
16402
1fb2f1400ea8
revset: add "matching" keyword
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
16218
diff
changeset
|
2306 |
getfieldfuncs.append(getfield) |
1fb2f1400ea8
revset: add "matching" keyword
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
16218
diff
changeset
|
2307 |
# convert the getfield array of functions into a "getinfo" function |
1fb2f1400ea8
revset: add "matching" keyword
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
16218
diff
changeset
|
2308 |
# which returns an array of field values (or a single value if there |
1fb2f1400ea8
revset: add "matching" keyword
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
16218
diff
changeset
|
2309 |
# is only one field to match) |
16445
453c8670566c
revset: speedup matching() by stopping the match early if a field does not match
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
16444
diff
changeset
|
2310 |
getinfo = lambda r: [f(r) for f in getfieldfuncs] |
16402
1fb2f1400ea8
revset: add "matching" keyword
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
16218
diff
changeset
|
2311 |
|
20459
51890507c6b3
revset: added lazyset implementation to matching revset
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20458
diff
changeset
|
2312 |
def matches(x): |
51890507c6b3
revset: added lazyset implementation to matching revset
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20458
diff
changeset
|
2313 |
for rev in revs: |
51890507c6b3
revset: added lazyset implementation to matching revset
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20458
diff
changeset
|
2314 |
target = getinfo(rev) |
16445
453c8670566c
revset: speedup matching() by stopping the match early if a field does not match
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
16444
diff
changeset
|
2315 |
match = True |
453c8670566c
revset: speedup matching() by stopping the match early if a field does not match
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
16444
diff
changeset
|
2316 |
for n, f in enumerate(getfieldfuncs): |
20459
51890507c6b3
revset: added lazyset implementation to matching revset
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20458
diff
changeset
|
2317 |
if target[n] != f(x): |
16445
453c8670566c
revset: speedup matching() by stopping the match early if a field does not match
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
16444
diff
changeset
|
2318 |
match = False |
453c8670566c
revset: speedup matching() by stopping the match early if a field does not match
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
16444
diff
changeset
|
2319 |
if match: |
20459
51890507c6b3
revset: added lazyset implementation to matching revset
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20458
diff
changeset
|
2320 |
return True |
51890507c6b3
revset: added lazyset implementation to matching revset
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20458
diff
changeset
|
2321 |
return False |
51890507c6b3
revset: added lazyset implementation to matching revset
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20458
diff
changeset
|
2322 |
|
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2323 |
return subset.filter(matches, condrepr=(b'<matching%r %r>', fields, revs)) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2324 |
|
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2325 |
|
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2326 |
@predicate(b'reverse(set)', safe=True, takeorder=True, weight=0) |
29945
89dbae952ec1
revset: make reverse() noop depending on ordering requirement (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
29944
diff
changeset
|
2327 |
def reverse(repo, subset, x, order): |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45750
diff
changeset
|
2328 |
"""Reverse order of set.""" |
34011
1b28525e6698
revset: remove order information from tree (API)
Jun Wu <quark@fb.com>
parents:
33855
diff
changeset
|
2329 |
l = getset(repo, subset, x, order) |
29945
89dbae952ec1
revset: make reverse() noop depending on ordering requirement (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
29944
diff
changeset
|
2330 |
if order == defineorder: |
89dbae952ec1
revset: make reverse() noop depending on ordering requirement (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
29944
diff
changeset
|
2331 |
l.reverse() |
11275 | 2332 |
return l |
2333 |
||
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
2334 |
|
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2335 |
@predicate(b'roots(set)', safe=True) |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
2336 |
def roots(repo, subset, x): |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45750
diff
changeset
|
2337 |
"""Changesets in set with no parent changeset in set.""" |
24115
ff24af40728b
revset: specify fullreposet without using spanset factory
Yuya Nishihara <yuya@tcha.org>
parents:
24114
diff
changeset
|
2338 |
s = getset(repo, fullreposet(repo), x) |
25647
46a96dd4d976
revset: improves time complexity of 'roots(xxx)'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25634
diff
changeset
|
2339 |
parents = repo.changelog.parentrevs |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
2340 |
|
25647
46a96dd4d976
revset: improves time complexity of 'roots(xxx)'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25634
diff
changeset
|
2341 |
def filter(r): |
49510
e02dcc625171
revset: handle wdir() in `roots()`
Matt Harbison <matt_harbison@yahoo.com>
parents:
49447
diff
changeset
|
2342 |
try: |
e02dcc625171
revset: handle wdir() in `roots()`
Matt Harbison <matt_harbison@yahoo.com>
parents:
49447
diff
changeset
|
2343 |
for p in parents(r): |
e02dcc625171
revset: handle wdir() in `roots()`
Matt Harbison <matt_harbison@yahoo.com>
parents:
49447
diff
changeset
|
2344 |
if 0 <= p and p in s: |
e02dcc625171
revset: handle wdir() in `roots()`
Matt Harbison <matt_harbison@yahoo.com>
parents:
49447
diff
changeset
|
2345 |
return False |
e02dcc625171
revset: handle wdir() in `roots()`
Matt Harbison <matt_harbison@yahoo.com>
parents:
49447
diff
changeset
|
2346 |
except error.WdirUnsupported: |
e02dcc625171
revset: handle wdir() in `roots()`
Matt Harbison <matt_harbison@yahoo.com>
parents:
49447
diff
changeset
|
2347 |
for p in repo[None].parents(): |
e02dcc625171
revset: handle wdir() in `roots()`
Matt Harbison <matt_harbison@yahoo.com>
parents:
49447
diff
changeset
|
2348 |
if p.rev() in s: |
e02dcc625171
revset: handle wdir() in `roots()`
Matt Harbison <matt_harbison@yahoo.com>
parents:
49447
diff
changeset
|
2349 |
return False |
25647
46a96dd4d976
revset: improves time complexity of 'roots(xxx)'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25634
diff
changeset
|
2350 |
return True |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
2351 |
|
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2352 |
return subset & s.filter(filter, condrepr=b'<roots>') |
11944
df52ff0980fe
revset: predicate to avoid lookup errors
Wagner Bruna <wbruna@softwareexpress.com.br>
parents:
11886
diff
changeset
|
2353 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
2354 |
|
49447
6dbe74669eba
sort-revset: introduce a `random` variant
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49279
diff
changeset
|
2355 |
MAXINT = sys.maxsize |
6dbe74669eba
sort-revset: introduce a `random` variant
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49279
diff
changeset
|
2356 |
MININT = -MAXINT - 1 |
6dbe74669eba
sort-revset: introduce a `random` variant
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49279
diff
changeset
|
2357 |
|
6dbe74669eba
sort-revset: introduce a `random` variant
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49279
diff
changeset
|
2358 |
|
6dbe74669eba
sort-revset: introduce a `random` variant
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49279
diff
changeset
|
2359 |
def pick_random(c, gen=random): |
6dbe74669eba
sort-revset: introduce a `random` variant
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49279
diff
changeset
|
2360 |
# exists as its own function to make it possible to overwrite the seed |
6dbe74669eba
sort-revset: introduce a `random` variant
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49279
diff
changeset
|
2361 |
return gen.randint(MININT, MAXINT) |
6dbe74669eba
sort-revset: introduce a `random` variant
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49279
diff
changeset
|
2362 |
|
6dbe74669eba
sort-revset: introduce a `random` variant
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49279
diff
changeset
|
2363 |
|
29265
3f9e68864ccc
revset: define table of sort() key functions
Yuya Nishihara <yuya@tcha.org>
parents:
29264
diff
changeset
|
2364 |
_sortkeyfuncs = { |
45701
b90d7e7f39db
revset: fix sorting key of wdir revision
Yuya Nishihara <yuya@tcha.org>
parents:
45686
diff
changeset
|
2365 |
b'rev': scmutil.intrev, |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2366 |
b'branch': lambda c: c.branch(), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2367 |
b'desc': lambda c: c.description(), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2368 |
b'user': lambda c: c.user(), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2369 |
b'author': lambda c: c.user(), |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2370 |
b'date': lambda c: c.date()[0], |
45701
b90d7e7f39db
revset: fix sorting key of wdir revision
Yuya Nishihara <yuya@tcha.org>
parents:
45686
diff
changeset
|
2371 |
b'node': scmutil.binnode, |
49447
6dbe74669eba
sort-revset: introduce a `random` variant
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49279
diff
changeset
|
2372 |
b'random': pick_random, |
29265
3f9e68864ccc
revset: define table of sort() key functions
Yuya Nishihara <yuya@tcha.org>
parents:
29264
diff
changeset
|
2373 |
} |
3f9e68864ccc
revset: define table of sort() key functions
Yuya Nishihara <yuya@tcha.org>
parents:
29264
diff
changeset
|
2374 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
2375 |
|
29365
f652e84f23f2
revset: extract function that validates sort() arguments
Yuya Nishihara <yuya@tcha.org>
parents:
29364
diff
changeset
|
2376 |
def _getsortargs(x): |
f652e84f23f2
revset: extract function that validates sort() arguments
Yuya Nishihara <yuya@tcha.org>
parents:
29364
diff
changeset
|
2377 |
"""Parse sort options into (set, [(key, reverse)], opts)""" |
49447
6dbe74669eba
sort-revset: introduce a `random` variant
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49279
diff
changeset
|
2378 |
args = getargsdict( |
6dbe74669eba
sort-revset: introduce a `random` variant
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49279
diff
changeset
|
2379 |
x, |
6dbe74669eba
sort-revset: introduce a `random` variant
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49279
diff
changeset
|
2380 |
b'sort', |
6dbe74669eba
sort-revset: introduce a `random` variant
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49279
diff
changeset
|
2381 |
b'set keys topo.firstbranch random.seed', |
6dbe74669eba
sort-revset: introduce a `random` variant
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49279
diff
changeset
|
2382 |
) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2383 |
if b'set' not in args: |
29238
e150c1d5f262
revset: use getargsdict for sort()
Martijn Pieters <mjpieters@fb.com>
parents:
29216
diff
changeset
|
2384 |
# i18n: "sort" is a keyword |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2385 |
raise error.ParseError(_(b'sort requires one or two arguments')) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2386 |
keys = b"rev" |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2387 |
if b'keys' in args: |
17259
e96ad092fb18
i18n: add/relocate "i18n keyword" comments for i18n messages in revset.py
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
17258
diff
changeset
|
2388 |
# i18n: "sort" is a keyword |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2389 |
keys = getstring(args[b'keys'], _(b"sort spec must be a string")) |
29238
e150c1d5f262
revset: use getargsdict for sort()
Martijn Pieters <mjpieters@fb.com>
parents:
29216
diff
changeset
|
2390 |
|
29363
2d18c61173f1
revset: build list of (key, reverse) pairs before sorting
Yuya Nishihara <yuya@tcha.org>
parents:
29362
diff
changeset
|
2391 |
keyflags = [] |
2d18c61173f1
revset: build list of (key, reverse) pairs before sorting
Yuya Nishihara <yuya@tcha.org>
parents:
29362
diff
changeset
|
2392 |
for k in keys.split(): |
2d18c61173f1
revset: build list of (key, reverse) pairs before sorting
Yuya Nishihara <yuya@tcha.org>
parents:
29362
diff
changeset
|
2393 |
fk = k |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2394 |
reverse = k.startswith(b'-') |
29363
2d18c61173f1
revset: build list of (key, reverse) pairs before sorting
Yuya Nishihara <yuya@tcha.org>
parents:
29362
diff
changeset
|
2395 |
if reverse: |
2d18c61173f1
revset: build list of (key, reverse) pairs before sorting
Yuya Nishihara <yuya@tcha.org>
parents:
29362
diff
changeset
|
2396 |
k = k[1:] |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2397 |
if k not in _sortkeyfuncs and k != b'topo': |
36580
04e50037d957
revset: use {force,}bytestr to fix some %r formatting issues
Augie Fackler <augie@google.com>
parents:
35914
diff
changeset
|
2398 |
raise error.ParseError( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2399 |
_(b"unknown sort key %r") % pycompat.bytestr(fk) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
2400 |
) |
29363
2d18c61173f1
revset: build list of (key, reverse) pairs before sorting
Yuya Nishihara <yuya@tcha.org>
parents:
29362
diff
changeset
|
2401 |
keyflags.append((k, reverse)) |
2d18c61173f1
revset: build list of (key, reverse) pairs before sorting
Yuya Nishihara <yuya@tcha.org>
parents:
29362
diff
changeset
|
2402 |
|
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2403 |
if len(keyflags) > 1 and any(k == b'topo' for k, reverse in keyflags): |
29348
2188f170f5b6
revset: add new topographical sort
Martijn Pieters <mjpieters@fb.com>
parents:
29347
diff
changeset
|
2404 |
# i18n: "topo" is a keyword |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
2405 |
raise error.ParseError( |
43117
8ff1ecfadcd1
cleanup: join string literals that are already on one line
Martin von Zweigbergk <martinvonz@google.com>
parents:
43106
diff
changeset
|
2406 |
_(b'topo sort order cannot be combined with other sort keys') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
2407 |
) |
29348
2188f170f5b6
revset: add new topographical sort
Martijn Pieters <mjpieters@fb.com>
parents:
29347
diff
changeset
|
2408 |
|
29364
76a1a703e23d
revset: build dict of extra sort options before evaluating set
Yuya Nishihara <yuya@tcha.org>
parents:
29363
diff
changeset
|
2409 |
opts = {} |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2410 |
if b'topo.firstbranch' in args: |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2411 |
if any(k == b'topo' for k, reverse in keyflags): |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2412 |
opts[b'topo.firstbranch'] = args[b'topo.firstbranch'] |
29348
2188f170f5b6
revset: add new topographical sort
Martijn Pieters <mjpieters@fb.com>
parents:
29347
diff
changeset
|
2413 |
else: |
2188f170f5b6
revset: add new topographical sort
Martijn Pieters <mjpieters@fb.com>
parents:
29347
diff
changeset
|
2414 |
# i18n: "topo" and "topo.firstbranch" are keywords |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
2415 |
raise error.ParseError( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
2416 |
_( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2417 |
b'topo.firstbranch can only be used ' |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2418 |
b'when using the topo sort key' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
2419 |
) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
2420 |
) |
29348
2188f170f5b6
revset: add new topographical sort
Martijn Pieters <mjpieters@fb.com>
parents:
29347
diff
changeset
|
2421 |
|
49447
6dbe74669eba
sort-revset: introduce a `random` variant
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49279
diff
changeset
|
2422 |
if b'random.seed' in args: |
6dbe74669eba
sort-revset: introduce a `random` variant
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49279
diff
changeset
|
2423 |
if any(k == b'random' for k, reverse in keyflags): |
6dbe74669eba
sort-revset: introduce a `random` variant
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49279
diff
changeset
|
2424 |
s = args[b'random.seed'] |
6dbe74669eba
sort-revset: introduce a `random` variant
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49279
diff
changeset
|
2425 |
seed = getstring(s, _(b"random.seed must be a string")) |
6dbe74669eba
sort-revset: introduce a `random` variant
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49279
diff
changeset
|
2426 |
opts[b'random.seed'] = seed |
6dbe74669eba
sort-revset: introduce a `random` variant
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49279
diff
changeset
|
2427 |
else: |
6dbe74669eba
sort-revset: introduce a `random` variant
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49279
diff
changeset
|
2428 |
# i18n: "random" and "random.seed" are keywords |
6dbe74669eba
sort-revset: introduce a `random` variant
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49279
diff
changeset
|
2429 |
raise error.ParseError( |
6dbe74669eba
sort-revset: introduce a `random` variant
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49279
diff
changeset
|
2430 |
_( |
6dbe74669eba
sort-revset: introduce a `random` variant
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49279
diff
changeset
|
2431 |
b'random.seed can only be used ' |
6dbe74669eba
sort-revset: introduce a `random` variant
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49279
diff
changeset
|
2432 |
b'when using the random sort key' |
6dbe74669eba
sort-revset: introduce a `random` variant
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49279
diff
changeset
|
2433 |
) |
6dbe74669eba
sort-revset: introduce a `random` variant
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49279
diff
changeset
|
2434 |
) |
6dbe74669eba
sort-revset: introduce a `random` variant
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49279
diff
changeset
|
2435 |
|
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2436 |
return args[b'set'], keyflags, opts |
29365
f652e84f23f2
revset: extract function that validates sort() arguments
Yuya Nishihara <yuya@tcha.org>
parents:
29364
diff
changeset
|
2437 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
2438 |
|
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
2439 |
@predicate( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2440 |
b'sort(set[, [-]key... [, ...]])', safe=True, takeorder=True, weight=10 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
2441 |
) |
29946
285a8c3e53f2
revset: make sort() noop depending on ordering requirement (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
29945
diff
changeset
|
2442 |
def sort(repo, subset, x, order): |
29365
f652e84f23f2
revset: extract function that validates sort() arguments
Yuya Nishihara <yuya@tcha.org>
parents:
29364
diff
changeset
|
2443 |
"""Sort set by keys. The default sort order is ascending, specify a key |
f652e84f23f2
revset: extract function that validates sort() arguments
Yuya Nishihara <yuya@tcha.org>
parents:
29364
diff
changeset
|
2444 |
as ``-key`` to sort in descending order. |
f652e84f23f2
revset: extract function that validates sort() arguments
Yuya Nishihara <yuya@tcha.org>
parents:
29364
diff
changeset
|
2445 |
|
f652e84f23f2
revset: extract function that validates sort() arguments
Yuya Nishihara <yuya@tcha.org>
parents:
29364
diff
changeset
|
2446 |
The keys can be: |
f652e84f23f2
revset: extract function that validates sort() arguments
Yuya Nishihara <yuya@tcha.org>
parents:
29364
diff
changeset
|
2447 |
|
f652e84f23f2
revset: extract function that validates sort() arguments
Yuya Nishihara <yuya@tcha.org>
parents:
29364
diff
changeset
|
2448 |
- ``rev`` for the revision number, |
f652e84f23f2
revset: extract function that validates sort() arguments
Yuya Nishihara <yuya@tcha.org>
parents:
29364
diff
changeset
|
2449 |
- ``branch`` for the branch name, |
f652e84f23f2
revset: extract function that validates sort() arguments
Yuya Nishihara <yuya@tcha.org>
parents:
29364
diff
changeset
|
2450 |
- ``desc`` for the commit message (description), |
f652e84f23f2
revset: extract function that validates sort() arguments
Yuya Nishihara <yuya@tcha.org>
parents:
29364
diff
changeset
|
2451 |
- ``user`` for user name (``author`` can be used as an alias), |
f652e84f23f2
revset: extract function that validates sort() arguments
Yuya Nishihara <yuya@tcha.org>
parents:
29364
diff
changeset
|
2452 |
- ``date`` for the commit date |
f652e84f23f2
revset: extract function that validates sort() arguments
Yuya Nishihara <yuya@tcha.org>
parents:
29364
diff
changeset
|
2453 |
- ``topo`` for a reverse topographical sort |
45686
17a12f53dd72
revset: add a `node` key for sorting
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
45428
diff
changeset
|
2454 |
- ``node`` the nodeid of the revision |
49447
6dbe74669eba
sort-revset: introduce a `random` variant
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49279
diff
changeset
|
2455 |
- ``random`` randomly shuffle revisions |
29365
f652e84f23f2
revset: extract function that validates sort() arguments
Yuya Nishihara <yuya@tcha.org>
parents:
29364
diff
changeset
|
2456 |
|
f652e84f23f2
revset: extract function that validates sort() arguments
Yuya Nishihara <yuya@tcha.org>
parents:
29364
diff
changeset
|
2457 |
The ``topo`` sort order cannot be combined with other sort keys. This sort |
f652e84f23f2
revset: extract function that validates sort() arguments
Yuya Nishihara <yuya@tcha.org>
parents:
29364
diff
changeset
|
2458 |
takes one optional argument, ``topo.firstbranch``, which takes a revset that |
f652e84f23f2
revset: extract function that validates sort() arguments
Yuya Nishihara <yuya@tcha.org>
parents:
29364
diff
changeset
|
2459 |
specifies what topographical branches to prioritize in the sort. |
f652e84f23f2
revset: extract function that validates sort() arguments
Yuya Nishihara <yuya@tcha.org>
parents:
29364
diff
changeset
|
2460 |
|
49447
6dbe74669eba
sort-revset: introduce a `random` variant
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49279
diff
changeset
|
2461 |
The ``random`` sort takes one optional ``random.seed`` argument to control |
6dbe74669eba
sort-revset: introduce a `random` variant
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49279
diff
changeset
|
2462 |
the pseudo-randomness of the result. |
29365
f652e84f23f2
revset: extract function that validates sort() arguments
Yuya Nishihara <yuya@tcha.org>
parents:
29364
diff
changeset
|
2463 |
""" |
f652e84f23f2
revset: extract function that validates sort() arguments
Yuya Nishihara <yuya@tcha.org>
parents:
29364
diff
changeset
|
2464 |
s, keyflags, opts = _getsortargs(x) |
34011
1b28525e6698
revset: remove order information from tree (API)
Jun Wu <quark@fb.com>
parents:
33855
diff
changeset
|
2465 |
revs = getset(repo, subset, s, order) |
29364
76a1a703e23d
revset: build dict of extra sort options before evaluating set
Yuya Nishihara <yuya@tcha.org>
parents:
29363
diff
changeset
|
2466 |
|
29946
285a8c3e53f2
revset: make sort() noop depending on ordering requirement (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
29945
diff
changeset
|
2467 |
if not keyflags or order != defineorder: |
20719
cce8fbedc82a
revset: changed sort method to use native sort implementation of smartsets
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20718
diff
changeset
|
2468 |
return revs |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2469 |
if len(keyflags) == 1 and keyflags[0][0] == b"rev": |
29363
2d18c61173f1
revset: build list of (key, reverse) pairs before sorting
Yuya Nishihara <yuya@tcha.org>
parents:
29362
diff
changeset
|
2470 |
revs.sort(reverse=keyflags[0][1]) |
20719
cce8fbedc82a
revset: changed sort method to use native sort implementation of smartsets
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20718
diff
changeset
|
2471 |
return revs |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2472 |
elif keyflags[0][0] == b"topo": |
29364
76a1a703e23d
revset: build dict of extra sort options before evaluating set
Yuya Nishihara <yuya@tcha.org>
parents:
29363
diff
changeset
|
2473 |
firstbranch = () |
49511
117dcc4a0e67
revset: handle wdir() in `sort(..., -topo)`
Matt Harbison <matt_harbison@yahoo.com>
parents:
49510
diff
changeset
|
2474 |
parentrevs = repo.changelog.parentrevs |
117dcc4a0e67
revset: handle wdir() in `sort(..., -topo)`
Matt Harbison <matt_harbison@yahoo.com>
parents:
49510
diff
changeset
|
2475 |
parentsfunc = parentrevs |
117dcc4a0e67
revset: handle wdir() in `sort(..., -topo)`
Matt Harbison <matt_harbison@yahoo.com>
parents:
49510
diff
changeset
|
2476 |
if wdirrev in revs: |
117dcc4a0e67
revset: handle wdir() in `sort(..., -topo)`
Matt Harbison <matt_harbison@yahoo.com>
parents:
49510
diff
changeset
|
2477 |
|
117dcc4a0e67
revset: handle wdir() in `sort(..., -topo)`
Matt Harbison <matt_harbison@yahoo.com>
parents:
49510
diff
changeset
|
2478 |
def parentsfunc(r): |
117dcc4a0e67
revset: handle wdir() in `sort(..., -topo)`
Matt Harbison <matt_harbison@yahoo.com>
parents:
49510
diff
changeset
|
2479 |
try: |
117dcc4a0e67
revset: handle wdir() in `sort(..., -topo)`
Matt Harbison <matt_harbison@yahoo.com>
parents:
49510
diff
changeset
|
2480 |
return parentrevs(r) |
117dcc4a0e67
revset: handle wdir() in `sort(..., -topo)`
Matt Harbison <matt_harbison@yahoo.com>
parents:
49510
diff
changeset
|
2481 |
except error.WdirUnsupported: |
117dcc4a0e67
revset: handle wdir() in `sort(..., -topo)`
Matt Harbison <matt_harbison@yahoo.com>
parents:
49510
diff
changeset
|
2482 |
return [p.rev() for p in repo[None].parents()] |
117dcc4a0e67
revset: handle wdir() in `sort(..., -topo)`
Matt Harbison <matt_harbison@yahoo.com>
parents:
49510
diff
changeset
|
2483 |
|
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2484 |
if b'topo.firstbranch' in opts: |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2485 |
firstbranch = getset(repo, subset, opts[b'topo.firstbranch']) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
2486 |
revs = baseset( |
49511
117dcc4a0e67
revset: handle wdir() in `sort(..., -topo)`
Matt Harbison <matt_harbison@yahoo.com>
parents:
49510
diff
changeset
|
2487 |
dagop.toposort(revs, parentsfunc, firstbranch), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
2488 |
istopo=True, |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
2489 |
) |
29363
2d18c61173f1
revset: build list of (key, reverse) pairs before sorting
Yuya Nishihara <yuya@tcha.org>
parents:
29362
diff
changeset
|
2490 |
if keyflags[0][1]: |
29348
2188f170f5b6
revset: add new topographical sort
Martijn Pieters <mjpieters@fb.com>
parents:
29347
diff
changeset
|
2491 |
revs.reverse() |
2188f170f5b6
revset: add new topographical sort
Martijn Pieters <mjpieters@fb.com>
parents:
29347
diff
changeset
|
2492 |
return revs |
2188f170f5b6
revset: add new topographical sort
Martijn Pieters <mjpieters@fb.com>
parents:
29347
diff
changeset
|
2493 |
|
29001
923fa9e06ea0
revset: make sort() do dumb multi-pass sorting for multiple keys (issue5218)
Yuya Nishihara <yuya@tcha.org>
parents:
28910
diff
changeset
|
2494 |
# sort() is guaranteed to be stable |
923fa9e06ea0
revset: make sort() do dumb multi-pass sorting for multiple keys (issue5218)
Yuya Nishihara <yuya@tcha.org>
parents:
28910
diff
changeset
|
2495 |
ctxs = [repo[r] for r in revs] |
29363
2d18c61173f1
revset: build list of (key, reverse) pairs before sorting
Yuya Nishihara <yuya@tcha.org>
parents:
29362
diff
changeset
|
2496 |
for k, reverse in reversed(keyflags): |
49447
6dbe74669eba
sort-revset: introduce a `random` variant
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49279
diff
changeset
|
2497 |
func = _sortkeyfuncs[k] |
6dbe74669eba
sort-revset: introduce a `random` variant
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49279
diff
changeset
|
2498 |
if k == b'random' and b'random.seed' in opts: |
6dbe74669eba
sort-revset: introduce a `random` variant
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49279
diff
changeset
|
2499 |
seed = opts[b'random.seed'] |
6dbe74669eba
sort-revset: introduce a `random` variant
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49279
diff
changeset
|
2500 |
r = random.Random(seed) |
6dbe74669eba
sort-revset: introduce a `random` variant
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49279
diff
changeset
|
2501 |
func = functools.partial(func, gen=r) |
6dbe74669eba
sort-revset: introduce a `random` variant
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
49279
diff
changeset
|
2502 |
ctxs.sort(key=func, reverse=reverse) |
29001
923fa9e06ea0
revset: make sort() do dumb multi-pass sorting for multiple keys (issue5218)
Yuya Nishihara <yuya@tcha.org>
parents:
28910
diff
changeset
|
2503 |
return baseset([c.rev() for c in ctxs]) |
11275 | 2504 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
2505 |
|
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2506 |
@predicate(b'subrepo([pattern])') |
24446
582cfcc843c7
revset: add the 'subrepo' symbol
Matt Harbison <matt_harbison@yahoo.com>
parents:
24419
diff
changeset
|
2507 |
def subrepo(repo, subset, x): |
27584
fc7c8cac6a4b
revset: use decorator to register a function as revset predicate
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27517
diff
changeset
|
2508 |
"""Changesets that add, modify or remove the given subrepo. If no subrepo |
24446
582cfcc843c7
revset: add the 'subrepo' symbol
Matt Harbison <matt_harbison@yahoo.com>
parents:
24419
diff
changeset
|
2509 |
pattern is named, any subrepo changes are returned. |
582cfcc843c7
revset: add the 'subrepo' symbol
Matt Harbison <matt_harbison@yahoo.com>
parents:
24419
diff
changeset
|
2510 |
""" |
582cfcc843c7
revset: add the 'subrepo' symbol
Matt Harbison <matt_harbison@yahoo.com>
parents:
24419
diff
changeset
|
2511 |
# i18n: "subrepo" is a keyword |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2512 |
args = getargs(x, 0, 1, _(b'subrepo takes at most one argument')) |
28272
760f9d04842a
revset: define "pat" variable unconditionally in subrepo()
Yuya Nishihara <yuya@tcha.org>
parents:
28271
diff
changeset
|
2513 |
pat = None |
24446
582cfcc843c7
revset: add the 'subrepo' symbol
Matt Harbison <matt_harbison@yahoo.com>
parents:
24419
diff
changeset
|
2514 |
if len(args) != 0: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2515 |
pat = getstring(args[0], _(b"subrepo requires a pattern")) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2516 |
|
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2517 |
m = matchmod.exact([b'.hgsubstate']) |
24446
582cfcc843c7
revset: add the 'subrepo' symbol
Matt Harbison <matt_harbison@yahoo.com>
parents:
24419
diff
changeset
|
2518 |
|
582cfcc843c7
revset: add the 'subrepo' symbol
Matt Harbison <matt_harbison@yahoo.com>
parents:
24419
diff
changeset
|
2519 |
def submatches(names): |
37084
f0b6fbea00cf
stringutil: bulk-replace call sites to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
37001
diff
changeset
|
2520 |
k, p, m = stringutil.stringmatcher(pat) |
24446
582cfcc843c7
revset: add the 'subrepo' symbol
Matt Harbison <matt_harbison@yahoo.com>
parents:
24419
diff
changeset
|
2521 |
for name in names: |
582cfcc843c7
revset: add the 'subrepo' symbol
Matt Harbison <matt_harbison@yahoo.com>
parents:
24419
diff
changeset
|
2522 |
if m(name): |
582cfcc843c7
revset: add the 'subrepo' symbol
Matt Harbison <matt_harbison@yahoo.com>
parents:
24419
diff
changeset
|
2523 |
yield name |
582cfcc843c7
revset: add the 'subrepo' symbol
Matt Harbison <matt_harbison@yahoo.com>
parents:
24419
diff
changeset
|
2524 |
|
582cfcc843c7
revset: add the 'subrepo' symbol
Matt Harbison <matt_harbison@yahoo.com>
parents:
24419
diff
changeset
|
2525 |
def matches(x): |
582cfcc843c7
revset: add the 'subrepo' symbol
Matt Harbison <matt_harbison@yahoo.com>
parents:
24419
diff
changeset
|
2526 |
c = repo[x] |
582cfcc843c7
revset: add the 'subrepo' symbol
Matt Harbison <matt_harbison@yahoo.com>
parents:
24419
diff
changeset
|
2527 |
s = repo.status(c.p1().node(), c.node(), match=m) |
582cfcc843c7
revset: add the 'subrepo' symbol
Matt Harbison <matt_harbison@yahoo.com>
parents:
24419
diff
changeset
|
2528 |
|
28272
760f9d04842a
revset: define "pat" variable unconditionally in subrepo()
Yuya Nishihara <yuya@tcha.org>
parents:
28271
diff
changeset
|
2529 |
if pat is None: |
24446
582cfcc843c7
revset: add the 'subrepo' symbol
Matt Harbison <matt_harbison@yahoo.com>
parents:
24419
diff
changeset
|
2530 |
return s.added or s.modified or s.removed |
582cfcc843c7
revset: add the 'subrepo' symbol
Matt Harbison <matt_harbison@yahoo.com>
parents:
24419
diff
changeset
|
2531 |
|
582cfcc843c7
revset: add the 'subrepo' symbol
Matt Harbison <matt_harbison@yahoo.com>
parents:
24419
diff
changeset
|
2532 |
if s.added: |
25149
3f0744eeaeaf
cleanup: use __builtins__.any instead of util.any
Augie Fackler <augie@google.com>
parents:
25146
diff
changeset
|
2533 |
return any(submatches(c.substate.keys())) |
24446
582cfcc843c7
revset: add the 'subrepo' symbol
Matt Harbison <matt_harbison@yahoo.com>
parents:
24419
diff
changeset
|
2534 |
|
582cfcc843c7
revset: add the 'subrepo' symbol
Matt Harbison <matt_harbison@yahoo.com>
parents:
24419
diff
changeset
|
2535 |
if s.modified: |
582cfcc843c7
revset: add the 'subrepo' symbol
Matt Harbison <matt_harbison@yahoo.com>
parents:
24419
diff
changeset
|
2536 |
subs = set(c.p1().substate.keys()) |
582cfcc843c7
revset: add the 'subrepo' symbol
Matt Harbison <matt_harbison@yahoo.com>
parents:
24419
diff
changeset
|
2537 |
subs.update(c.substate.keys()) |
582cfcc843c7
revset: add the 'subrepo' symbol
Matt Harbison <matt_harbison@yahoo.com>
parents:
24419
diff
changeset
|
2538 |
|
582cfcc843c7
revset: add the 'subrepo' symbol
Matt Harbison <matt_harbison@yahoo.com>
parents:
24419
diff
changeset
|
2539 |
for path in submatches(subs): |
582cfcc843c7
revset: add the 'subrepo' symbol
Matt Harbison <matt_harbison@yahoo.com>
parents:
24419
diff
changeset
|
2540 |
if c.p1().substate.get(path) != c.substate.get(path): |
582cfcc843c7
revset: add the 'subrepo' symbol
Matt Harbison <matt_harbison@yahoo.com>
parents:
24419
diff
changeset
|
2541 |
return True |
582cfcc843c7
revset: add the 'subrepo' symbol
Matt Harbison <matt_harbison@yahoo.com>
parents:
24419
diff
changeset
|
2542 |
|
582cfcc843c7
revset: add the 'subrepo' symbol
Matt Harbison <matt_harbison@yahoo.com>
parents:
24419
diff
changeset
|
2543 |
if s.removed: |
25149
3f0744eeaeaf
cleanup: use __builtins__.any instead of util.any
Augie Fackler <augie@google.com>
parents:
25146
diff
changeset
|
2544 |
return any(submatches(c.p1().substate.keys())) |
24446
582cfcc843c7
revset: add the 'subrepo' symbol
Matt Harbison <matt_harbison@yahoo.com>
parents:
24419
diff
changeset
|
2545 |
|
582cfcc843c7
revset: add the 'subrepo' symbol
Matt Harbison <matt_harbison@yahoo.com>
parents:
24419
diff
changeset
|
2546 |
return False |
582cfcc843c7
revset: add the 'subrepo' symbol
Matt Harbison <matt_harbison@yahoo.com>
parents:
24419
diff
changeset
|
2547 |
|
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2548 |
return subset.filter(matches, condrepr=(b'<subrepo %r>', pat)) |
24446
582cfcc843c7
revset: add the 'subrepo' symbol
Matt Harbison <matt_harbison@yahoo.com>
parents:
24419
diff
changeset
|
2549 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
2550 |
|
33377 | 2551 |
def _mapbynodefunc(repo, s, f): |
2552 |
"""(repo, smartset, [node] -> [node]) -> smartset |
|
2553 |
||
2554 |
Helper method to map a smartset to another smartset given a function only |
|
2555 |
talking about nodes. Handles converting between rev numbers and nodes, and |
|
2556 |
filtering. |
|
2557 |
""" |
|
2558 |
cl = repo.unfiltered().changelog |
|
43561
45d123d84011
index: use `index.get_rev` in `revset._mapbynodefunc`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43117
diff
changeset
|
2559 |
torev = cl.index.get_rev |
33377 | 2560 |
tonode = cl.node |
44452
9d2b2df2c2ba
cleanup: run pyupgrade on our source tree to clean up varying things
Augie Fackler <augie@google.com>
parents:
44343
diff
changeset
|
2561 |
result = {torev(n) for n in f(tonode(r) for r in s)} |
43561
45d123d84011
index: use `index.get_rev` in `revset._mapbynodefunc`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43117
diff
changeset
|
2562 |
result.discard(None) |
33377 | 2563 |
return smartset.baseset(result - repo.changelog.filteredrevs) |
2564 |
||
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
2565 |
|
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2566 |
@predicate(b'successors(set)', safe=True) |
33377 | 2567 |
def successors(repo, subset, x): |
44699
bcc1846e0f2b
revset: mark `successors()` experimental
Matt Harbison <matt_harbison@yahoo.com>
parents:
44698
diff
changeset
|
2568 |
"""All successors for set, including the given set themselves. |
bcc1846e0f2b
revset: mark `successors()` experimental
Matt Harbison <matt_harbison@yahoo.com>
parents:
44698
diff
changeset
|
2569 |
(EXPERIMENTAL)""" |
33377 | 2570 |
s = getset(repo, fullreposet(repo), x) |
2571 |
f = lambda nodes: obsutil.allsuccessors(repo.obsstore, nodes) |
|
2572 |
d = _mapbynodefunc(repo, s, f) |
|
2573 |
return subset & d |
|
2574 |
||
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
2575 |
|
30782
db38cfc7c29d
revset: stop lowercasing the regex pattern for 'author'
Matt Harbison <matt_harbison@yahoo.com>
parents:
30772
diff
changeset
|
2576 |
def _substringmatcher(pattern, casesensitive=True): |
37084
f0b6fbea00cf
stringutil: bulk-replace call sites to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
37001
diff
changeset
|
2577 |
kind, pattern, matcher = stringutil.stringmatcher( |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
2578 |
pattern, casesensitive=casesensitive |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
2579 |
) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2580 |
if kind == b'literal': |
30782
db38cfc7c29d
revset: stop lowercasing the regex pattern for 'author'
Matt Harbison <matt_harbison@yahoo.com>
parents:
30772
diff
changeset
|
2581 |
if not casesensitive: |
db38cfc7c29d
revset: stop lowercasing the regex pattern for 'author'
Matt Harbison <matt_harbison@yahoo.com>
parents:
30772
diff
changeset
|
2582 |
pattern = encoding.lower(pattern) |
db38cfc7c29d
revset: stop lowercasing the regex pattern for 'author'
Matt Harbison <matt_harbison@yahoo.com>
parents:
30772
diff
changeset
|
2583 |
matcher = lambda s: pattern in encoding.lower(s) |
db38cfc7c29d
revset: stop lowercasing the regex pattern for 'author'
Matt Harbison <matt_harbison@yahoo.com>
parents:
30772
diff
changeset
|
2584 |
else: |
db38cfc7c29d
revset: stop lowercasing the regex pattern for 'author'
Matt Harbison <matt_harbison@yahoo.com>
parents:
30772
diff
changeset
|
2585 |
matcher = lambda s: pattern in s |
16823
b23bacb230c9
revset: add pattern matching to the 'user' revset expression
Simon King <simon@simonking.org.uk>
parents:
16822
diff
changeset
|
2586 |
return kind, pattern, matcher |
16819
5260a9e93113
revset: add helper function for matching strings to patterns
Simon King <simon@simonking.org.uk>
parents:
16803
diff
changeset
|
2587 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
2588 |
|
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2589 |
@predicate(b'tag([name])', safe=True) |
12715
33820dccbea4
revset: rename tagged() to tag() and allow it to take an optional tag name
Augie Fackler <durin42@gmail.com>
parents:
12616
diff
changeset
|
2590 |
def tag(repo, subset, x): |
27584
fc7c8cac6a4b
revset: use decorator to register a function as revset predicate
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27517
diff
changeset
|
2591 |
"""The specified tag by name, or all tagged revisions if no name is given. |
20824
c57c9cece645
revset: document the regular expression support for tag(name)
Matt Harbison <matt_harbison@yahoo.com>
parents:
20289
diff
changeset
|
2592 |
|
30784
5dd67f0993ce
help: eliminate duplicate text for revset string patterns
Matt Harbison <matt_harbison@yahoo.com>
parents:
30783
diff
changeset
|
2593 |
Pattern matching is supported for `name`. See |
30799
0b49449a01f4
help: use :hg: role and canonical name to point to revset string patterns
Yuya Nishihara <yuya@tcha.org>
parents:
30784
diff
changeset
|
2594 |
:hg:`help revisions.patterns`. |
12821
165079e564f0
revsets: generate predicate help dynamically
Patrick Mezard <pmezard@gmail.com>
parents:
12815
diff
changeset
|
2595 |
""" |
12815
079a618ea89d
revset: add translator comments to i18n strings
Martin Geisler <mg@lazybytes.net>
parents:
12786
diff
changeset
|
2596 |
# i18n: "tag" is a keyword |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2597 |
args = getargs(x, 0, 1, _(b"tag takes one or no arguments")) |
11280
a5eb0bf7e158
revset: add tagged predicate
Matt Mackall <mpm@selenic.com>
parents:
11279
diff
changeset
|
2598 |
cl = repo.changelog |
12715
33820dccbea4
revset: rename tagged() to tag() and allow it to take an optional tag name
Augie Fackler <durin42@gmail.com>
parents:
12616
diff
changeset
|
2599 |
if args: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
2600 |
pattern = getstring( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
2601 |
args[0], |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
2602 |
# i18n: "tag" is a keyword |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2603 |
_(b'the argument to tag must be a string'), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
2604 |
) |
37084
f0b6fbea00cf
stringutil: bulk-replace call sites to point to new module
Yuya Nishihara <yuya@tcha.org>
parents:
37001
diff
changeset
|
2605 |
kind, pattern, matcher = stringutil.stringmatcher(pattern) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2606 |
if kind == b'literal': |
16825
b6ef1395d77f
revset: avoid validating all tag nodes for tag(x)
Matt Mackall <mpm@selenic.com>
parents:
16824
diff
changeset
|
2607 |
# avoid resolving all tags |
b6ef1395d77f
revset: avoid validating all tag nodes for tag(x)
Matt Mackall <mpm@selenic.com>
parents:
16824
diff
changeset
|
2608 |
tn = repo._tagscache.tags.get(pattern, None) |
b6ef1395d77f
revset: avoid validating all tag nodes for tag(x)
Matt Mackall <mpm@selenic.com>
parents:
16824
diff
changeset
|
2609 |
if tn is None: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
2610 |
raise error.RepoLookupError( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2611 |
_(b"tag '%s' does not exist") % pattern |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
2612 |
) |
32291
bd872f64a8ba
cleanup: use set literals
Martin von Zweigbergk <martinvonz@google.com>
parents:
32085
diff
changeset
|
2613 |
s = {repo[tn].rev()} |
16820
20f55613fb2a
revset: add pattern matching to 'tag' revset expression
Simon King <simon@simonking.org.uk>
parents:
16819
diff
changeset
|
2614 |
else: |
32291
bd872f64a8ba
cleanup: use set literals
Martin von Zweigbergk <martinvonz@google.com>
parents:
32085
diff
changeset
|
2615 |
s = {cl.rev(n) for t, n in repo.tagslist() if matcher(t)} |
12715
33820dccbea4
revset: rename tagged() to tag() and allow it to take an optional tag name
Augie Fackler <durin42@gmail.com>
parents:
12616
diff
changeset
|
2616 |
else: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2617 |
s = {cl.rev(n) for t, n in repo.tagslist() if t != b'tip'} |
20367
2ac278aab2b4
revset: added intersection to baseset class
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20366
diff
changeset
|
2618 |
return subset & s |
11280
a5eb0bf7e158
revset: add tagged predicate
Matt Mackall <mpm@selenic.com>
parents:
11279
diff
changeset
|
2619 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
2620 |
|
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2621 |
@predicate(b'tagged', safe=True) |
12821
165079e564f0
revsets: generate predicate help dynamically
Patrick Mezard <pmezard@gmail.com>
parents:
12815
diff
changeset
|
2622 |
def tagged(repo, subset, x): |
165079e564f0
revsets: generate predicate help dynamically
Patrick Mezard <pmezard@gmail.com>
parents:
12815
diff
changeset
|
2623 |
return tag(repo, subset, x) |
165079e564f0
revsets: generate predicate help dynamically
Patrick Mezard <pmezard@gmail.com>
parents:
12815
diff
changeset
|
2624 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
2625 |
|
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2626 |
@predicate(b'orphan()', safe=True) |
33774
9dcc3529e002
revset: rename unstable into orphan
Boris Feld <boris.feld@octobus.net>
parents:
33417
diff
changeset
|
2627 |
def orphan(repo, subset, x): |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45750
diff
changeset
|
2628 |
"""Non-obsolete changesets with obsolete ancestors. (EXPERIMENTAL)""" |
33774
9dcc3529e002
revset: rename unstable into orphan
Boris Feld <boris.feld@octobus.net>
parents:
33417
diff
changeset
|
2629 |
# i18n: "orphan" is a keyword |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2630 |
getargs(x, 0, 0, _(b"orphan takes no arguments")) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2631 |
orphan = obsmod.getrevs(repo, b'orphan') |
33777
d4b7496f7d0b
obsolete: rename unstable volatile set into orphan volatile set
Boris Feld <boris.feld@octobus.net>
parents:
33776
diff
changeset
|
2632 |
return subset & orphan |
17171
9c750c3e4fac
obsolete: compute unstable changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17170
diff
changeset
|
2633 |
|
9c750c3e4fac
obsolete: compute unstable changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17170
diff
changeset
|
2634 |
|
44691
48b99af7b4b3
revset: import `unstable()` from the evolve extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
44584
diff
changeset
|
2635 |
@predicate(b'unstable()', safe=True) |
48b99af7b4b3
revset: import `unstable()` from the evolve extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
44584
diff
changeset
|
2636 |
def unstable(repo, subset, x): |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45750
diff
changeset
|
2637 |
"""Changesets with instabilities. (EXPERIMENTAL)""" |
44691
48b99af7b4b3
revset: import `unstable()` from the evolve extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
44584
diff
changeset
|
2638 |
# i18n: "unstable" is a keyword |
48b99af7b4b3
revset: import `unstable()` from the evolve extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
44584
diff
changeset
|
2639 |
getargs(x, 0, 0, b'unstable takes no arguments') |
48b99af7b4b3
revset: import `unstable()` from the evolve extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
44584
diff
changeset
|
2640 |
_unstable = set() |
48b99af7b4b3
revset: import `unstable()` from the evolve extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
44584
diff
changeset
|
2641 |
_unstable.update(obsmod.getrevs(repo, b'orphan')) |
48b99af7b4b3
revset: import `unstable()` from the evolve extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
44584
diff
changeset
|
2642 |
_unstable.update(obsmod.getrevs(repo, b'phasedivergent')) |
48b99af7b4b3
revset: import `unstable()` from the evolve extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
44584
diff
changeset
|
2643 |
_unstable.update(obsmod.getrevs(repo, b'contentdivergent')) |
44711
637eb7f7559b
revset: remove explicit sort() from unstable()
Yuya Nishihara <yuya@tcha.org>
parents:
44710
diff
changeset
|
2644 |
return subset & baseset(_unstable) |
44691
48b99af7b4b3
revset: import `unstable()` from the evolve extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
44584
diff
changeset
|
2645 |
|
48b99af7b4b3
revset: import `unstable()` from the evolve extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
44584
diff
changeset
|
2646 |
|
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2647 |
@predicate(b'user(string)', safe=True, weight=10) |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
2648 |
def user(repo, subset, x): |
27584
fc7c8cac6a4b
revset: use decorator to register a function as revset predicate
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
27517
diff
changeset
|
2649 |
"""User name contains string. The match is case-insensitive. |
16823
b23bacb230c9
revset: add pattern matching to the 'user' revset expression
Simon King <simon@simonking.org.uk>
parents:
16822
diff
changeset
|
2650 |
|
30784
5dd67f0993ce
help: eliminate duplicate text for revset string patterns
Matt Harbison <matt_harbison@yahoo.com>
parents:
30783
diff
changeset
|
2651 |
Pattern matching is supported for `string`. See |
30799
0b49449a01f4
help: use :hg: role and canonical name to point to revset string patterns
Yuya Nishihara <yuya@tcha.org>
parents:
30784
diff
changeset
|
2652 |
:hg:`help revisions.patterns`. |
13359
87f248e78173
bookmarks: move revset support to core
Matt Mackall <mpm@selenic.com>
parents:
13031
diff
changeset
|
2653 |
""" |
13915
8f81d6f4047f
revset: rearrange code so functions are sorted alphabetically
Idan Kamara <idankk86@gmail.com>
parents:
13914
diff
changeset
|
2654 |
return author(repo, subset, x) |
13359
87f248e78173
bookmarks: move revset support to core
Matt Mackall <mpm@selenic.com>
parents:
13031
diff
changeset
|
2655 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
2656 |
|
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2657 |
@predicate(b'wdir()', safe=True, weight=0) |
24419
0e41f110e69e
revset: add wdir() function to specify workingctx revision by command
Yuya Nishihara <yuya@tcha.org>
parents:
24374
diff
changeset
|
2658 |
def wdir(repo, subset, x): |
30701
8b1d87243710
revset: document wdir() as an experimental function
Yuya Nishihara <yuya@tcha.org>
parents:
30700
diff
changeset
|
2659 |
"""Working directory. (EXPERIMENTAL)""" |
24419
0e41f110e69e
revset: add wdir() function to specify workingctx revision by command
Yuya Nishihara <yuya@tcha.org>
parents:
24374
diff
changeset
|
2660 |
# i18n: "wdir" is a keyword |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2661 |
getargs(x, 0, 0, _(b"wdir takes no arguments")) |
46113
59fa3890d40a
node: import symbols explicitly
Joerg Sonnenberger <joerg@bec.de>
parents:
45942
diff
changeset
|
2662 |
if wdirrev in subset or isinstance(subset, fullreposet): |
59fa3890d40a
node: import symbols explicitly
Joerg Sonnenberger <joerg@bec.de>
parents:
45942
diff
changeset
|
2663 |
return baseset([wdirrev]) |
24419
0e41f110e69e
revset: add wdir() function to specify workingctx revision by command
Yuya Nishihara <yuya@tcha.org>
parents:
24374
diff
changeset
|
2664 |
return baseset() |
0e41f110e69e
revset: add wdir() function to specify workingctx revision by command
Yuya Nishihara <yuya@tcha.org>
parents:
24374
diff
changeset
|
2665 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
2666 |
|
29935
e34cd85dc5b1
revset: fix order of nested '_(|int|hex)list' expression (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
29934
diff
changeset
|
2667 |
def _orderedlist(repo, subset, x): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2668 |
s = getstring(x, b"internal error") |
15898
6902e13ddd03
revset: optimize building large lists in formatrevspec
Matt Mackall <mpm@selenic.com>
parents:
15837
diff
changeset
|
2669 |
if not s: |
22802
1fcd361efaf4
baseset: use default value instead of [] when possible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22801
diff
changeset
|
2670 |
return baseset() |
25341
9d6cc87bd507
revset: make internal _list() expression remove duplicated revisions
Yuya Nishihara <yuya@tcha.org>
parents:
25309
diff
changeset
|
2671 |
# remove duplicates here. it's difficult for caller to deduplicate sets |
9d6cc87bd507
revset: make internal _list() expression remove duplicated revisions
Yuya Nishihara <yuya@tcha.org>
parents:
25309
diff
changeset
|
2672 |
# because different symbols can point to the same rev. |
25344
ceaf04bb14ff
revset: add fast path for _list() of integer revisions
Yuya Nishihara <yuya@tcha.org>
parents:
25343
diff
changeset
|
2673 |
cl = repo.changelog |
25341
9d6cc87bd507
revset: make internal _list() expression remove duplicated revisions
Yuya Nishihara <yuya@tcha.org>
parents:
25309
diff
changeset
|
2674 |
ls = [] |
9d6cc87bd507
revset: make internal _list() expression remove duplicated revisions
Yuya Nishihara <yuya@tcha.org>
parents:
25309
diff
changeset
|
2675 |
seen = set() |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2676 |
for t in s.split(b'\0'): |
25344
ceaf04bb14ff
revset: add fast path for _list() of integer revisions
Yuya Nishihara <yuya@tcha.org>
parents:
25343
diff
changeset
|
2677 |
try: |
ceaf04bb14ff
revset: add fast path for _list() of integer revisions
Yuya Nishihara <yuya@tcha.org>
parents:
25343
diff
changeset
|
2678 |
# fast path for integer revision |
ceaf04bb14ff
revset: add fast path for _list() of integer revisions
Yuya Nishihara <yuya@tcha.org>
parents:
25343
diff
changeset
|
2679 |
r = int(t) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2680 |
if (b'%d' % r) != t or r not in cl: |
25344
ceaf04bb14ff
revset: add fast path for _list() of integer revisions
Yuya Nishihara <yuya@tcha.org>
parents:
25343
diff
changeset
|
2681 |
raise ValueError |
26143
42bb1812686f
revset: fix resolving strings from a list
Durham Goode <durham@fb.com>
parents:
26102
diff
changeset
|
2682 |
revs = [r] |
25344
ceaf04bb14ff
revset: add fast path for _list() of integer revisions
Yuya Nishihara <yuya@tcha.org>
parents:
25343
diff
changeset
|
2683 |
except ValueError: |
34011
1b28525e6698
revset: remove order information from tree (API)
Jun Wu <quark@fb.com>
parents:
33855
diff
changeset
|
2684 |
revs = stringset(repo, subset, t, defineorder) |
26143
42bb1812686f
revset: fix resolving strings from a list
Durham Goode <durham@fb.com>
parents:
26102
diff
changeset
|
2685 |
|
42bb1812686f
revset: fix resolving strings from a list
Durham Goode <durham@fb.com>
parents:
26102
diff
changeset
|
2686 |
for r in revs: |
42bb1812686f
revset: fix resolving strings from a list
Durham Goode <durham@fb.com>
parents:
26102
diff
changeset
|
2687 |
if r in seen: |
42bb1812686f
revset: fix resolving strings from a list
Durham Goode <durham@fb.com>
parents:
26102
diff
changeset
|
2688 |
continue |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
2689 |
if ( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
2690 |
r in subset |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
2691 |
or r in _virtualrevs |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
2692 |
and isinstance(subset, fullreposet) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
2693 |
): |
26143
42bb1812686f
revset: fix resolving strings from a list
Durham Goode <durham@fb.com>
parents:
26102
diff
changeset
|
2694 |
ls.append(r) |
42bb1812686f
revset: fix resolving strings from a list
Durham Goode <durham@fb.com>
parents:
26102
diff
changeset
|
2695 |
seen.add(r) |
25341
9d6cc87bd507
revset: make internal _list() expression remove duplicated revisions
Yuya Nishihara <yuya@tcha.org>
parents:
25309
diff
changeset
|
2696 |
return baseset(ls) |
15898
6902e13ddd03
revset: optimize building large lists in formatrevspec
Matt Mackall <mpm@selenic.com>
parents:
15837
diff
changeset
|
2697 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
2698 |
|
20566
98024950ade0
revset: added _intlist method to replace _list for %ld
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20552
diff
changeset
|
2699 |
# for internal use |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2700 |
@predicate(b'_list', safe=True, takeorder=True) |
29935
e34cd85dc5b1
revset: fix order of nested '_(|int|hex)list' expression (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
29934
diff
changeset
|
2701 |
def _list(repo, subset, x, order): |
e34cd85dc5b1
revset: fix order of nested '_(|int|hex)list' expression (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
29934
diff
changeset
|
2702 |
if order == followorder: |
e34cd85dc5b1
revset: fix order of nested '_(|int|hex)list' expression (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
29934
diff
changeset
|
2703 |
# slow path to take the subset order |
e34cd85dc5b1
revset: fix order of nested '_(|int|hex)list' expression (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
29934
diff
changeset
|
2704 |
return subset & _orderedlist(repo, fullreposet(repo), x) |
e34cd85dc5b1
revset: fix order of nested '_(|int|hex)list' expression (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
29934
diff
changeset
|
2705 |
else: |
e34cd85dc5b1
revset: fix order of nested '_(|int|hex)list' expression (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
29934
diff
changeset
|
2706 |
return _orderedlist(repo, subset, x) |
e34cd85dc5b1
revset: fix order of nested '_(|int|hex)list' expression (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
29934
diff
changeset
|
2707 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
2708 |
|
29935
e34cd85dc5b1
revset: fix order of nested '_(|int|hex)list' expression (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
29934
diff
changeset
|
2709 |
def _orderedintlist(repo, subset, x): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2710 |
s = getstring(x, b"internal error") |
20566
98024950ade0
revset: added _intlist method to replace _list for %ld
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20552
diff
changeset
|
2711 |
if not s: |
22802
1fcd361efaf4
baseset: use default value instead of [] when possible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22801
diff
changeset
|
2712 |
return baseset() |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2713 |
ls = [int(r) for r in s.split(b'\0')] |
22876
d52ca940c665
revset-_intlist: remove usage of `set()`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22875
diff
changeset
|
2714 |
s = subset |
20566
98024950ade0
revset: added _intlist method to replace _list for %ld
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20552
diff
changeset
|
2715 |
return baseset([r for r in ls if r in s]) |
98024950ade0
revset: added _intlist method to replace _list for %ld
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20552
diff
changeset
|
2716 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
2717 |
|
20569
0d4be103c734
revset: added _hexlist method to replace _list for %ln
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20566
diff
changeset
|
2718 |
# for internal use |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2719 |
@predicate(b'_intlist', safe=True, takeorder=True, weight=0) |
29935
e34cd85dc5b1
revset: fix order of nested '_(|int|hex)list' expression (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
29934
diff
changeset
|
2720 |
def _intlist(repo, subset, x, order): |
e34cd85dc5b1
revset: fix order of nested '_(|int|hex)list' expression (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
29934
diff
changeset
|
2721 |
if order == followorder: |
e34cd85dc5b1
revset: fix order of nested '_(|int|hex)list' expression (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
29934
diff
changeset
|
2722 |
# slow path to take the subset order |
e34cd85dc5b1
revset: fix order of nested '_(|int|hex)list' expression (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
29934
diff
changeset
|
2723 |
return subset & _orderedintlist(repo, fullreposet(repo), x) |
e34cd85dc5b1
revset: fix order of nested '_(|int|hex)list' expression (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
29934
diff
changeset
|
2724 |
else: |
e34cd85dc5b1
revset: fix order of nested '_(|int|hex)list' expression (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
29934
diff
changeset
|
2725 |
return _orderedintlist(repo, subset, x) |
e34cd85dc5b1
revset: fix order of nested '_(|int|hex)list' expression (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
29934
diff
changeset
|
2726 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
2727 |
|
29935
e34cd85dc5b1
revset: fix order of nested '_(|int|hex)list' expression (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
29934
diff
changeset
|
2728 |
def _orderedhexlist(repo, subset, x): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2729 |
s = getstring(x, b"internal error") |
20569
0d4be103c734
revset: added _hexlist method to replace _list for %ln
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20566
diff
changeset
|
2730 |
if not s: |
22802
1fcd361efaf4
baseset: use default value instead of [] when possible
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22801
diff
changeset
|
2731 |
return baseset() |
20569
0d4be103c734
revset: added _hexlist method to replace _list for %ln
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20566
diff
changeset
|
2732 |
cl = repo.changelog |
46113
59fa3890d40a
node: import symbols explicitly
Joerg Sonnenberger <joerg@bec.de>
parents:
45942
diff
changeset
|
2733 |
ls = [cl.rev(bin(r)) for r in s.split(b'\0')] |
22877
489d2f3688c9
revset-_hexlist: remove usage of `set()`
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22876
diff
changeset
|
2734 |
s = subset |
20569
0d4be103c734
revset: added _hexlist method to replace _list for %ln
Lucas Moscovicz <lmoscovicz@fb.com>
parents:
20566
diff
changeset
|
2735 |
return baseset([r for r in ls if r in s]) |
15898
6902e13ddd03
revset: optimize building large lists in formatrevspec
Matt Mackall <mpm@selenic.com>
parents:
15837
diff
changeset
|
2736 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
2737 |
|
29935
e34cd85dc5b1
revset: fix order of nested '_(|int|hex)list' expression (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
29934
diff
changeset
|
2738 |
# for internal use |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2739 |
@predicate(b'_hexlist', safe=True, takeorder=True) |
29935
e34cd85dc5b1
revset: fix order of nested '_(|int|hex)list' expression (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
29934
diff
changeset
|
2740 |
def _hexlist(repo, subset, x, order): |
e34cd85dc5b1
revset: fix order of nested '_(|int|hex)list' expression (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
29934
diff
changeset
|
2741 |
if order == followorder: |
e34cd85dc5b1
revset: fix order of nested '_(|int|hex)list' expression (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
29934
diff
changeset
|
2742 |
# slow path to take the subset order |
e34cd85dc5b1
revset: fix order of nested '_(|int|hex)list' expression (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
29934
diff
changeset
|
2743 |
return subset & _orderedhexlist(repo, fullreposet(repo), x) |
e34cd85dc5b1
revset: fix order of nested '_(|int|hex)list' expression (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
29934
diff
changeset
|
2744 |
else: |
e34cd85dc5b1
revset: fix order of nested '_(|int|hex)list' expression (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
29934
diff
changeset
|
2745 |
return _orderedhexlist(repo, subset, x) |
e34cd85dc5b1
revset: fix order of nested '_(|int|hex)list' expression (BC)
Yuya Nishihara <yuya@tcha.org>
parents:
29934
diff
changeset
|
2746 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
2747 |
|
11275 | 2748 |
methods = { |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2749 |
b"range": rangeset, |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2750 |
b"rangeall": rangeall, |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2751 |
b"rangepre": rangepre, |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2752 |
b"rangepost": rangepost, |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2753 |
b"dagrange": dagrange, |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2754 |
b"string": stringset, |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2755 |
b"symbol": stringset, |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2756 |
b"and": andset, |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2757 |
b"andsmally": andsmallyset, |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2758 |
b"or": orset, |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2759 |
b"not": notset, |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2760 |
b"difference": differenceset, |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2761 |
b"relation": relationset, |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2762 |
b"relsubscript": relsubscriptset, |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2763 |
b"subscript": subscriptset, |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2764 |
b"list": listset, |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2765 |
b"keyvalue": keyvaluepair, |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2766 |
b"func": func, |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2767 |
b"ancestor": ancestorspec, |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2768 |
b"parent": parentspec, |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2769 |
b"parentpost": parentpost, |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2770 |
b"smartset": rawsmartset, |
11275 | 2771 |
} |
2772 |
||
44710
eca82eb9d777
revset: implement a simple 'foo#generations' expression
Anton Shestakov <av6@dwimlabs.net>
parents:
44709
diff
changeset
|
2773 |
relations = { |
eca82eb9d777
revset: implement a simple 'foo#generations' expression
Anton Shestakov <av6@dwimlabs.net>
parents:
44709
diff
changeset
|
2774 |
b"g": generationsrel, |
eca82eb9d777
revset: implement a simple 'foo#generations' expression
Anton Shestakov <av6@dwimlabs.net>
parents:
44709
diff
changeset
|
2775 |
b"generations": generationsrel, |
eca82eb9d777
revset: implement a simple 'foo#generations' expression
Anton Shestakov <av6@dwimlabs.net>
parents:
44709
diff
changeset
|
2776 |
} |
eca82eb9d777
revset: implement a simple 'foo#generations' expression
Anton Shestakov <av6@dwimlabs.net>
parents:
44709
diff
changeset
|
2777 |
|
40931
e54bfde922f2
revset: move subscript relation functions to its own dict
Anton Shestakov <av6@dwimlabs.net>
parents:
40534
diff
changeset
|
2778 |
subscriptrelations = { |
44709
8859de3e83dc
revset: rename generationsrel() to generationssubrel()
Anton Shestakov <av6@dwimlabs.net>
parents:
44700
diff
changeset
|
2779 |
b"g": generationssubrel, |
8859de3e83dc
revset: rename generationsrel() to generationssubrel()
Anton Shestakov <av6@dwimlabs.net>
parents:
44700
diff
changeset
|
2780 |
b"generations": generationssubrel, |
40931
e54bfde922f2
revset: move subscript relation functions to its own dict
Anton Shestakov <av6@dwimlabs.net>
parents:
40534
diff
changeset
|
2781 |
} |
e54bfde922f2
revset: move subscript relation functions to its own dict
Anton Shestakov <av6@dwimlabs.net>
parents:
40534
diff
changeset
|
2782 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
2783 |
|
37350
e32dfff71529
revset: use revsymbol() for checking if a symbol is valid
Martin von Zweigbergk <martinvonz@google.com>
parents:
37271
diff
changeset
|
2784 |
def lookupfn(repo): |
46115
be3d8178251e
errors: raise InputError if an ambiguous revision id prefix is used
Martin von Zweigbergk <martinvonz@google.com>
parents:
46113
diff
changeset
|
2785 |
def fn(symbol): |
be3d8178251e
errors: raise InputError if an ambiguous revision id prefix is used
Martin von Zweigbergk <martinvonz@google.com>
parents:
46113
diff
changeset
|
2786 |
try: |
be3d8178251e
errors: raise InputError if an ambiguous revision id prefix is used
Martin von Zweigbergk <martinvonz@google.com>
parents:
46113
diff
changeset
|
2787 |
return scmutil.isrevsymbol(repo, symbol) |
be3d8178251e
errors: raise InputError if an ambiguous revision id prefix is used
Martin von Zweigbergk <martinvonz@google.com>
parents:
46113
diff
changeset
|
2788 |
except error.AmbiguousPrefixLookupError: |
be3d8178251e
errors: raise InputError if an ambiguous revision id prefix is used
Martin von Zweigbergk <martinvonz@google.com>
parents:
46113
diff
changeset
|
2789 |
raise error.InputError( |
be3d8178251e
errors: raise InputError if an ambiguous revision id prefix is used
Martin von Zweigbergk <martinvonz@google.com>
parents:
46113
diff
changeset
|
2790 |
b'ambiguous revision identifier: %s' % symbol |
be3d8178251e
errors: raise InputError if an ambiguous revision id prefix is used
Martin von Zweigbergk <martinvonz@google.com>
parents:
46113
diff
changeset
|
2791 |
) |
be3d8178251e
errors: raise InputError if an ambiguous revision id prefix is used
Martin von Zweigbergk <martinvonz@google.com>
parents:
46113
diff
changeset
|
2792 |
|
be3d8178251e
errors: raise InputError if an ambiguous revision id prefix is used
Martin von Zweigbergk <martinvonz@google.com>
parents:
46113
diff
changeset
|
2793 |
return fn |
37350
e32dfff71529
revset: use revsymbol() for checking if a symbol is valid
Martin von Zweigbergk <martinvonz@google.com>
parents:
37271
diff
changeset
|
2794 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
2795 |
|
37674
f83cb91b052e
revset: pass in lookup function instead of repo (API)
Yuya Nishihara <yuya@tcha.org>
parents:
37673
diff
changeset
|
2796 |
def match(ui, spec, lookup=None): |
34018
de286200f722
revset: move order argument to run-time match function
Yuya Nishihara <yuya@tcha.org>
parents:
34017
diff
changeset
|
2797 |
"""Create a matcher for a single revision spec""" |
37854
edb28a6d95b7
revset: pass in lookup function to matchany() (issue5879)
Yuya Nishihara <yuya@tcha.org>
parents:
37674
diff
changeset
|
2798 |
return matchany(ui, [spec], lookup=lookup) |
29955
1b5931604a5a
revset: add option to make matcher takes the ordering of the input set
Yuya Nishihara <yuya@tcha.org>
parents:
29946
diff
changeset
|
2799 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
2800 |
|
37674
f83cb91b052e
revset: pass in lookup function instead of repo (API)
Yuya Nishihara <yuya@tcha.org>
parents:
37673
diff
changeset
|
2801 |
def matchany(ui, specs, lookup=None, localalias=None): |
25927
44da63623fca
revset: add matchany() to construct OR expression from a list of specs
Yuya Nishihara <yuya@tcha.org>
parents:
25926
diff
changeset
|
2802 |
"""Create a matcher that will include any revisions matching one of the |
29955
1b5931604a5a
revset: add option to make matcher takes the ordering of the input set
Yuya Nishihara <yuya@tcha.org>
parents:
29946
diff
changeset
|
2803 |
given specs |
1b5931604a5a
revset: add option to make matcher takes the ordering of the input set
Yuya Nishihara <yuya@tcha.org>
parents:
29946
diff
changeset
|
2804 |
|
37674
f83cb91b052e
revset: pass in lookup function instead of repo (API)
Yuya Nishihara <yuya@tcha.org>
parents:
37673
diff
changeset
|
2805 |
If lookup function is not None, the parser will first attempt to handle |
f83cb91b052e
revset: pass in lookup function instead of repo (API)
Yuya Nishihara <yuya@tcha.org>
parents:
37673
diff
changeset
|
2806 |
old-style ranges, which may contain operator characters. |
f83cb91b052e
revset: pass in lookup function instead of repo (API)
Yuya Nishihara <yuya@tcha.org>
parents:
37673
diff
changeset
|
2807 |
|
33336
4672db164c98
revset: make repo.anyrevs accept customized alias override (API)
Jun Wu <quark@fb.com>
parents:
33080
diff
changeset
|
2808 |
If localalias is not None, it is a dict {name: definitionstring}. It takes |
4672db164c98
revset: make repo.anyrevs accept customized alias override (API)
Jun Wu <quark@fb.com>
parents:
33080
diff
changeset
|
2809 |
precedence over [revsetalias] config section. |
29955
1b5931604a5a
revset: add option to make matcher takes the ordering of the input set
Yuya Nishihara <yuya@tcha.org>
parents:
29946
diff
changeset
|
2810 |
""" |
25927
44da63623fca
revset: add matchany() to construct OR expression from a list of specs
Yuya Nishihara <yuya@tcha.org>
parents:
25926
diff
changeset
|
2811 |
if not specs: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
2812 |
|
25927
44da63623fca
revset: add matchany() to construct OR expression from a list of specs
Yuya Nishihara <yuya@tcha.org>
parents:
25926
diff
changeset
|
2813 |
def mfunc(repo, subset=None): |
44da63623fca
revset: add matchany() to construct OR expression from a list of specs
Yuya Nishihara <yuya@tcha.org>
parents:
25926
diff
changeset
|
2814 |
return baseset() |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
2815 |
|
25927
44da63623fca
revset: add matchany() to construct OR expression from a list of specs
Yuya Nishihara <yuya@tcha.org>
parents:
25926
diff
changeset
|
2816 |
return mfunc |
44da63623fca
revset: add matchany() to construct OR expression from a list of specs
Yuya Nishihara <yuya@tcha.org>
parents:
25926
diff
changeset
|
2817 |
if not all(specs): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2818 |
raise error.ParseError(_(b"empty query")) |
25927
44da63623fca
revset: add matchany() to construct OR expression from a list of specs
Yuya Nishihara <yuya@tcha.org>
parents:
25926
diff
changeset
|
2819 |
if len(specs) == 1: |
31024
0b8356705de6
revset: split language services to revsetlang module (API)
Yuya Nishihara <yuya@tcha.org>
parents:
31017
diff
changeset
|
2820 |
tree = revsetlang.parse(specs[0], lookup) |
25927
44da63623fca
revset: add matchany() to construct OR expression from a list of specs
Yuya Nishihara <yuya@tcha.org>
parents:
25926
diff
changeset
|
2821 |
else: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
2822 |
tree = ( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2823 |
b'or', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2824 |
(b'list',) + tuple(revsetlang.parse(s, lookup) for s in specs), |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
2825 |
) |
29906
41491cf936f2
revset: add public function to create matcher from evaluatable tree
Yuya Nishihara <yuya@tcha.org>
parents:
29905
diff
changeset
|
2826 |
|
33336
4672db164c98
revset: make repo.anyrevs accept customized alias override (API)
Jun Wu <quark@fb.com>
parents:
33080
diff
changeset
|
2827 |
aliases = [] |
4672db164c98
revset: make repo.anyrevs accept customized alias override (API)
Jun Wu <quark@fb.com>
parents:
33080
diff
changeset
|
2828 |
warn = None |
14900
fc3d6f300d7d
revset: allow bypassing alias expansion
Matt Mackall <mpm@selenic.com>
parents:
14851
diff
changeset
|
2829 |
if ui: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
2830 |
aliases.extend(ui.configitems(b'revsetalias')) |
33336
4672db164c98
revset: make repo.anyrevs accept customized alias override (API)
Jun Wu <quark@fb.com>
parents:
33080
diff
changeset
|
2831 |
warn = ui.warn |
4672db164c98
revset: make repo.anyrevs accept customized alias override (API)
Jun Wu <quark@fb.com>
parents:
33080
diff
changeset
|
2832 |
if localalias: |
4672db164c98
revset: make repo.anyrevs accept customized alias override (API)
Jun Wu <quark@fb.com>
parents:
33080
diff
changeset
|
2833 |
aliases.extend(localalias.items()) |
4672db164c98
revset: make repo.anyrevs accept customized alias override (API)
Jun Wu <quark@fb.com>
parents:
33080
diff
changeset
|
2834 |
if aliases: |
4672db164c98
revset: make repo.anyrevs accept customized alias override (API)
Jun Wu <quark@fb.com>
parents:
33080
diff
changeset
|
2835 |
tree = revsetlang.expandaliases(tree, aliases, warn=warn) |
31024
0b8356705de6
revset: split language services to revsetlang module (API)
Yuya Nishihara <yuya@tcha.org>
parents:
31017
diff
changeset
|
2836 |
tree = revsetlang.foldconcat(tree) |
34011
1b28525e6698
revset: remove order information from tree (API)
Jun Wu <quark@fb.com>
parents:
33855
diff
changeset
|
2837 |
tree = revsetlang.analyze(tree) |
31024
0b8356705de6
revset: split language services to revsetlang module (API)
Yuya Nishihara <yuya@tcha.org>
parents:
31017
diff
changeset
|
2838 |
tree = revsetlang.optimize(tree) |
34018
de286200f722
revset: move order argument to run-time match function
Yuya Nishihara <yuya@tcha.org>
parents:
34017
diff
changeset
|
2839 |
return makematcher(tree) |
29906
41491cf936f2
revset: add public function to create matcher from evaluatable tree
Yuya Nishihara <yuya@tcha.org>
parents:
29905
diff
changeset
|
2840 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
2841 |
|
34018
de286200f722
revset: move order argument to run-time match function
Yuya Nishihara <yuya@tcha.org>
parents:
34017
diff
changeset
|
2842 |
def makematcher(tree): |
29906
41491cf936f2
revset: add public function to create matcher from evaluatable tree
Yuya Nishihara <yuya@tcha.org>
parents:
29905
diff
changeset
|
2843 |
"""Create a matcher from an evaluatable tree""" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
2844 |
|
34019
205c47e30a93
revset: make match function follow given subset if specified (API)
Yuya Nishihara <yuya@tcha.org>
parents:
34018
diff
changeset
|
2845 |
def mfunc(repo, subset=None, order=None): |
205c47e30a93
revset: make match function follow given subset if specified (API)
Yuya Nishihara <yuya@tcha.org>
parents:
34018
diff
changeset
|
2846 |
if order is None: |
205c47e30a93
revset: make match function follow given subset if specified (API)
Yuya Nishihara <yuya@tcha.org>
parents:
34018
diff
changeset
|
2847 |
if subset is None: |
205c47e30a93
revset: make match function follow given subset if specified (API)
Yuya Nishihara <yuya@tcha.org>
parents:
34018
diff
changeset
|
2848 |
order = defineorder # 'x' |
205c47e30a93
revset: make match function follow given subset if specified (API)
Yuya Nishihara <yuya@tcha.org>
parents:
34018
diff
changeset
|
2849 |
else: |
205c47e30a93
revset: make match function follow given subset if specified (API)
Yuya Nishihara <yuya@tcha.org>
parents:
34018
diff
changeset
|
2850 |
order = followorder # 'subset & x' |
24114
fafd9a1284cf
revset: make match function initiate query from full set by default
Yuya Nishihara <yuya@tcha.org>
parents:
24031
diff
changeset
|
2851 |
if subset is None: |
24115
ff24af40728b
revset: specify fullreposet without using spanset factory
Yuya Nishihara <yuya@tcha.org>
parents:
24114
diff
changeset
|
2852 |
subset = fullreposet(repo) |
34011
1b28525e6698
revset: remove order information from tree (API)
Jun Wu <quark@fb.com>
parents:
33855
diff
changeset
|
2853 |
return getset(repo, subset, tree, order) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
2854 |
|
11275 | 2855 |
return mfunc |
12821
165079e564f0
revsets: generate predicate help dynamically
Patrick Mezard <pmezard@gmail.com>
parents:
12815
diff
changeset
|
2856 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
2857 |
|
28393
ac11ba7c2e56
registrar: define revsetpredicate to decorate revset predicate
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28272
diff
changeset
|
2858 |
def loadpredicate(ui, extname, registrarobj): |
45942
89a2afe31e82
formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents:
45750
diff
changeset
|
2859 |
"""Load revset predicates from specified registrarobj""" |
48913
f254fc73d956
global: bulk replace simple pycompat.iteritems(x) with x.items()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
48875
diff
changeset
|
2860 |
for name, func in registrarobj._table.items(): |
28393
ac11ba7c2e56
registrar: define revsetpredicate to decorate revset predicate
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28272
diff
changeset
|
2861 |
symbols[name] = func |
ac11ba7c2e56
registrar: define revsetpredicate to decorate revset predicate
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28272
diff
changeset
|
2862 |
if func._safe: |
ac11ba7c2e56
registrar: define revsetpredicate to decorate revset predicate
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28272
diff
changeset
|
2863 |
safesymbols.add(name) |
ac11ba7c2e56
registrar: define revsetpredicate to decorate revset predicate
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28272
diff
changeset
|
2864 |
|
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
42699
diff
changeset
|
2865 |
|
28395
0383f7a5e86c
revset: replace predicate by revsetpredicate of registrar
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28393
diff
changeset
|
2866 |
# load built-in predicates explicitly to setup safesymbols |
0383f7a5e86c
revset: replace predicate by revsetpredicate of registrar
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28393
diff
changeset
|
2867 |
loadpredicate(None, None, predicate) |
0383f7a5e86c
revset: replace predicate by revsetpredicate of registrar
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28393
diff
changeset
|
2868 |
|
12823
80deae3bc5ea
hggettext: handle i18nfunctions declaration for docstrings translations
Patrick Mezard <pmezard@gmail.com>
parents:
12821
diff
changeset
|
2869 |
# tell hggettext to extract docstrings from these functions: |
80deae3bc5ea
hggettext: handle i18nfunctions declaration for docstrings translations
Patrick Mezard <pmezard@gmail.com>
parents:
12821
diff
changeset
|
2870 |
i18nfunctions = symbols.values() |