comparison hgext/largefiles/overrides.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 2cb787b65cf2
children 73e6d3346e4f
comparison
equal deleted inserted replaced
43505:47fac1692ede 43506:9f70512ae2cf
82 m.matchfn = lambda f: notlfile(f) and origmatchfn(f) 82 m.matchfn = lambda f: notlfile(f) and origmatchfn(f)
83 return m 83 return m
84 84
85 85
86 def addlargefiles(ui, repo, isaddremove, matcher, uipathfn, **opts): 86 def addlargefiles(ui, repo, isaddremove, matcher, uipathfn, **opts):
87 large = opts.get(r'large') 87 large = opts.get('large')
88 lfsize = lfutil.getminsize( 88 lfsize = lfutil.getminsize(
89 ui, lfutil.islfilesrepo(repo), opts.get(r'lfsize') 89 ui, lfutil.islfilesrepo(repo), opts.get('lfsize')
90 ) 90 )
91 91
92 lfmatcher = None 92 lfmatcher = None
93 if lfutil.islfilesrepo(repo): 93 if lfutil.islfilesrepo(repo):
94 lfpats = ui.configlist(lfutil.longname, b'patterns') 94 lfpats = ui.configlist(lfutil.longname, b'patterns')
129 bad = [] 129 bad = []
130 130
131 # Need to lock, otherwise there could be a race condition between 131 # Need to lock, otherwise there could be a race condition between
132 # when standins are created and added to the repo. 132 # when standins are created and added to the repo.
133 with repo.wlock(): 133 with repo.wlock():
134 if not opts.get(r'dry_run'): 134 if not opts.get('dry_run'):
135 standins = [] 135 standins = []
136 lfdirstate = lfutil.openlfdirstate(ui, repo) 136 lfdirstate = lfutil.openlfdirstate(ui, repo)
137 for f in lfnames: 137 for f in lfnames:
138 standinname = lfutil.standin(f) 138 standinname = lfutil.standin(f)
139 lfutil.writestandin( 139 lfutil.writestandin(
167 finally: 167 finally:
168 repo.lfstatus = oldvalue 168 repo.lfstatus = oldvalue
169 169
170 170
171 def removelargefiles(ui, repo, isaddremove, matcher, uipathfn, dryrun, **opts): 171 def removelargefiles(ui, repo, isaddremove, matcher, uipathfn, dryrun, **opts):
172 after = opts.get(r'after') 172 after = opts.get('after')
173 m = composelargefilematcher(matcher, repo[None].manifest()) 173 m = composelargefilematcher(matcher, repo[None].manifest())
174 with lfstatus(repo): 174 with lfstatus(repo):
175 s = repo.status(match=m, clean=not isaddremove) 175 s = repo.status(match=m, clean=not isaddremove)
176 manifest = repo[None].manifest() 176 manifest = repo[None].manifest()
177 modified, added, deleted, clean = [ 177 modified, added, deleted, clean = [
267 ), 267 ),
268 ), 268 ),
269 ], 269 ],
270 ) 270 )
271 def overrideadd(orig, ui, repo, *pats, **opts): 271 def overrideadd(orig, ui, repo, *pats, **opts):
272 if opts.get(r'normal') and opts.get(r'large'): 272 if opts.get('normal') and opts.get('large'):
273 raise error.Abort(_(b'--normal cannot be used with --large')) 273 raise error.Abort(_(b'--normal cannot be used with --large'))
274 return orig(ui, repo, *pats, **opts) 274 return orig(ui, repo, *pats, **opts)
275 275
276 276
277 @eh.wrapfunction(cmdutil, b'add') 277 @eh.wrapfunction(cmdutil, b'add')
278 def cmdutiladd(orig, ui, repo, matcher, prefix, uipathfn, explicitonly, **opts): 278 def cmdutiladd(orig, ui, repo, matcher, prefix, uipathfn, explicitonly, **opts):
279 # The --normal flag short circuits this override 279 # The --normal flag short circuits this override
280 if opts.get(r'normal'): 280 if opts.get('normal'):
281 return orig(ui, repo, matcher, prefix, uipathfn, explicitonly, **opts) 281 return orig(ui, repo, matcher, prefix, uipathfn, explicitonly, **opts)
282 282
283 ladded, lbad = addlargefiles(ui, repo, False, matcher, uipathfn, **opts) 283 ladded, lbad = addlargefiles(ui, repo, False, matcher, uipathfn, **opts)
284 normalmatcher = composenormalfilematcher( 284 normalmatcher = composenormalfilematcher(
285 matcher, repo[None].manifest(), ladded 285 matcher, repo[None].manifest(), ladded
475 _(b'verify local largefile contents, not just existence'), 475 _(b'verify local largefile contents, not just existence'),
476 ), 476 ),
477 ], 477 ],
478 ) 478 )
479 def overrideverify(orig, ui, repo, *pats, **opts): 479 def overrideverify(orig, ui, repo, *pats, **opts):
480 large = opts.pop(r'large', False) 480 large = opts.pop('large', False)
481 all = opts.pop(r'lfa', False) 481 all = opts.pop('lfa', False)
482 contents = opts.pop(r'lfc', False) 482 contents = opts.pop('lfc', False)
483 483
484 result = orig(ui, repo, *pats, **opts) 484 result = orig(ui, repo, *pats, **opts)
485 if large or all or contents: 485 if large or all or contents:
486 result = result or lfcommands.verifylfiles(ui, repo, all, contents) 486 result = result or lfcommands.verifylfiles(ui, repo, all, contents)
487 return result 487 return result
490 @eh.wrapcommand( 490 @eh.wrapcommand(
491 b'debugstate', 491 b'debugstate',
492 opts=[(b'', b'large', None, _(b'display largefiles dirstate'))], 492 opts=[(b'', b'large', None, _(b'display largefiles dirstate'))],
493 ) 493 )
494 def overridedebugstate(orig, ui, repo, *pats, **opts): 494 def overridedebugstate(orig, ui, repo, *pats, **opts):
495 large = opts.pop(r'large', False) 495 large = opts.pop('large', False)
496 if large: 496 if large:
497 497
498 class fakerepo(object): 498 class fakerepo(object):
499 dirstate = lfutil.openlfdirstate(ui, repo) 499 dirstate = lfutil.openlfdirstate(ui, repo)
500 500
973 if not source: 973 if not source:
974 source = b'default' 974 source = b'default'
975 repo.lfpullsource = source 975 repo.lfpullsource = source
976 result = orig(ui, repo, source, **opts) 976 result = orig(ui, repo, source, **opts)
977 revspostpull = len(repo) 977 revspostpull = len(repo)
978 lfrevs = opts.get(r'lfrev', []) 978 lfrevs = opts.get('lfrev', [])
979 if opts.get(r'all_largefiles'): 979 if opts.get('all_largefiles'):
980 lfrevs.append(b'pulled()') 980 lfrevs.append(b'pulled()')
981 if lfrevs and revspostpull > revsprepull: 981 if lfrevs and revspostpull > revsprepull:
982 numcached = 0 982 numcached = 0
983 repo.firstpulled = revsprepull # for pulled() revset expression 983 repo.firstpulled = revsprepull # for pulled() revset expression
984 try: 984 try:
1004 ) 1004 )
1005 ], 1005 ],
1006 ) 1006 )
1007 def overridepush(orig, ui, repo, *args, **kwargs): 1007 def overridepush(orig, ui, repo, *args, **kwargs):
1008 """Override push command and store --lfrev parameters in opargs""" 1008 """Override push command and store --lfrev parameters in opargs"""
1009 lfrevs = kwargs.pop(r'lfrev', None) 1009 lfrevs = kwargs.pop('lfrev', None)
1010 if lfrevs: 1010 if lfrevs:
1011 opargs = kwargs.setdefault(r'opargs', {}) 1011 opargs = kwargs.setdefault('opargs', {})
1012 opargs[b'lfrevs'] = scmutil.revrange(repo, lfrevs) 1012 opargs[b'lfrevs'] = scmutil.revrange(repo, lfrevs)
1013 return orig(ui, repo, *args, **kwargs) 1013 return orig(ui, repo, *args, **kwargs)
1014 1014
1015 1015
1016 @eh.wrapfunction(exchange, b'pushoperation') 1016 @eh.wrapfunction(exchange, b'pushoperation')
1017 def exchangepushoperation(orig, *args, **kwargs): 1017 def exchangepushoperation(orig, *args, **kwargs):
1018 """Override pushoperation constructor and store lfrevs parameter""" 1018 """Override pushoperation constructor and store lfrevs parameter"""
1019 lfrevs = kwargs.pop(r'lfrevs', None) 1019 lfrevs = kwargs.pop('lfrevs', None)
1020 pushop = orig(*args, **kwargs) 1020 pushop = orig(*args, **kwargs)
1021 pushop.lfrevs = lfrevs 1021 pushop.lfrevs = lfrevs
1022 return pushop 1022 return pushop
1023 1023
1024 1024
1062 ) 1062 )
1063 def overrideclone(orig, ui, source, dest=None, **opts): 1063 def overrideclone(orig, ui, source, dest=None, **opts):
1064 d = dest 1064 d = dest
1065 if d is None: 1065 if d is None:
1066 d = hg.defaultdest(source) 1066 d = hg.defaultdest(source)
1067 if opts.get(r'all_largefiles') and not hg.islocal(d): 1067 if opts.get('all_largefiles') and not hg.islocal(d):
1068 raise error.Abort( 1068 raise error.Abort(
1069 _(b'--all-largefiles is incompatible with non-local destination %s') 1069 _(b'--all-largefiles is incompatible with non-local destination %s')
1070 % d 1070 % d
1071 ) 1071 )
1072 1072
1102 @eh.wrapcommand(b'rebase', extension=b'rebase') 1102 @eh.wrapcommand(b'rebase', extension=b'rebase')
1103 def overriderebase(orig, ui, repo, **opts): 1103 def overriderebase(orig, ui, repo, **opts):
1104 if not util.safehasattr(repo, b'_largefilesenabled'): 1104 if not util.safehasattr(repo, b'_largefilesenabled'):
1105 return orig(ui, repo, **opts) 1105 return orig(ui, repo, **opts)
1106 1106
1107 resuming = opts.get(r'continue') 1107 resuming = opts.get('continue')
1108 repo._lfcommithooks.append(lfutil.automatedcommithook(resuming)) 1108 repo._lfcommithooks.append(lfutil.automatedcommithook(resuming))
1109 repo._lfstatuswriters.append(lambda *msg, **opts: None) 1109 repo._lfstatuswriters.append(lambda *msg, **opts: None)
1110 try: 1110 try:
1111 return orig(ui, repo, **opts) 1111 return orig(ui, repo, **opts)
1112 finally: 1112 finally:
1594 return result 1594 return result
1595 1595
1596 1596
1597 @eh.wrapcommand(b'transplant', extension=b'transplant') 1597 @eh.wrapcommand(b'transplant', extension=b'transplant')
1598 def overridetransplant(orig, ui, repo, *revs, **opts): 1598 def overridetransplant(orig, ui, repo, *revs, **opts):
1599 resuming = opts.get(r'continue') 1599 resuming = opts.get('continue')
1600 repo._lfcommithooks.append(lfutil.automatedcommithook(resuming)) 1600 repo._lfcommithooks.append(lfutil.automatedcommithook(resuming))
1601 repo._lfstatuswriters.append(lambda *msg, **opts: None) 1601 repo._lfstatuswriters.append(lambda *msg, **opts: None)
1602 try: 1602 try:
1603 result = orig(ui, repo, *revs, **opts) 1603 result = orig(ui, repo, *revs, **opts)
1604 finally: 1604 finally:
1679 return err 1679 return err
1680 1680
1681 1681
1682 @eh.wrapfunction(merge, b'update') 1682 @eh.wrapfunction(merge, b'update')
1683 def mergeupdate(orig, repo, node, branchmerge, force, *args, **kwargs): 1683 def mergeupdate(orig, repo, node, branchmerge, force, *args, **kwargs):
1684 matcher = kwargs.get(r'matcher', None) 1684 matcher = kwargs.get('matcher', None)
1685 # note if this is a partial update 1685 # note if this is a partial update
1686 partial = matcher and not matcher.always() 1686 partial = matcher and not matcher.always()
1687 with repo.wlock(): 1687 with repo.wlock():
1688 # branch | | | 1688 # branch | | |
1689 # merge | force | partial | action 1689 # merge | force | partial | action
1739 1739
1740 oldstandins = lfutil.getstandinsstate(repo) 1740 oldstandins = lfutil.getstandinsstate(repo)
1741 # Make sure the merge runs on disk, not in-memory. largefiles is not a 1741 # Make sure the merge runs on disk, not in-memory. largefiles is not a
1742 # good candidate for in-memory merge (large files, custom dirstate, 1742 # good candidate for in-memory merge (large files, custom dirstate,
1743 # matcher usage). 1743 # matcher usage).
1744 kwargs[r'wc'] = repo[None] 1744 kwargs['wc'] = repo[None]
1745 result = orig(repo, node, branchmerge, force, *args, **kwargs) 1745 result = orig(repo, node, branchmerge, force, *args, **kwargs)
1746 1746
1747 newstandins = lfutil.getstandinsstate(repo) 1747 newstandins = lfutil.getstandinsstate(repo)
1748 filelist = lfutil.getlfilestoupdate(oldstandins, newstandins) 1748 filelist = lfutil.getlfilestoupdate(oldstandins, newstandins)
1749 1749