changeset 50785:bf92386f76fd

wrapfunction: use sysstr instead of bytes as argument in "largefiles" This is as valid and simpler, it will help us to eventually get ride of `safehasattr`.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Fri, 03 Feb 2023 04:22:41 +0100
parents fcb67b8c8107
children dde4b55a0785
files hgext/largefiles/__init__.py hgext/largefiles/overrides.py hgext/largefiles/proto.py
diffstat 3 files changed, 31 insertions(+), 31 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/largefiles/__init__.py	Fri Feb 03 04:22:28 2023 +0100
+++ b/hgext/largefiles/__init__.py	Fri Feb 03 04:22:41 2023 +0100
@@ -184,7 +184,7 @@
     )
 
     extensions.wrapfunction(
-        wireprotov1server.commands[b'heads'], b'func', proto.heads
+        wireprotov1server.commands[b'heads'], 'func', proto.heads
     )
     # TODO also wrap wireproto.commandsv2 once heads is implemented there.
 
--- a/hgext/largefiles/overrides.py	Fri Feb 03 04:22:28 2023 +0100
+++ b/hgext/largefiles/overrides.py	Fri Feb 03 04:22:41 2023 +0100
@@ -243,7 +243,7 @@
 
 # For overriding mercurial.hgweb.webcommands so that largefiles will
 # appear at their right place in the manifests.
-@eh.wrapfunction(webcommands, b'decodepath')
+@eh.wrapfunction(webcommands, 'decodepath')
 def decodepath(orig, path):
     return lfutil.splitstandin(path) or path
 
@@ -273,7 +273,7 @@
     return orig(ui, repo, *pats, **opts)
 
 
-@eh.wrapfunction(cmdutil, b'add')
+@eh.wrapfunction(cmdutil, 'add')
 def cmdutiladd(orig, ui, repo, matcher, prefix, uipathfn, explicitonly, **opts):
     # The --normal flag short circuits this override
     if opts.get('normal'):
@@ -289,7 +289,7 @@
     return bad
 
 
-@eh.wrapfunction(cmdutil, b'remove')
+@eh.wrapfunction(cmdutil, 'remove')
 def cmdutilremove(
     orig, ui, repo, matcher, prefix, uipathfn, after, force, subrepos, dryrun
 ):
@@ -313,7 +313,7 @@
     )
 
 
-@eh.wrapfunction(dirstate.dirstate, b'_changing')
+@eh.wrapfunction(dirstate.dirstate, '_changing')
 @contextlib.contextmanager
 def _changing(orig, self, repo, change_type):
     pre = sub_dirstate = getattr(self, '_sub_dirstate', None)
@@ -334,7 +334,7 @@
         self._sub_dirstate = pre
 
 
-@eh.wrapfunction(dirstate.dirstate, b'running_status')
+@eh.wrapfunction(dirstate.dirstate, 'running_status')
 @contextlib.contextmanager
 def running_status(orig, self, repo):
     pre = sub_dirstate = getattr(self, '_sub_dirstate', None)
@@ -355,7 +355,7 @@
         self._sub_dirstate = pre
 
 
-@eh.wrapfunction(subrepo.hgsubrepo, b'status')
+@eh.wrapfunction(subrepo.hgsubrepo, 'status')
 def overridestatusfn(orig, repo, rev2, **opts):
     with lfstatus(repo._repo):
         return orig(repo, rev2, **opts)
@@ -367,7 +367,7 @@
         return orig(ui, repo, *pats, **opts)
 
 
-@eh.wrapfunction(subrepo.hgsubrepo, b'dirty')
+@eh.wrapfunction(subrepo.hgsubrepo, 'dirty')
 def overridedirty(orig, repo, ignoreupdate=False, missing=False):
     with lfstatus(repo._repo):
         return orig(repo, ignoreupdate=ignoreupdate, missing=missing)
@@ -554,7 +554,7 @@
 # The overridden function filters the unknown files by removing any
 # largefiles. This makes the merge proceed and we can then handle this
 # case further in the overridden calculateupdates function below.
