Mercurial > hg
comparison hgext/remotefilelog/__init__.py @ 40610:13d4ad8d7801
py3: fix keyword arguments handling in hgext/remotefilelog/
Keys of kwargs on Python 3 should be strings. This patch fixes them by appending
r'' prefixes, and using pycompat.byteskwargs() and pycompat.strkwargs().
Differential Revision: https://phab.mercurial-scm.org/D5259
author | Pulkit Goyal <pulkit@yandex-team.ru> |
---|---|
date | Tue, 13 Nov 2018 17:41:26 +0300 |
parents | 157f0e29eaa3 |
children | 32a23c3f56d4 |
comparison
equal
deleted
inserted
replaced
40609:ee9981bc8b44 | 40610:13d4ad8d7801 |
---|---|
149 localrepo, | 149 localrepo, |
150 match, | 150 match, |
151 merge, | 151 merge, |
152 node as nodemod, | 152 node as nodemod, |
153 patch, | 153 patch, |
154 pycompat, | |
154 registrar, | 155 registrar, |
155 repair, | 156 repair, |
156 repoview, | 157 repoview, |
157 revset, | 158 revset, |
158 scmutil, | 159 scmutil, |
270 extensions.wrapcommand(commands.table, 'log', log) | 271 extensions.wrapcommand(commands.table, 'log', log) |
271 extensions.wrapcommand(commands.table, 'pull', pull) | 272 extensions.wrapcommand(commands.table, 'pull', pull) |
272 | 273 |
273 # Prevent 'hg manifest --all' | 274 # Prevent 'hg manifest --all' |
274 def _manifest(orig, ui, repo, *args, **opts): | 275 def _manifest(orig, ui, repo, *args, **opts): |
275 if (isenabled(repo) and opts.get('all')): | 276 if (isenabled(repo) and opts.get(r'all')): |
276 raise error.Abort(_("--all is not supported in a shallow repo")) | 277 raise error.Abort(_("--all is not supported in a shallow repo")) |
277 | 278 |
278 return orig(ui, repo, *args, **opts) | 279 return orig(ui, repo, *args, **opts) |
279 extensions.wrapcommand(commands.table, "manifest", _manifest) | 280 extensions.wrapcommand(commands.table, "manifest", _manifest) |
280 | 281 |
292 | 293 |
293 # debugdata needs remotefilelog.len to work | 294 # debugdata needs remotefilelog.len to work |
294 extensions.wrapcommand(commands.table, 'debugdata', debugdatashallow) | 295 extensions.wrapcommand(commands.table, 'debugdata', debugdatashallow) |
295 | 296 |
296 def cloneshallow(orig, ui, repo, *args, **opts): | 297 def cloneshallow(orig, ui, repo, *args, **opts): |
297 if opts.get('shallow'): | 298 if opts.get(r'shallow'): |
298 repos = [] | 299 repos = [] |
299 def pull_shallow(orig, self, *args, **kwargs): | 300 def pull_shallow(orig, self, *args, **kwargs): |
300 if not isenabled(self): | 301 if not isenabled(self): |
301 repos.append(self.unfiltered()) | 302 repos.append(self.unfiltered()) |
302 # set up the client hooks so the post-clone update works | 303 # set up the client hooks so the post-clone update works |
325 def stream_out_shallow(orig): | 326 def stream_out_shallow(orig): |
326 caps = remote.capabilities() | 327 caps = remote.capabilities() |
327 if constants.NETWORK_CAP_LEGACY_SSH_GETFILES in caps: | 328 if constants.NETWORK_CAP_LEGACY_SSH_GETFILES in caps: |
328 opts = {} | 329 opts = {} |
329 if repo.includepattern: | 330 if repo.includepattern: |
330 opts['includepattern'] = '\0'.join(repo.includepattern) | 331 opts[r'includepattern'] = '\0'.join(repo.includepattern) |
331 if repo.excludepattern: | 332 if repo.excludepattern: |
332 opts['excludepattern'] = '\0'.join(repo.excludepattern) | 333 opts[r'excludepattern'] = '\0'.join(repo.excludepattern) |
333 return remote._callstream('stream_out_shallow', **opts) | 334 return remote._callstream('stream_out_shallow', **opts) |
334 else: | 335 else: |
335 return orig() | 336 return orig() |
336 extensions.wrapfunction(remote, 'stream_out', stream_out_shallow) | 337 extensions.wrapfunction(remote, 'stream_out', stream_out_shallow) |
337 def stream_wrap(orig, op): | 338 def stream_wrap(orig, op): |
358 streamclone, 'canperformstreamclone', canperformstreamclone) | 359 streamclone, 'canperformstreamclone', canperformstreamclone) |
359 | 360 |
360 try: | 361 try: |
361 orig(ui, repo, *args, **opts) | 362 orig(ui, repo, *args, **opts) |
362 finally: | 363 finally: |
363 if opts.get('shallow'): | 364 if opts.get(r'shallow'): |
364 for r in repos: | 365 for r in repos: |
365 if util.safehasattr(r, 'fileservice'): | 366 if util.safehasattr(r, 'fileservice'): |
366 r.fileservice.close() | 367 r.fileservice.close() |
367 | 368 |
368 def debugdatashallow(orig, *args, **kwds): | 369 def debugdatashallow(orig, *args, **kwds): |
886 | 887 |
887 def log(orig, ui, repo, *pats, **opts): | 888 def log(orig, ui, repo, *pats, **opts): |
888 if not isenabled(repo): | 889 if not isenabled(repo): |
889 return orig(ui, repo, *pats, **opts) | 890 return orig(ui, repo, *pats, **opts) |
890 | 891 |
891 follow = opts.get('follow') | 892 follow = opts.get(r'follow') |
892 revs = opts.get('rev') | 893 revs = opts.get(r'rev') |
893 if pats: | 894 if pats: |
894 # Force slowpath for non-follow patterns and follows that start from | 895 # Force slowpath for non-follow patterns and follows that start from |
895 # non-working-copy-parent revs. | 896 # non-working-copy-parent revs. |
896 if not follow or revs: | 897 if not follow or revs: |
897 # This forces the slowpath | 898 # This forces the slowpath |
898 opts['removed'] = True | 899 opts[r'removed'] = True |
899 | 900 |
900 # If this is a non-follow log without any revs specified, recommend that | 901 # If this is a non-follow log without any revs specified, recommend that |
901 # the user add -f to speed it up. | 902 # the user add -f to speed it up. |
902 if not follow and not revs: | 903 if not follow and not revs: |
903 match, pats = scmutil.matchandpats(repo['.'], pats, opts) | 904 match, pats = scmutil.matchandpats(repo['.'], pats, |
905 pycompat.byteskwargs(opts)) | |
904 isfile = not match.anypats() | 906 isfile = not match.anypats() |
905 if isfile: | 907 if isfile: |
906 for file in match.files(): | 908 for file in match.files(): |
907 if not os.path.isfile(repo.wjoin(file)): | 909 if not os.path.isfile(repo.wjoin(file)): |
908 isfile = False | 910 isfile = False |
1102 used which is the union of dot, draft, pullprefetch and bgprefetchrev. | 1104 used which is the union of dot, draft, pullprefetch and bgprefetchrev. |
1103 File names or patterns can be used to limit which files are downloaded. | 1105 File names or patterns can be used to limit which files are downloaded. |
1104 | 1106 |
1105 Return 0 on success. | 1107 Return 0 on success. |
1106 """ | 1108 """ |
1109 opts = pycompat.byteskwargs(opts) | |
1107 if not isenabled(repo): | 1110 if not isenabled(repo): |
1108 raise error.Abort(_("repo is not shallow")) | 1111 raise error.Abort(_("repo is not shallow")) |
1109 | 1112 |
1110 opts = resolveprefetchopts(ui, opts) | 1113 opts = resolveprefetchopts(ui, opts) |
1111 revs = scmutil.revrange(repo, opts.get('rev')) | 1114 revs = scmutil.revrange(repo, opts.get('rev')) |
1119 ('', 'background', None, _('run in a background process'), None), | 1122 ('', 'background', None, _('run in a background process'), None), |
1120 ('', 'incremental', None, _('do an incremental repack'), None), | 1123 ('', 'incremental', None, _('do an incremental repack'), None), |
1121 ('', 'packsonly', None, _('only repack packs (skip loose objects)'), None), | 1124 ('', 'packsonly', None, _('only repack packs (skip loose objects)'), None), |
1122 ], _('hg repack [OPTIONS]')) | 1125 ], _('hg repack [OPTIONS]')) |
1123 def repack_(ui, repo, *pats, **opts): | 1126 def repack_(ui, repo, *pats, **opts): |
1124 if opts.get('background'): | 1127 if opts.get(r'background'): |
1125 repackmod.backgroundrepack(repo, incremental=opts.get('incremental'), | 1128 repackmod.backgroundrepack(repo, incremental=opts.get(r'incremental'), |
1126 packsonly=opts.get('packsonly', False)) | 1129 packsonly=opts.get(r'packsonly', False)) |
1127 return | 1130 return |
1128 | 1131 |
1129 options = {'packsonly': opts.get('packsonly')} | 1132 options = {'packsonly': opts.get(r'packsonly')} |
1130 | 1133 |
1131 try: | 1134 try: |
1132 if opts.get('incremental'): | 1135 if opts.get(r'incremental'): |
1133 repackmod.incrementalrepack(repo, options=options) | 1136 repackmod.incrementalrepack(repo, options=options) |
1134 else: | 1137 else: |
1135 repackmod.fullrepack(repo, options=options) | 1138 repackmod.fullrepack(repo, options=options) |
1136 except repackmod.RepackAlreadyRunning as ex: | 1139 except repackmod.RepackAlreadyRunning as ex: |
1137 # Don't propogate the exception if the repack is already in | 1140 # Don't propogate the exception if the repack is already in |