--- a/hgext/sparse.py Sun Oct 06 09:45:02 2019 -0400
+++ b/hgext/sparse.py Sun Oct 06 09:48:39 2019 -0400
@@ -92,7 +92,7 @@
# extensions which SHIP WITH MERCURIAL. Non-mainline extensions should
# be specifying the version(s) of Mercurial they are tested with, or
# leave the attribute unspecified.
-testedwith = 'ships-with-hg-core'
+testedwith = b'ships-with-hg-core'
cmdtable = {}
command = registrar.command(cmdtable)
@@ -121,24 +121,24 @@
if cls is object:
raise AttributeError(
- _("type '%s' has no property '%s'") % (origcls, propname)
+ _(b"type '%s' has no property '%s'") % (origcls, propname)
)
def _setuplog(ui):
- entry = commands.table['log|history']
+ entry = commands.table[b'log|history']
entry[1].append(
(
- '',
- 'sparse',
+ b'',
+ b'sparse',
None,
- "limit to changesets affecting the sparse checkout",
+ b"limit to changesets affecting the sparse checkout",
)
)
def _initialrevs(orig, repo, opts):
revs = orig(repo, opts)
- if opts.get('sparse'):
+ if opts.get(b'sparse'):
sparsematch = sparse.matcher(repo)
def ctxmatch(rev):
@@ -148,7 +148,7 @@
revs = revs.filter(ctxmatch)
return revs
- extensions.wrapfunction(logcmdutil, '_initialrevs', _initialrevs)
+ extensions.wrapfunction(logcmdutil, b'_initialrevs', _initialrevs)
def _clonesparsecmd(orig, ui, repo, *args, **opts):
@@ -167,7 +167,7 @@
pat = enableprofile_pat
enableprofile = True
if sum([include, exclude, enableprofile]) > 1:
- raise error.Abort(_("too many flags specified."))
+ raise error.Abort(_(b"too many flags specified."))
# if --narrow is passed, it means they are includes and excludes for narrow
# clone
if not narrow_pat and (include or exclude or enableprofile):
@@ -184,26 +184,26 @@
)
return orig(self, node, overwrite, *args, **kwargs)
- extensions.wrapfunction(hg, 'updaterepo', clonesparse)
+ extensions.wrapfunction(hg, b'updaterepo', clonesparse)
return orig(ui, repo, *args, **opts)
def _setupclone(ui):
- entry = commands.table['clone']
- entry[1].append(('', 'enable-profile', [], 'enable a sparse profile'))
- entry[1].append(('', 'include', [], 'include sparse pattern'))
- entry[1].append(('', 'exclude', [], 'exclude sparse pattern'))
- extensions.wrapcommand(commands.table, 'clone', _clonesparsecmd)
+ entry = commands.table[b'clone']
+ entry[1].append((b'', b'enable-profile', [], b'enable a sparse profile'))
+ entry[1].append((b'', b'include', [], b'include sparse pattern'))
+ entry[1].append((b'', b'exclude', [], b'exclude sparse pattern'))
+ extensions.wrapcommand(commands.table, b'clone', _clonesparsecmd)
def _setupadd(ui):
- entry = commands.table['add']
+ entry = commands.table[b'add']
entry[1].append(
(
- 's',
- 'sparse',
+ b's',
+ b'sparse',
None,
- 'also include directories of added files in sparse config',
+ b'also include directories of added files in sparse config',
)
)
@@ -216,7 +216,7 @@
sparse.updateconfig(repo, list(dirs), opts, include=True)
return orig(ui, repo, *pats, **opts)
- extensions.wrapcommand(commands.table, 'add', _add)
+ extensions.wrapcommand(commands.table, b'add', _add)
def _setupdirstate(ui):
@@ -232,7 +232,7 @@
match = matchmod.intersectmatchers(match, sm)
return orig(self, match, subrepos, unknown, ignored, full)
- extensions.wrapfunction(dirstate.dirstate, 'walk', walk)
+ extensions.wrapfunction(dirstate.dirstate, b'walk', walk)
# dirstate.rebuild should not add non-matching files
def _rebuild(orig, self, parent, allfiles, changedfiles=None):
@@ -250,13 +250,20 @@
return orig(self, parent, allfiles, changedfiles)
- extensions.wrapfunction(dirstate.dirstate, 'rebuild', _rebuild)
+ extensions.wrapfunction(dirstate.dirstate, b'rebuild', _rebuild)
# Prevent adding files that are outside the sparse checkout
- editfuncs = ['normal', 'add', 'normallookup', 'copy', 'remove', 'merge']
+ editfuncs = [
+ b'normal',
+ b'add',
+ b'normallookup',
+ b'copy',
+ b'remove',
+ b'merge',
+ ]
hint = _(
- 'include file with `hg debugsparse --include <pattern>` or use '
- + '`hg add -s <file>` to include file directory while adding'
+ b'include file with `hg debugsparse --include <pattern>` or use '
+ + b'`hg add -s <file>` to include file directory while adding'
)
for func in editfuncs:
@@ -267,8 +274,8 @@
if f is not None and not sparsematch(f) and f not in self:
raise error.Abort(
_(
- "cannot add '%s' - it is outside "
- "the sparse checkout"
+ b"cannot add '%s' - it is outside "
+ b"the sparse checkout"
)
% f,
hint=hint,
@@ -279,31 +286,31 @@
@command(
- 'debugsparse',
+ b'debugsparse',
[
- ('I', 'include', False, _('include files in the sparse checkout')),
- ('X', 'exclude', False, _('exclude files in the sparse checkout')),
- ('d', 'delete', False, _('delete an include/exclude rule')),
+ (b'I', b'include', False, _(b'include files in the sparse checkout')),
+ (b'X', b'exclude', False, _(b'exclude files in the sparse checkout')),
+ (b'd', b'delete', False, _(b'delete an include/exclude rule')),
(
- 'f',
- 'force',
+ b'f',
+ b'force',
False,
- _('allow changing rules even with pending changes'),
+ _(b'allow changing rules even with pending changes'),
),
- ('', 'enable-profile', False, _('enables the specified profile')),
- ('', 'disable-profile', False, _('disables the specified profile')),
- ('', 'import-rules', False, _('imports rules from a file')),
- ('', 'clear-rules', False, _('clears local include/exclude rules')),
+ (b'', b'enable-profile', False, _(b'enables the specified profile')),
+ (b'', b'disable-profile', False, _(b'disables the specified profile')),
+ (b'', b'import-rules', False, _(b'imports rules from a file')),
+ (b'', b'clear-rules', False, _(b'clears local include/exclude rules')),
(
- '',
- 'refresh',
+ b'',
+ b'refresh',
False,
- _('updates the working after sparseness changes'),
+ _(b'updates the working after sparseness changes'),
),
- ('', 'reset', False, _('makes the repo full again')),
+ (b'', b'reset', False, _(b'makes the repo full again')),
]
+ commands.templateopts,
- _('[--OPTION] PATTERN...'),
+ _(b'[--OPTION] PATTERN...'),
helpbasic=True,
)
def debugsparse(ui, repo, *pats, **opts):
@@ -348,16 +355,16 @@
Returns 0 if editing the sparse checkout succeeds.
"""
opts = pycompat.byteskwargs(opts)
- include = opts.get('include')
- exclude = opts.get('exclude')
- force = opts.get('force')
- enableprofile = opts.get('enable_profile')
- disableprofile = opts.get('disable_profile')
- importrules = opts.get('import_rules')
- clearrules = opts.get('clear_rules')
- delete = opts.get('delete')
- refresh = opts.get('refresh')
- reset = opts.get('reset')
+ include = opts.get(b'include')
+ exclude = opts.get(b'exclude')
+ force = opts.get(b'force')
+ enableprofile = opts.get(b'enable_profile')
+ disableprofile = opts.get(b'disable_profile')
+ importrules = opts.get(b'import_rules')
+ clearrules = opts.get(b'clear_rules')
+ delete = opts.get(b'delete')
+ refresh = opts.get(b'refresh')
+ reset = opts.get(b'reset')
count = sum(
[
include,
@@ -372,21 +379,23 @@
]
)
if count > 1:
- raise error.Abort(_("too many flags specified"))
+ raise error.Abort(_(b"too many flags specified"))
if count == 0:
- if repo.vfs.exists('sparse'):
- ui.status(repo.vfs.read("sparse") + "\n")
+ if repo.vfs.exists(b'sparse'):
+ ui.status(repo.vfs.read(b"sparse") + b"\n")
temporaryincludes = sparse.readtemporaryincludes(repo)
if temporaryincludes:
- ui.status(_("Temporarily Included Files (for merge/rebase):\n"))
- ui.status(("\n".join(temporaryincludes) + "\n"))
+ ui.status(
+ _(b"Temporarily Included Files (for merge/rebase):\n")
+ )
+ ui.status((b"\n".join(temporaryincludes) + b"\n"))
return
else:
raise error.Abort(
_(
- 'the debugsparse command is only supported on'
- ' sparse repositories'
+ b'the debugsparse command is only supported on'
+ b' sparse repositories'
)
)