-@eh.wrapfunction(merge, b'_checkunknownfile')
+@eh.wrapfunction(merge, '_checkunknownfile')
 def overridecheckunknownfile(
     origfn, dirstate, wvfs, dircache, wctx, mctx, f, f2=None
 ):
@@ -589,7 +589,7 @@
 # Finally, the merge.applyupdates function will then take care of
 # writing the files into the working copy and lfcommands.updatelfiles
 # will update the largefiles.
-@eh.wrapfunction(merge, b'calculateupdates')
+@eh.wrapfunction(merge, 'calculateupdates')
 def overridecalculateupdates(
     origfn, repo, p1, p2, pas, branchmerge, force, acceptremote, *args, **kwargs
 ):
@@ -700,7 +700,7 @@
     return mresult
 
 
-@eh.wrapfunction(mergestatemod, b'recordupdates')
+@eh.wrapfunction(mergestatemod, 'recordupdates')
 def mergerecordupdates(orig, repo, actions, branchmerge, getfiledata):
     if MERGE_ACTION_LARGEFILE_MARK_REMOVED in actions:
         lfdirstate = lfutil.openlfdirstate(repo.ui, repo)
@@ -716,7 +716,7 @@
 
 # Override filemerge to prompt the user about how they wish to merge
 # largefiles. This will handle identical edits without prompting the user.
-@eh.wrapfunction(filemerge, b'filemerge')
+@eh.wrapfunction(filemerge, 'filemerge')
 def overridefilemerge(
     origfn, repo, wctx, mynode, orig, fcd, fco, fca, labels=None
 ):
@@ -748,7 +748,7 @@
     return 0, False
 
 
-@eh.wrapfunction(copiesmod, b'pathcopies')
+@eh.wrapfunction(copiesmod, 'pathcopies')
 def copiespathcopies(orig, ctx1, ctx2, match=None):
     copies = orig(ctx1, ctx2, match=match)
     updated = {}
@@ -764,7 +764,7 @@
 # checks if the destination largefile already exists. It also keeps a
 # list of copied files so that the largefiles can be copied and the
 # dirstate updated.
-@eh.wrapfunction(cmdutil, b'copy')
+@eh.wrapfunction(cmdutil, 'copy')
 def overridecopy(orig, ui, repo, pats, opts, rename=False):
     # doesn't remove largefile on rename
     if len(pats) < 2:
@@ -936,7 +936,7 @@
 # commits. Update the standins then run the original revert, changing
 # the matcher to hit standins instead of largefiles. Based on the
 # resulting standins update the largefiles.
-@eh.wrapfunction(cmdutil, b'revert')
+@eh.wrapfunction(cmdutil, 'revert')
 def overriderevert(orig, ui, repo, ctx, *pats, **opts):
     # Because we put the standins in a bad state (by updating them)
     # and then return them to a correct state we need to lock to
@@ -1079,7 +1079,7 @@
     return orig(ui, repo, *args, **kwargs)
 
 
-@eh.wrapfunction(exchange, b'pushoperation')
+@eh.wrapfunction(exchange, 'pushoperation')
 def exchangepushoperation(orig, *args, **kwargs):
     """Override pushoperation constructor and store lfrevs parameter"""
     lfrevs = kwargs.pop('lfrevs', None)
@@ -1139,7 +1139,7 @@
     return orig(ui, source, dest, **opts)
 
 
-@eh.wrapfunction(hg, b'clone')
+@eh.wrapfunction(hg, 'clone')
 def hgclone(orig, ui, opts, *args, **kwargs):
     result = orig(ui, opts, *args, **kwargs)
 
@@ -1195,7 +1195,7 @@
             kwargs['inmemory'] = False
             return orig(*args, **kwargs)
 
-        extensions.wrapfunction(rebase, b'_dorebase', _dorebase)
+        extensions.wrapfunction(rebase, '_dorebase', _dorebase)
 
 
 @eh.wrapcommand(b'archive')
@@ -1204,13 +1204,13 @@
         return orig(ui, repo.unfiltered(), dest, **opts)
 
 
-@eh.wrapfunction(webcommands, b'archive')
+@eh.wrapfunction(webcommands, 'archive')
 def hgwebarchive(orig, web):
     with lfstatus(web.repo):
         return orig(web)
 
 
