Show More
@@ -245,7 +245,7 b' class kwtemplater(object):' | |||
|
245 | 245 | @util.propertycache |
|
246 | 246 | def escape(self): |
|
247 | 247 | '''Returns bar-separated and escaped keywords.''' |
|
248 |
return '|'.join(map( |
|
|
248 | return '|'.join(map(stringutil.reescape, self.templates.keys())) | |
|
249 | 249 | |
|
250 | 250 | @util.propertycache |
|
251 | 251 | def rekw(self): |
@@ -56,7 +56,7 b' class gitlfspointer(dict):' | |||
|
56 | 56 | _requiredre = { |
|
57 | 57 | 'size': re.compile(br'\A[0-9]+\Z'), |
|
58 | 58 | 'oid': re.compile(br'\Asha256:[0-9a-f]{64}\Z'), |
|
59 |
'version': re.compile(br'\A%s\Z' % |
|
|
59 | 'version': re.compile(br'\A%s\Z' % stringutil.reescape(VERSION)), | |
|
60 | 60 | } |
|
61 | 61 | |
|
62 | 62 | def validate(self): |
@@ -766,7 +766,7 b' def getwebsubs(repo):' | |||
|
766 | 766 | for key, pattern in websubdefs: |
|
767 | 767 | # grab the delimiter from the character after the "s" |
|
768 | 768 | unesc = pattern[1:2] |
|
769 |
delim = |
|
|
769 | delim = stringutil.reescape(unesc) | |
|
770 | 770 | |
|
771 | 771 | # identify portions of the pattern, taking care to avoid escaped |
|
772 | 772 | # delimiters. the replace format and flags are optional, but |
@@ -714,7 +714,7 b' def _globre(pat):' | |||
|
714 | 714 | >>> bprint(_globre(br'**/a')) |
|
715 | 715 | (?:.*/)?a |
|
716 | 716 | >>> bprint(_globre(br'a/**/b')) |
|
717 |
a |
|
|
717 | a/(?:.*/)?b | |
|
718 | 718 | >>> bprint(_globre(br'[a*?!^][^b][!c]')) |
|
719 | 719 | [a*?!^][\^b][^c] |
|
720 | 720 | >>> bprint(_globre(br'{a,b}')) |
@@ -725,7 +725,7 b' def _globre(pat):' | |||
|
725 | 725 | i, n = 0, len(pat) |
|
726 | 726 | res = '' |
|
727 | 727 | group = 0 |
|
728 |
escape = util. |
|
|
728 | escape = util.stringutil.reescape | |
|
729 | 729 | def peek(): |
|
730 | 730 | return i < n and pat[i:i + 1] |
|
731 | 731 | while i < n: |
@@ -790,13 +790,13 b' def _regex(kind, pat, globsuffix):' | |||
|
790 | 790 | if kind in ('path', 'relpath'): |
|
791 | 791 | if pat == '.': |
|
792 | 792 | return '' |
|
793 |
return util. |
|
|
793 | return util.stringutil.reescape(pat) + '(?:/|$)' | |
|
794 | 794 | if kind == 'rootfilesin': |
|
795 | 795 | if pat == '.': |
|
796 | 796 | escaped = '' |
|
797 | 797 | else: |
|
798 | 798 | # Pattern is a directory name. |
|
799 |
escaped = util. |
|
|
799 | escaped = util.stringutil.reescape(pat) + '/' | |
|
800 | 800 | # Anything after the pattern must be a non-directory. |
|
801 | 801 | return escaped + '[^/]+$' |
|
802 | 802 | if kind == 'relglob': |
@@ -22,6 +22,7 b' from . import (' | |||
|
22 | 22 | ) |
|
23 | 23 | from .utils import ( |
|
24 | 24 | procutil, |
|
25 | stringutil, | |
|
25 | 26 | ) |
|
26 | 27 | |
|
27 | 28 | def _serverquote(s): |
@@ -273,7 +274,7 b' def _performhandshake(ui, stdin, stdout,' | |||
|
273 | 274 | |
|
274 | 275 | # Assume version 1 of wire protocol by default. |
|
275 | 276 | protoname = wireprototypes.SSHV1 |
|
276 |
reupgraded = re.compile(b'^upgraded %s (.*)$' % |
|
|
277 | reupgraded = re.compile(b'^upgraded %s (.*)$' % stringutil.reescape(token)) | |
|
277 | 278 | |
|
278 | 279 | lines = ['', 'dummy'] |
|
279 | 280 | max_noise = 500 |
@@ -618,14 +618,14 b' def _dnsnamematch(dn, hostname, maxwildc' | |||
|
618 | 618 | # The client SHOULD NOT attempt to match a presented identifier |
|
619 | 619 | # where the wildcard character is embedded within an A-label or |
|
620 | 620 | # U-label of an internationalized domain name. |
|
621 |
pats.append( |
|
|
621 | pats.append(stringutil.reescape(leftmost)) | |
|
622 | 622 | else: |
|
623 | 623 | # Otherwise, '*' matches any dotless string, e.g. www* |
|
624 |
pats.append( |
|
|
624 | pats.append(stringutil.reescape(leftmost).replace(br'\*', '[^.]*')) | |
|
625 | 625 | |
|
626 | 626 | # add the remaining fragments, ignore any wildcards |
|
627 | 627 | for frag in remainder: |
|
628 |
pats.append( |
|
|
628 | pats.append(stringutil.reescape(frag)) | |
|
629 | 629 | |
|
630 | 630 | pat = re.compile(br'\A' + br'\.'.join(pats) + br'\Z', re.IGNORECASE) |
|
631 | 631 | return pat.match(hostname) is not None |
@@ -92,11 +92,11 b'' | |||
|
92 | 92 | f mammals/skunk skunk |
|
93 | 93 | $ hg debugwalk -v -I '*k' |
|
94 | 94 | * matcher: |
|
95 |
<includematcher includes='(?:mammals |
|
|
95 | <includematcher includes='(?:mammals/[^/]*k(?:/|$))'> | |
|
96 | 96 | f mammals/skunk skunk |
|
97 | 97 | $ hg debugwalk -v -I 'glob:*k' |
|
98 | 98 | * matcher: |
|
99 |
<includematcher includes='(?:mammals |
|
|
99 | <includematcher includes='(?:mammals/[^/]*k(?:/|$))'> | |
|
100 | 100 | f mammals/skunk skunk |
|
101 | 101 | $ hg debugwalk -v -I 'relglob:*k' |
|
102 | 102 | * matcher: |
@@ -260,7 +260,7 b'' | |||
|
260 | 260 | f mammals/skunk skunk |
|
261 | 261 | $ hg debugwalk -v Procyonidae |
|
262 | 262 | * matcher: |
|
263 |
<patternmatcher patterns='(?:mammals |
|
|
263 | <patternmatcher patterns='(?:mammals/Procyonidae(?:/|$))'> | |
|
264 | 264 | f mammals/Procyonidae/cacomistle Procyonidae/cacomistle |
|
265 | 265 | f mammals/Procyonidae/coatimundi Procyonidae/coatimundi |
|
266 | 266 | f mammals/Procyonidae/raccoon Procyonidae/raccoon |
@@ -268,7 +268,7 b'' | |||
|
268 | 268 | $ cd Procyonidae |
|
269 | 269 | $ hg debugwalk -v . |
|
270 | 270 | * matcher: |
|
271 |
<patternmatcher patterns='(?:mammals |
|
|
271 | <patternmatcher patterns='(?:mammals/Procyonidae(?:/|$))'> | |
|
272 | 272 | f mammals/Procyonidae/cacomistle cacomistle |
|
273 | 273 | f mammals/Procyonidae/coatimundi coatimundi |
|
274 | 274 | f mammals/Procyonidae/raccoon raccoon |
@@ -316,7 +316,7 b'' | |||
|
316 | 316 | f beans/turtle beans/turtle |
|
317 | 317 | $ hg debugwalk -v -I '{*,{b,m}*/*}k' |
|
318 | 318 | * matcher: |
|
319 |
<includematcher includes='(?:(?:[^/]*|(?:b|m)[^/]* |
|
|
319 | <includematcher includes='(?:(?:[^/]*|(?:b|m)[^/]*/[^/]*)k(?:/|$))'> | |
|
320 | 320 | f beans/black beans/black |
|
321 | 321 | f fenugreek fenugreek |
|
322 | 322 | f mammals/skunk mammals/skunk |
@@ -330,25 +330,25 b'' | |||
|
330 | 330 | <includematcher includes='(?:non\\-existent(?:/|$))'> |
|
331 | 331 | $ hg debugwalk -v -Inon-existent -Ibeans/black |
|
332 | 332 | * matcher: |
|
333 |
<includematcher includes='(?:non\\-existent(?:/|$)|beans |
|
|
333 | <includematcher includes='(?:non\\-existent(?:/|$)|beans/black(?:/|$))'> | |
|
334 | 334 | f beans/black beans/black |
|
335 | 335 | $ hg debugwalk -v -Ibeans beans/black |
|
336 | 336 | * matcher: |
|
337 | 337 | <intersectionmatcher |
|
338 |
m1=<patternmatcher patterns='(?:beans |
|
|
338 | m1=<patternmatcher patterns='(?:beans/black(?:/|$))'>, | |
|
339 | 339 | m2=<includematcher includes='(?:beans(?:/|$))'>> |
|
340 | 340 | f beans/black beans/black exact |
|
341 | 341 | $ hg debugwalk -v -Ibeans/black beans |
|
342 | 342 | * matcher: |
|
343 | 343 | <intersectionmatcher |
|
344 | 344 | m1=<patternmatcher patterns='(?:beans(?:/|$))'>, |
|
345 |
m2=<includematcher includes='(?:beans |
|
|
345 | m2=<includematcher includes='(?:beans/black(?:/|$))'>> | |
|
346 | 346 | f beans/black beans/black |
|
347 | 347 | $ hg debugwalk -v -Xbeans/black beans |
|
348 | 348 | * matcher: |
|
349 | 349 | <differencematcher |
|
350 | 350 | m1=<patternmatcher patterns='(?:beans(?:/|$))'>, |
|
351 |
m2=<includematcher includes='(?:beans |
|
|
351 | m2=<includematcher includes='(?:beans/black(?:/|$))'>> | |
|
352 | 352 | f beans/borlotti beans/borlotti |
|
353 | 353 | f beans/kidney beans/kidney |
|
354 | 354 | f beans/navy beans/navy |
@@ -358,7 +358,7 b'' | |||
|
358 | 358 | * matcher: |
|
359 | 359 | <differencematcher |
|
360 | 360 | m1=<includematcher includes='(?:beans(?:/|$))'>, |
|
361 |
m2=<includematcher includes='(?:beans |
|
|
361 | m2=<includematcher includes='(?:beans/black(?:/|$))'>> | |
|
362 | 362 | f beans/borlotti beans/borlotti |
|
363 | 363 | f beans/kidney beans/kidney |
|
364 | 364 | f beans/navy beans/navy |
@@ -367,33 +367,33 b'' | |||
|
367 | 367 | $ hg debugwalk -v -Xbeans/black beans/black |
|
368 | 368 | * matcher: |
|
369 | 369 | <differencematcher |
|
370 |
m1=<patternmatcher patterns='(?:beans |
|
|
371 |
m2=<includematcher includes='(?:beans |
|
|
370 | m1=<patternmatcher patterns='(?:beans/black(?:/|$))'>, | |
|
371 | m2=<includematcher includes='(?:beans/black(?:/|$))'>> | |
|
372 | 372 | $ hg debugwalk -v -Xbeans/black -Ibeans/black |
|
373 | 373 | * matcher: |
|
374 | 374 | <differencematcher |
|
375 |
m1=<includematcher includes='(?:beans |
|
|
376 |
m2=<includematcher includes='(?:beans |
|
|
375 | m1=<includematcher includes='(?:beans/black(?:/|$))'>, | |
|
376 | m2=<includematcher includes='(?:beans/black(?:/|$))'>> | |
|
377 | 377 | $ hg debugwalk -v -Xbeans beans/black |
|
378 | 378 | * matcher: |
|
379 | 379 | <differencematcher |
|
380 |
m1=<patternmatcher patterns='(?:beans |
|
|
380 | m1=<patternmatcher patterns='(?:beans/black(?:/|$))'>, | |
|
381 | 381 | m2=<includematcher includes='(?:beans(?:/|$))'>> |
|
382 | 382 | $ hg debugwalk -v -Xbeans -Ibeans/black |
|
383 | 383 | * matcher: |
|
384 | 384 | <differencematcher |
|
385 |
m1=<includematcher includes='(?:beans |
|
|
385 | m1=<includematcher includes='(?:beans/black(?:/|$))'>, | |
|
386 | 386 | m2=<includematcher includes='(?:beans(?:/|$))'>> |
|
387 | 387 | $ hg debugwalk -v 'glob:mammals/../beans/b*' |
|
388 | 388 | * matcher: |
|
389 |
<patternmatcher patterns='(?:beans |
|
|
389 | <patternmatcher patterns='(?:beans/b[^/]*$)'> | |
|
390 | 390 | f beans/black beans/black |
|
391 | 391 | f beans/borlotti beans/borlotti |
|
392 | 392 | $ hg debugwalk -v '-X*/Procyonidae' mammals |
|
393 | 393 | * matcher: |
|
394 | 394 | <differencematcher |
|
395 | 395 | m1=<patternmatcher patterns='(?:mammals(?:/|$))'>, |
|
396 |
m2=<includematcher includes='(?:[^/]* |
|
|
396 | m2=<includematcher includes='(?:[^/]*/Procyonidae(?:/|$))'>> | |
|
397 | 397 | f mammals/skunk mammals/skunk |
|
398 | 398 | $ hg debugwalk -v path:mammals |
|
399 | 399 | * matcher: |
@@ -436,12 +436,12 b' Test explicit paths and excludes:' | |||
|
436 | 436 | $ hg debugwalk -v beans/black -X 'path:beans' |
|
437 | 437 | * matcher: |
|
438 | 438 | <differencematcher |
|
439 |
m1=<patternmatcher patterns='(?:beans |
|
|
439 | m1=<patternmatcher patterns='(?:beans/black(?:/|$))'>, | |
|
440 | 440 | m2=<includematcher includes='(?:beans(?:/|$))'>> |
|
441 | 441 | $ hg debugwalk -v -I 'path:beans/black' -X 'path:beans' |
|
442 | 442 | * matcher: |
|
443 | 443 | <differencematcher |
|
444 |
m1=<includematcher includes='(?:beans |
|
|
444 | m1=<includematcher includes='(?:beans/black(?:/|$))'>, | |
|
445 | 445 | m2=<includematcher includes='(?:beans(?:/|$))'>> |
|
446 | 446 | |
|
447 | 447 | Test absolute paths: |
@@ -485,11 +485,11 b' Test patterns:' | |||
|
485 | 485 | glob: $ENOENT$ |
|
486 | 486 | $ hg debugwalk -v glob:glob:glob |
|
487 | 487 | * matcher: |
|
488 |
<patternmatcher patterns='(?:glob |
|
|
488 | <patternmatcher patterns='(?:glob:glob$)'> | |
|
489 | 489 | f glob:glob glob:glob exact |
|
490 | 490 | $ hg debugwalk -v path:glob:glob |
|
491 | 491 | * matcher: |
|
492 |
<patternmatcher patterns='(?:glob |
|
|
492 | <patternmatcher patterns='(?:glob:glob(?:/|$))'> | |
|
493 | 493 | f glob:glob glob:glob exact |
|
494 | 494 | $ rm glob:glob |
|
495 | 495 | $ hg addremove |
@@ -511,11 +511,11 b' Test patterns:' | |||
|
511 | 511 | |
|
512 | 512 | $ hg debugwalk -v path:beans/black |
|
513 | 513 | * matcher: |
|
514 |
<patternmatcher patterns='(?:beans |
|
|
514 | <patternmatcher patterns='(?:beans/black(?:/|$))'> | |
|
515 | 515 | f beans/black beans/black exact |
|
516 | 516 | $ hg debugwalk -v path:beans//black |
|
517 | 517 | * matcher: |
|
518 |
<patternmatcher patterns='(?:beans |
|
|
518 | <patternmatcher patterns='(?:beans/black(?:/|$))'> | |
|
519 | 519 | f beans/black beans/black exact |
|
520 | 520 | |
|
521 | 521 | $ hg debugwalk -v relglob:Procyonidae |
@@ -523,20 +523,20 b' Test patterns:' | |||
|
523 | 523 | <patternmatcher patterns='(?:(?:|.*/)Procyonidae$)'> |
|
524 | 524 | $ hg debugwalk -v 'relglob:Procyonidae/**' |
|
525 | 525 | * matcher: |
|
526 |
<patternmatcher patterns='(?:(?:|.*/)Procyonidae |
|
|
526 | <patternmatcher patterns='(?:(?:|.*/)Procyonidae/.*$)'> | |
|
527 | 527 | f mammals/Procyonidae/cacomistle mammals/Procyonidae/cacomistle |
|
528 | 528 | f mammals/Procyonidae/coatimundi mammals/Procyonidae/coatimundi |
|
529 | 529 | f mammals/Procyonidae/raccoon mammals/Procyonidae/raccoon |
|
530 | 530 | $ hg debugwalk -v 'relglob:Procyonidae/**' fennel |
|
531 | 531 | * matcher: |
|
532 |
<patternmatcher patterns='(?:(?:|.*/)Procyonidae |
|
|
532 | <patternmatcher patterns='(?:(?:|.*/)Procyonidae/.*$|fennel(?:/|$))'> | |
|
533 | 533 | f fennel fennel exact |
|
534 | 534 | f mammals/Procyonidae/cacomistle mammals/Procyonidae/cacomistle |
|
535 | 535 | f mammals/Procyonidae/coatimundi mammals/Procyonidae/coatimundi |
|
536 | 536 | f mammals/Procyonidae/raccoon mammals/Procyonidae/raccoon |
|
537 | 537 | $ hg debugwalk -v beans 'glob:beans/*' |
|
538 | 538 | * matcher: |
|
539 |
<patternmatcher patterns='(?:beans(?:/|$)|beans |
|
|
539 | <patternmatcher patterns='(?:beans(?:/|$)|beans/[^/]*$)'> | |
|
540 | 540 | f beans/black beans/black |
|
541 | 541 | f beans/borlotti beans/borlotti |
|
542 | 542 | f beans/kidney beans/kidney |
@@ -598,7 +598,7 b' Test patterns:' | |||
|
598 | 598 | <patternmatcher patterns='(?:ignored(?:/|$))'> |
|
599 | 599 | $ hg debugwalk -v ignored/file |
|
600 | 600 | * matcher: |
|
601 |
<patternmatcher patterns='(?:ignored |
|
|
601 | <patternmatcher patterns='(?:ignored/file(?:/|$))'> | |
|
602 | 602 | f ignored/file ignored/file exact |
|
603 | 603 | |
|
604 | 604 | Test listfile and listfile0 |
@@ -612,7 +612,7 b' Test listfile and listfile0' | |||
|
612 | 612 | $ $PYTHON -c "open('listfile', 'wb').write(b'fenugreek\nnew\r\nmammals/skunk\n')" |
|
613 | 613 | $ hg debugwalk -v -I 'listfile:listfile' |
|
614 | 614 | * matcher: |
|
615 |
<includematcher includes='(?:fenugreek(?:/|$)|new(?:/|$)|mammals |
|
|
615 | <includematcher includes='(?:fenugreek(?:/|$)|new(?:/|$)|mammals/skunk(?:/|$))'> | |
|
616 | 616 | f fenugreek fenugreek |
|
617 | 617 | f mammals/skunk mammals/skunk |
|
618 | 618 | f new new |
@@ -620,17 +620,17 b' Test listfile and listfile0' | |||
|
620 | 620 | $ cd .. |
|
621 | 621 | $ hg debugwalk -v -R t t/mammals/skunk |
|
622 | 622 | * matcher: |
|
623 |
<patternmatcher patterns='(?:mammals |
|
|
623 | <patternmatcher patterns='(?:mammals/skunk(?:/|$))'> | |
|
624 | 624 | f mammals/skunk t/mammals/skunk exact |
|
625 | 625 | $ mkdir t2 |
|
626 | 626 | $ cd t2 |
|
627 | 627 | $ hg debugwalk -v -R ../t ../t/mammals/skunk |
|
628 | 628 | * matcher: |
|
629 |
<patternmatcher patterns='(?:mammals |
|
|
629 | <patternmatcher patterns='(?:mammals/skunk(?:/|$))'> | |
|
630 | 630 | f mammals/skunk ../t/mammals/skunk exact |
|
631 | 631 | $ hg debugwalk -v --cwd ../t mammals/skunk |
|
632 | 632 | * matcher: |
|
633 |
<patternmatcher patterns='(?:mammals |
|
|
633 | <patternmatcher patterns='(?:mammals/skunk(?:/|$))'> | |
|
634 | 634 | f mammals/skunk mammals/skunk exact |
|
635 | 635 | |
|
636 | 636 | $ cd .. |
General Comments 0
You need to be logged in to leave comments.
Login now