comparison mercurial/exchange.py @ 43506:9f70512ae2cf

cleanup: remove pointless r-prefixes on single-quoted strings This is the promised second step on single-quoted strings. These had existed because our source transformer didn't turn r'' into b'', so we had tagged some strings as r-strings to get "native" strings on both Pythons. Now that the transformer is gone, we can dispense with this nonsense. Methodology: I ran hg locate 'set:added() or modified() or clean()' | egrep '.*\.py$' | xargs egrep --color=never -n -- \[\^b\]\[\^a-z\]r\'\[\^\'\\\\\]\*\'\[\^\'\ in an emacs grep-mode buffer, and then used a keyboard macro to iterate over the results and remove the r prefix as needed. # skip-blame removing unneeded r prefixes left over from Python 3 migration. Differential Revision: https://phab.mercurial-scm.org/D7306
author Augie Fackler <augie@google.com>
date Fri, 08 Nov 2019 11:19:20 -0800
parents 2c70dd03b743
children 9c1f4e2f1fc4
comparison
equal deleted inserted replaced
43505:47fac1692ede 43506:9f70512ae2cf
2195 ] 2195 ]
2196 user_excludes = [ 2196 user_excludes = [
2197 b'path:.' if p == b'*' else b'path:' + p for p in user_excludes 2197 b'path:.' if p == b'*' else b'path:' + p for p in user_excludes
2198 ] 2198 ]
2199 2199
2200 req_includes = set(kwargs.get(r'includepats', [])) 2200 req_includes = set(kwargs.get('includepats', []))
2201 req_excludes = set(kwargs.get(r'excludepats', [])) 2201 req_excludes = set(kwargs.get('excludepats', []))
2202 2202
2203 req_includes, req_excludes, invalid_includes = narrowspec.restrictpatterns( 2203 req_includes, req_excludes, invalid_includes = narrowspec.restrictpatterns(
2204 req_includes, req_excludes, user_includes, user_excludes 2204 req_includes, req_excludes, user_includes, user_excludes
2205 ) 2205 )
2206 2206
2211 ) 2211 )
2212 ) 2212 )
2213 2213
2214 new_args = {} 2214 new_args = {}
2215 new_args.update(kwargs) 2215 new_args.update(kwargs)
2216 new_args[r'narrow'] = True 2216 new_args['narrow'] = True
2217 new_args[r'narrow_acl'] = True 2217 new_args['narrow_acl'] = True
2218 new_args[r'includepats'] = req_includes 2218 new_args['includepats'] = req_includes
2219 if req_excludes: 2219 if req_excludes:
2220 new_args[r'excludepats'] = req_excludes 2220 new_args['excludepats'] = req_excludes
2221 2221
2222 return new_args 2222 return new_args
2223 2223
2224 2224
2225 def _computeellipsis(repo, common, heads, known, match, depth=None): 2225 def _computeellipsis(repo, common, heads, known, match, depth=None):
2478 heads=None, 2478 heads=None,
2479 common=None, 2479 common=None,
2480 **kwargs 2480 **kwargs
2481 ): 2481 ):
2482 """add a changegroup part to the requested bundle""" 2482 """add a changegroup part to the requested bundle"""
2483 if not kwargs.get(r'cg', True): 2483 if not kwargs.get('cg', True):
2484 return 2484 return
2485 2485
2486 version = b'01' 2486 version = b'01'
2487 cgversions = b2caps.get(b'changegroup') 2487 cgversions = b2caps.get(b'changegroup')
2488 if cgversions: # 3.1 and 3.2 ship with an empty value 2488 if cgversions: # 3.1 and 3.2 ship with an empty value
2497 2497
2498 outgoing = _computeoutgoing(repo, heads, common) 2498 outgoing = _computeoutgoing(repo, heads, common)
2499 if not outgoing.missing: 2499 if not outgoing.missing:
2500 return 2500 return
2501 2501
2502 if kwargs.get(r'narrow', False): 2502 if kwargs.get('narrow', False):
2503 include = sorted(filter(bool, kwargs.get(r'includepats', []))) 2503 include = sorted(filter(bool, kwargs.get('includepats', [])))
2504 exclude = sorted(filter(bool, kwargs.get(r'excludepats', []))) 2504 exclude = sorted(filter(bool, kwargs.get('excludepats', [])))
2505 matcher = narrowspec.match(repo.root, include=include, exclude=exclude) 2505 matcher = narrowspec.match(repo.root, include=include, exclude=exclude)
2506 else: 2506 else:
2507 matcher = None 2507 matcher = None
2508 2508
2509 cgstream = changegroup.makestream( 2509 cgstream = changegroup.makestream(
2521 2521
2522 if b'exp-sidedata-flag' in repo.requirements: 2522 if b'exp-sidedata-flag' in repo.requirements:
2523 part.addparam(b'exp-sidedata', b'1') 2523 part.addparam(b'exp-sidedata', b'1')
2524 2524
2525 if ( 2525 if (
2526 kwargs.get(r'narrow', False) 2526 kwargs.get('narrow', False)
2527 and kwargs.get(r'narrow_acl', False) 2527 and kwargs.get('narrow_acl', False)
2528 and (include or exclude) 2528 and (include or exclude)
2529 ): 2529 ):
2530 # this is mandatory because otherwise ACL clients won't work 2530 # this is mandatory because otherwise ACL clients won't work
2531 narrowspecpart = bundler.newpart(b'Narrow:responsespec') 2531 narrowspecpart = bundler.newpart(b'Narrow:responsespec')
2532 narrowspecpart.data = b'%s\0%s' % ( 2532 narrowspecpart.data = b'%s\0%s' % (
2538 @getbundle2partsgenerator(b'bookmarks') 2538 @getbundle2partsgenerator(b'bookmarks')
2539 def _getbundlebookmarkpart( 2539 def _getbundlebookmarkpart(
2540 bundler, repo, source, bundlecaps=None, b2caps=None, **kwargs 2540 bundler, repo, source, bundlecaps=None, b2caps=None, **kwargs
2541 ): 2541 ):
2542 """add a bookmark part to the requested bundle""" 2542 """add a bookmark part to the requested bundle"""
2543 if not kwargs.get(r'bookmarks', False): 2543 if not kwargs.get('bookmarks', False):
2544 return 2544 return
2545 if b'bookmarks' not in b2caps: 2545 if b'bookmarks' not in b2caps:
2546 raise error.Abort(_(b'no common bookmarks exchange method')) 2546 raise error.Abort(_(b'no common bookmarks exchange method'))
2547 books = bookmod.listbinbookmarks(repo) 2547 books = bookmod.listbinbookmarks(repo)
2548 data = bookmod.binaryencode(books) 2548 data = bookmod.binaryencode(books)
2553 @getbundle2partsgenerator(b'listkeys') 2553 @getbundle2partsgenerator(b'listkeys')
2554 def _getbundlelistkeysparts( 2554 def _getbundlelistkeysparts(
2555 bundler, repo, source, bundlecaps=None, b2caps=None, **kwargs 2555 bundler, repo, source, bundlecaps=None, b2caps=None, **kwargs
2556 ): 2556 ):
2557 """add parts containing listkeys namespaces to the requested bundle""" 2557 """add parts containing listkeys namespaces to the requested bundle"""
2558 listkeys = kwargs.get(r'listkeys', ()) 2558 listkeys = kwargs.get('listkeys', ())
2559 for namespace in listkeys: 2559 for namespace in listkeys:
2560 part = bundler.newpart(b'listkeys') 2560 part = bundler.newpart(b'listkeys')
2561 part.addparam(b'namespace', namespace) 2561 part.addparam(b'namespace', namespace)
2562 keys = repo.listkeys(namespace).items() 2562 keys = repo.listkeys(namespace).items()
2563 part.data = pushkey.encodekeys(keys) 2563 part.data = pushkey.encodekeys(keys)
2566 @getbundle2partsgenerator(b'obsmarkers') 2566 @getbundle2partsgenerator(b'obsmarkers')
2567 def _getbundleobsmarkerpart( 2567 def _getbundleobsmarkerpart(
2568 bundler, repo, source, bundlecaps=None, b2caps=None, heads=None, **kwargs 2568 bundler, repo, source, bundlecaps=None, b2caps=None, heads=None, **kwargs
2569 ): 2569 ):
2570 """add an obsolescence markers part to the requested bundle""" 2570 """add an obsolescence markers part to the requested bundle"""
2571 if kwargs.get(r'obsmarkers', False): 2571 if kwargs.get('obsmarkers', False):
2572 if heads is None: 2572 if heads is None:
2573 heads = repo.heads() 2573 heads = repo.heads()
2574 subset = [c.node() for c in repo.set(b'::%ln', heads)] 2574 subset = [c.node() for c in repo.set(b'::%ln', heads)]
2575 markers = repo.obsstore.relevantmarkers(subset) 2575 markers = repo.obsstore.relevantmarkers(subset)
2576 markers = _sortedmarkers(markers) 2576 markers = _sortedmarkers(markers)
2580 @getbundle2partsgenerator(b'phases') 2580 @getbundle2partsgenerator(b'phases')
2581 def _getbundlephasespart( 2581 def _getbundlephasespart(
2582 bundler, repo, source, bundlecaps=None, b2caps=None, heads=None, **kwargs 2582 bundler, repo, source, bundlecaps=None, b2caps=None, heads=None, **kwargs
2583 ): 2583 ):
2584 """add phase heads part to the requested bundle""" 2584 """add phase heads part to the requested bundle"""
2585 if kwargs.get(r'phases', False): 2585 if kwargs.get('phases', False):
2586 if not b'heads' in b2caps.get(b'phases'): 2586 if not b'heads' in b2caps.get(b'phases'):
2587 raise error.Abort(_(b'no common phases exchange method')) 2587 raise error.Abort(_(b'no common phases exchange method'))
2588 if heads is None: 2588 if heads is None:
2589 heads = repo.heads() 2589 heads = repo.heads()
2590 2590
2645 filenodes raw values. 2645 filenodes raw values.
2646 """ 2646 """
2647 # Don't send unless: 2647 # Don't send unless:
2648 # - changeset are being exchanged, 2648 # - changeset are being exchanged,
2649 # - the client supports it. 2649 # - the client supports it.
2650 if not (kwargs.get(r'cg', True) and b'hgtagsfnodes' in b2caps): 2650 if not (kwargs.get('cg', True) and b'hgtagsfnodes' in b2caps):
2651 return 2651 return
2652 2652
2653 outgoing = _computeoutgoing(repo, heads, common) 2653 outgoing = _computeoutgoing(repo, heads, common)
2654 bundle2.addparttagsfnodescache(repo, bundler, outgoing) 2654 bundle2.addparttagsfnodescache(repo, bundler, outgoing)
2655 2655
2678 # Don't send unless: 2678 # Don't send unless:
2679 # - changeset are being exchanged, 2679 # - changeset are being exchanged,
2680 # - the client supports it. 2680 # - the client supports it.
2681 # - narrow bundle isn't in play (not currently compatible). 2681 # - narrow bundle isn't in play (not currently compatible).
2682 if ( 2682 if (
2683 not kwargs.get(r'cg', True) 2683 not kwargs.get('cg', True)
2684 or b'rev-branch-cache' not in b2caps 2684 or b'rev-branch-cache' not in b2caps
2685 or kwargs.get(r'narrow', False) 2685 or kwargs.get('narrow', False)
2686 or repo.ui.has_section(_NARROWACL_SECTION) 2686 or repo.ui.has_section(_NARROWACL_SECTION)
2687 ): 2687 ):
2688 return 2688 return
2689 2689
2690 outgoing = _computeoutgoing(repo, heads, common) 2690 outgoing = _computeoutgoing(repo, heads, common)