-@eh.wrapfunction(archival, b'archive')
+@eh.wrapfunction(archival, 'archive')
 def overridearchive(
     orig,
     repo,
@@ -1307,7 +1307,7 @@
     archiver.done()
 
 
-@eh.wrapfunction(subrepo.hgsubrepo, b'archive')
+@eh.wrapfunction(subrepo.hgsubrepo, 'archive')
 def hgsubrepoarchive(orig, repo, archiver, prefix, match=None, decode=True):
     lfenabled = util.safehasattr(repo._repo, b'_largefilesenabled')
     if not lfenabled or not repo._repo.lfstatus:
@@ -1375,7 +1375,7 @@
 # standin until a commit. cmdutil.bailifchanged() raises an exception
 # if the repo has uncommitted changes. Wrap it to also check if
 # largefiles were changed. This is used by bisect, backout and fetch.
-@eh.wrapfunction(cmdutil, b'bailifchanged')
+@eh.wrapfunction(cmdutil, 'bailifchanged')
 def overridebailifchanged(orig, repo, *args, **kwargs):
     orig(repo, *args, **kwargs)
     with lfstatus(repo):
@@ -1384,13 +1384,13 @@
         raise error.Abort(_(b'uncommitted changes'))
 
 
-@eh.wrapfunction(cmdutil, b'postcommitstatus')
+@eh.wrapfunction(cmdutil, 'postcommitstatus')
 def postcommitstatus(orig, repo, *args, **kwargs):
     with lfstatus(repo):
         return orig(repo, *args, **kwargs)
 
 
-@eh.wrapfunction(cmdutil, b'forget')
+@eh.wrapfunction(cmdutil, 'forget')
 def cmdutilforget(
     orig, ui, repo, match, prefix, uipathfn, explicitonly, dryrun, interactive
 ):
@@ -1559,7 +1559,7 @@
         orig(ui, repo, *pats, **opts)
 
 
-@eh.wrapfunction(scmutil, b'addremove')
+@eh.wrapfunction(scmutil, 'addremove')
 def scmutiladdremove(
     orig,
     repo,
@@ -1787,7 +1787,7 @@
     return err
 
 
-@eh.wrapfunction(merge, b'_update')
+@eh.wrapfunction(merge, '_update')
 def mergeupdate(orig, repo, node, branchmerge, force, *args, **kwargs):
     matcher = kwargs.get('matcher', None)
     # note if this is a partial update
@@ -1880,7 +1880,7 @@
         return result
 
 
-@eh.wrapfunction(scmutil, b'marktouched')
+@eh.wrapfunction(scmutil, 'marktouched')
 def scmutilmarktouched(orig, repo, files, *args, **kwargs):
     result = orig(repo, files, *args, **kwargs)
 
@@ -1901,8 +1901,8 @@
     return result
 
 
-@eh.wrapfunction(upgrade_actions, b'preservedrequirements')
-@eh.wrapfunction(upgrade_actions, b'supporteddestrequirements')
+@eh.wrapfunction(upgrade_actions, 'preservedrequirements')
+@eh.wrapfunction(upgrade_actions, 'supporteddestrequirements')
 def upgraderequirements(orig, repo):
     reqs = orig(repo)
     if b'largefiles' in repo.requirements:
@@ -1913,7 +1913,7 @@
 _lfscheme = b'largefile://'
 
 
-@eh.wrapfunction(urlmod, b'open')
+@eh.wrapfunction(urlmod, 'open')
 def openlargefile(orig, ui, url_, data=None, **kwargs):
     if url_.startswith(_lfscheme):
         if data:
--- a/hgext/largefiles/proto.py	Fri Feb 03 04:22:28 2023 +0100
+++ b/hgext/largefiles/proto.py	Fri Feb 03 04:22:41 2023 +0100
@@ -200,7 +200,7 @@
 
 
 # advertise the largefiles=serve capability
-@eh.wrapfunction(wireprotov1server, b'_capabilities')
+@eh.wrapfunction(wireprotov1server, '_capabilities')
 def _capabilities(orig, repo, proto):
     '''announce largefile server capability'''
     caps = orig(repo, proto)