##// END OF EJS Templates
revset: implement a simple 'foo#generations' expression...
av6 -
r45204:eca82eb9 default
parent child Browse files
Show More
@@ -247,7 +247,15 b' def notset(repo, subset, x, order):'
247
247
248
248
249 def relationset(repo, subset, x, y, order):
249 def relationset(repo, subset, x, y, order):
250 raise error.ParseError(_(b"can't use a relation in this context"))
250 # this is pretty basic implementation of 'x#y' operator, still
251 # experimental so undocumented. see the wiki for further ideas.
252 # https://www.mercurial-scm.org/wiki/RevsetOperatorPlan
253 rel = getsymbol(y)
254 if rel in relations:
255 return relations[rel](repo, subset, x, rel, order)
256
257 relnames = [r for r in relations.keys() if len(r) > 1]
258 raise error.UnknownIdentifier(rel, relnames)
251
259
252
260
253 def _splitrange(a, b):
261 def _splitrange(a, b):
@@ -281,6 +289,11 b' def _splitrange(a, b):'
281 return ancdepths, descdepths
289 return ancdepths, descdepths
282
290
283
291
292 def generationsrel(repo, subset, x, rel, order):
293 z = (b'rangeall', None)
294 return generationssubrel(repo, subset, x, rel, z, order)
295
296
284 def generationssubrel(repo, subset, x, rel, z, order):
297 def generationssubrel(repo, subset, x, rel, z, order):
285 # TODO: rewrite tests, and drop startdepth argument from ancestors() and
298 # TODO: rewrite tests, and drop startdepth argument from ancestors() and
286 # descendants() predicates
299 # descendants() predicates
@@ -2649,6 +2662,11 b' methods = {'
2649 b"smartset": rawsmartset,
2662 b"smartset": rawsmartset,
2650 }
2663 }
2651
2664
2665 relations = {
2666 b"g": generationsrel,
2667 b"generations": generationsrel,
2668 }
2669
2652 subscriptrelations = {
2670 subscriptrelations = {
2653 b"g": generationssubrel,
2671 b"g": generationssubrel,
2654 b"generations": generationssubrel,
2672 b"generations": generationssubrel,
@@ -1274,6 +1274,36 b' test descendants with depth limit'
1274 5
1274 5
1275 7
1275 7
1276
1276
1277 test ancestors/descendants relation:
1278
1279 $ log 'tip#generations'
1280 0
1281 1
1282 2
1283 4
1284 8
1285 9
1286
1287 $ log '3#g'
1288 0
1289 1
1290 3
1291 5
1292 6
1293 7
1294
1295 $ hg debugrevspec -p parsed 'tip#g'
1296 * parsed:
1297 (relation
1298 (symbol 'tip')
1299 (symbol 'g'))
1300 0
1301 1
1302 2
1303 4
1304 8
1305 9
1306
1277 test ancestors/descendants relation subscript:
1307 test ancestors/descendants relation subscript:
1278
1308
1279 $ log 'tip#generations[0]'
1309 $ log 'tip#generations[0]'
General Comments 0
You need to be logged in to leave comments. Login now