##// END OF EJS Templates
repoview: move subsettable in a dedicated module...
repoview: move subsettable in a dedicated module The dictionary got moved in `branchmap` to avoid import cycle. However, we are about to needs it in repoview too. So we introduce a now module to define that that mapping.

File last commit:

r42146:6cad258e default
r42309:890f450f default
Show More
narrowcommands.py
463 lines | 18.9 KiB | text/x-python | PythonLexer
Augie Fackler
narrow: import experimental extension from narrowhg revision cb51d673e9c5...
r36096 # narrowcommands.py - command modifications for narrowhg extension
#
# Copyright 2017 Google, Inc.
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2 or any later version.
from __future__ import absolute_import
import itertools
Pulkit Goyal
narrow: add a --narrowspec flag to clone command...
r39283 import os
Augie Fackler
narrow: import experimental extension from narrowhg revision cb51d673e9c5...
r36096
from mercurial.i18n import _
from mercurial import (
Pulkit Goyal
narrow: the first version of narrow_widen wireprotocol command...
r40106 bundle2,
Augie Fackler
narrow: import experimental extension from narrowhg revision cb51d673e9c5...
r36096 cmdutil,
commands,
discovery,
Pulkit Goyal
narrow: add '--import-rules' flag to tracked command...
r39471 encoding,
Augie Fackler
narrow: import experimental extension from narrowhg revision cb51d673e9c5...
r36096 error,
exchange,
extensions,
hg,
Gregory Szorc
narrowspec: move module into core...
r36178 narrowspec,
Augie Fackler
narrow: import experimental extension from narrowhg revision cb51d673e9c5...
r36096 node,
Augie Fackler
narrowcommands: use pycompat.{bytes,str}kwargs...
r36172 pycompat,
Augie Fackler
narrow: import experimental extension from narrowhg revision cb51d673e9c5...
r36096 registrar,
repair,
Martin von Zweigbergk
narrow: move requirement constant from changegroup to repository...
r38871 repository,
Augie Fackler
narrow: import experimental extension from narrowhg revision cb51d673e9c5...
r36096 repoview,
Pulkit Goyal
narrow: add a --narrowspec flag to clone command...
r39283 sparse,
Augie Fackler
narrow: import experimental extension from narrowhg revision cb51d673e9c5...
r36096 util,
Pulkit Goyal
wireprotoserver: move narrow capabilities to wireprototypes.py...
r40110 wireprototypes,
Augie Fackler
narrow: import experimental extension from narrowhg revision cb51d673e9c5...
r36096 )
table = {}
command = registrar.command(table)
def setup():
"""Wraps user-facing mercurial commands with narrow-aware versions."""
entry = extensions.wrapcommand(commands.table, 'clone', clonenarrowcmd)
entry[1].append(('', 'narrow', None,
_("create a narrow clone of select files")))
entry[1].append(('', 'depth', '',
_("limit the history fetched by distance from heads")))
Pulkit Goyal
narrow: add a --narrowspec flag to clone command...
r39283 entry[1].append(('', 'narrowspec', '',
_("read narrowspecs from file")))
Augie Fackler
narrow: import experimental extension from narrowhg revision cb51d673e9c5...
r36096 # TODO(durin42): unify sparse/narrow --include/--exclude logic a bit
if 'sparse' not in extensions.enabled():
entry[1].append(('', 'include', [],
_("specifically fetch this file/directory")))
entry[1].append(
('', 'exclude', [],
_("do not fetch this file/directory, even if included")))
entry = extensions.wrapcommand(commands.table, 'pull', pullnarrowcmd)
entry[1].append(('', 'depth', '',
_("limit the history fetched by distance from heads")))
extensions.wrapcommand(commands.table, 'archive', archivenarrowcmd)
def clonenarrowcmd(orig, ui, repo, *args, **opts):
"""Wraps clone command, so 'hg clone' first wraps localrepo.clone()."""
Augie Fackler
narrowcommands: use pycompat.{bytes,str}kwargs...
r36172 opts = pycompat.byteskwargs(opts)
Augie Fackler
narrow: import experimental extension from narrowhg revision cb51d673e9c5...
r36096 wrappedextraprepare = util.nullcontextmanager()
Pulkit Goyal
narrow: add a --narrowspec flag to clone command...
r39283 narrowspecfile = opts['narrowspec']
if narrowspecfile:
Matt Harbison
py3: rename pycompat.getcwd() to encoding.getcwd() (API)...
r39843 filepath = os.path.join(encoding.getcwd(), narrowspecfile)
Pulkit Goyal
narrow: add a --narrowspec flag to clone command...
r39283 ui.status(_("reading narrowspec from '%s'\n") % filepath)
try:
Pulkit Goyal
narrow: use util.readfile() and improve error message using --narrowspec...
r39501 fdata = util.readfile(filepath)
except IOError as inst:
raise error.Abort(_("cannot read narrowspecs from '%s': %s") %
(filepath, encoding.strtolocal(inst.strerror)))
Pulkit Goyal
narrow: add a --narrowspec flag to clone command...
r39283
Pulkit Goyal
narrow: use util.readfile() and improve error message using --narrowspec...
r39501 includes, excludes, profiles = sparse.parseconfig(ui, fdata, 'narrow')
Pulkit Goyal
narrow: add a --narrowspec flag to clone command...
r39283 if profiles:
raise error.Abort(_("cannot specify other files using '%include' in"
" narrowspec"))
Gregory Szorc
narrow: validate spec files are well-formed during clone (BC)...
r39577 narrowspec.validatepatterns(includes)
narrowspec.validatepatterns(excludes)
Pulkit Goyal
narrow: add a --narrowspec flag to clone command...
r39283 # narrowspec is passed so we should assume that user wants narrow clone
Gregory Szorc
narrow: set opts['narrow'] instead of local variable...
r39582 opts['narrow'] = True
Pulkit Goyal
narrow: add a --narrowspec flag to clone command...
r39283 opts['include'].extend(includes)
opts['exclude'].extend(excludes)
Gregory Szorc
narrow: set opts['narrow'] instead of local variable...
r39582 if opts['narrow']:
Augie Fackler
narrow: import experimental extension from narrowhg revision cb51d673e9c5...
r36096 def pullbundle2extraprepare_widen(orig, pullop, kwargs):
orig(pullop, kwargs)
if opts.get('depth'):
kwargs['depth'] = opts['depth']
wrappedextraprepare = extensions.wrappedfunction(exchange,
'_pullbundle2extraprepare', pullbundle2extraprepare_widen)
Gregory Szorc
narrow: don't wrap exchange.pull() during clone...
r39590 with wrappedextraprepare:
Augie Fackler
narrowcommands: use pycompat.{bytes,str}kwargs...
r36172 return orig(ui, repo, *args, **pycompat.strkwargs(opts))
Augie Fackler
narrow: import experimental extension from narrowhg revision cb51d673e9c5...
r36096
def pullnarrowcmd(orig, ui, repo, *args, **opts):
"""Wraps pull command to allow modifying narrow spec."""
wrappedextraprepare = util.nullcontextmanager()
Martin von Zweigbergk
narrow: move requirement constant from changegroup to repository...
r38871 if repository.NARROW_REQUIREMENT in repo.requirements:
Augie Fackler
narrow: import experimental extension from narrowhg revision cb51d673e9c5...
r36096
def pullbundle2extraprepare_widen(orig, pullop, kwargs):
orig(pullop, kwargs)
Pulkit Goyal
py3: fix more keyword arguments handling...
r36474 if opts.get(r'depth'):
kwargs['depth'] = opts[r'depth']
Augie Fackler
narrow: import experimental extension from narrowhg revision cb51d673e9c5...
r36096 wrappedextraprepare = extensions.wrappedfunction(exchange,
'_pullbundle2extraprepare', pullbundle2extraprepare_widen)
with wrappedextraprepare:
return orig(ui, repo, *args, **opts)
def archivenarrowcmd(orig, ui, repo, *args, **opts):
"""Wraps archive command to narrow the default includes."""
Martin von Zweigbergk
narrow: move requirement constant from changegroup to repository...
r38871 if repository.NARROW_REQUIREMENT in repo.requirements:
Augie Fackler
narrow: import experimental extension from narrowhg revision cb51d673e9c5...
r36096 repo_includes, repo_excludes = repo.narrowpats
Augie Fackler
narrowcommands: add some missing strkwargs calls for py3...
r36370 includes = set(opts.get(r'include', []))
excludes = set(opts.get(r'exclude', []))
Augie Fackler
narrow: make restrictpatterns a little more idiomatic...
r36117 includes, excludes, unused_invalid = narrowspec.restrictpatterns(
Augie Fackler
narrow: import experimental extension from narrowhg revision cb51d673e9c5...
r36096 includes, excludes, repo_includes, repo_excludes)
if includes:
Augie Fackler
narrowcommands: add some missing strkwargs calls for py3...
r36370 opts[r'include'] = includes
Augie Fackler
narrow: import experimental extension from narrowhg revision cb51d673e9c5...
r36096 if excludes:
Augie Fackler
narrowcommands: add some missing strkwargs calls for py3...
r36370 opts[r'exclude'] = excludes
Augie Fackler
narrow: import experimental extension from narrowhg revision cb51d673e9c5...
r36096 return orig(ui, repo, *args, **opts)
def pullbundle2extraprepare(orig, pullop, kwargs):
repo = pullop.repo
Martin von Zweigbergk
narrow: move requirement constant from changegroup to repository...
r38871 if repository.NARROW_REQUIREMENT not in repo.requirements:
Augie Fackler
narrow: import experimental extension from narrowhg revision cb51d673e9c5...
r36096 return orig(pullop, kwargs)
Pulkit Goyal
wireprotoserver: move narrow capabilities to wireprototypes.py...
r40110 if wireprototypes.NARROWCAP not in pullop.remote.capabilities():
Pulkit Goyal
narrow: check for servers' narrow support before doing anything (BC)...
r40000 raise error.Abort(_("server does not support narrow clones"))
Augie Fackler
narrow: import experimental extension from narrowhg revision cb51d673e9c5...
r36096 orig(pullop, kwargs)
kwargs['narrow'] = True
include, exclude = repo.narrowpats
kwargs['oldincludepats'] = include
kwargs['oldexcludepats'] = exclude
Pulkit Goyal
narrow: only send includepats and excludepats if they are not empty...
r40528 if include:
kwargs['includepats'] = include
if exclude:
kwargs['excludepats'] = exclude
Pulkit Goyal
narrow: build the known set of nodes only when ellipses is enabled...
r39560 # calculate known nodes only in ellipses cases because in non-ellipses cases
# we have all the nodes
Pulkit Goyal
wireprotoserver: move narrow capabilities to wireprototypes.py...
r40110 if wireprototypes.ELLIPSESCAP in pullop.remote.capabilities():
Pulkit Goyal
narrow: build the known set of nodes only when ellipses is enabled...
r39560 kwargs['known'] = [node.hex(ctx.node()) for ctx in
repo.set('::%ln', pullop.common)
if ctx.node() != node.nullid]
if not kwargs['known']:
# Mercurial serializes an empty list as '' and deserializes it as
# [''], so delete it instead to avoid handling the empty string on
# the server.
del kwargs['known']
Augie Fackler
narrow: import experimental extension from narrowhg revision cb51d673e9c5...
r36096
extensions.wrapfunction(exchange,'_pullbundle2extraprepare',
pullbundle2extraprepare)
def _narrow(ui, repo, remote, commoninc, oldincludes, oldexcludes,
newincludes, newexcludes, force):
oldmatch = narrowspec.match(repo.root, oldincludes, oldexcludes)
newmatch = narrowspec.match(repo.root, newincludes, newexcludes)
# This is essentially doing "hg outgoing" to find all local-only
# commits. We will then check that the local-only commits don't
# have any changes to files that will be untracked.
unfi = repo.unfiltered()
outgoing = discovery.findcommonoutgoing(unfi, remote,
commoninc=commoninc)
ui.status(_('looking for local changes to affected paths\n'))
localnodes = []
for n in itertools.chain(outgoing.missing, outgoing.excluded):
if any(oldmatch(f) and not newmatch(f) for f in unfi[n].files()):
localnodes.append(n)
revstostrip = unfi.revs('descendants(%ln)', localnodes)
hiddenrevs = repoview.filterrevs(repo, 'visible')
visibletostrip = list(repo.changelog.node(r)
for r in (revstostrip - hiddenrevs))
if visibletostrip:
ui.status(_('The following changeset(s) or their ancestors have '
'local changes not on the remote:\n'))
maxnodes = 10
if ui.verbose or len(visibletostrip) <= maxnodes:
for n in visibletostrip:
ui.status('%s\n' % node.short(n))
else:
for n in visibletostrip[:maxnodes]:
ui.status('%s\n' % node.short(n))
ui.status(_('...and %d more, use --verbose to list all\n') %
(len(visibletostrip) - maxnodes))
if not force:
raise error.Abort(_('local changes found'),
hint=_('use --force-delete-local-changes to '
'ignore'))
Kyle Lippincott
procutil: correct spelling of uninterruptable -> uninterruptible...
r41106 with ui.uninterruptible():
Augie Fackler
narrow: mark the critical chunks of narrowing/widening as unsafe...
r38547 if revstostrip:
tostrip = [unfi.changelog.node(r) for r in revstostrip]
if repo['.'].node() in tostrip:
# stripping working copy, so move to a different commit first
urev = max(repo.revs('(::%n) - %ln + null',
repo['.'].node(), visibletostrip))
hg.clean(repo, urev)
Martin von Zweigbergk
narrow: don't resurrect old commits when narrowing (don't strip obsmarkers)...
r40864 overrides = {('devel', 'strip-obsmarkers'): False}
with ui.configoverride(overrides, 'narrow'):
repair.strip(ui, unfi, tostrip, topic='narrow')
Augie Fackler
narrow: import experimental extension from narrowhg revision cb51d673e9c5...
r36096
Augie Fackler
narrow: mark the critical chunks of narrowing/widening as unsafe...
r38547 todelete = []
for f, f2, size in repo.store.datafiles():
if f.startswith('data/'):
file = f[5:-2]
if not newmatch(file):
todelete.append(f)
elif f.startswith('meta/'):
dir = f[5:-13]
dirs = ['.'] + sorted(util.dirs({dir})) + [dir]
include = True
for d in dirs:
visit = newmatch.visitdir(d)
if not visit:
include = False
break
if visit == 'all':
break
if not include:
todelete.append(f)
Augie Fackler
narrow: import experimental extension from narrowhg revision cb51d673e9c5...
r36096
Augie Fackler
narrow: mark the critical chunks of narrowing/widening as unsafe...
r38547 repo.destroying()
Augie Fackler
narrow: import experimental extension from narrowhg revision cb51d673e9c5...
r36096
Martin von Zweigbergk
narrow: reuse narrowspec.updateworkingcopy() when narrowing...
r41274 with repo.transaction('narrowing'):
Martin von Zweigbergk
narrow: when narrowing, write new narrowspec before removing revlogs...
r41057 # Update narrowspec before removing revlogs, so repo won't be
# corrupt in case of crash
repo.setnarrowpats(newincludes, newexcludes)
Augie Fackler
narrow: mark the critical chunks of narrowing/widening as unsafe...
r38547 for f in todelete:
ui.status(_('deleting %s\n') % f)
util.unlinkpath(repo.svfs.join(f))
repo.store.markremoved(f)
Augie Fackler
narrow: import experimental extension from narrowhg revision cb51d673e9c5...
r36096
Martin von Zweigbergk
narrow: reuse narrowspec.updateworkingcopy() when narrowing...
r41274 narrowspec.updateworkingcopy(repo, assumeclean=True)
narrowspec.copytoworkingcopy(repo)
Augie Fackler
narrow: import experimental extension from narrowhg revision cb51d673e9c5...
r36096
Augie Fackler
narrow: mark the critical chunks of narrowing/widening as unsafe...
r38547 repo.destroyed()
Augie Fackler
narrow: import experimental extension from narrowhg revision cb51d673e9c5...
r36096
Pulkit Goyal
narrow: pass old includes and excludes to _widen()...
r40001 def _widen(ui, repo, remote, commoninc, oldincludes, oldexcludes,
newincludes, newexcludes):
Pulkit Goyal
narrow: don't do the dirstate dance if ellipses is not enabled...
r39999 # for now we assume that if a server has ellipses enabled, we will be
# exchanging ellipses nodes. In future we should add ellipses as a client
# side requirement (maybe) to distinguish a client is shallow or not and
# then send that information to server whether we want ellipses or not.
# Theoretically a non-ellipses repo should be able to use narrow
# functionality from an ellipses enabled server
Pulkit Goyal
wireprotoserver: move narrow capabilities to wireprototypes.py...
r40110 ellipsesremote = wireprototypes.ELLIPSESCAP in remote.capabilities()
Pulkit Goyal
narrow: don't do the dirstate dance if ellipses is not enabled...
r39999
Augie Fackler
narrow: import experimental extension from narrowhg revision cb51d673e9c5...
r36096 def pullbundle2extraprepare_widen(orig, pullop, kwargs):
orig(pullop, kwargs)
# The old{in,ex}cludepats have already been set by orig()
kwargs['includepats'] = newincludes
kwargs['excludepats'] = newexcludes
wrappedextraprepare = extensions.wrappedfunction(exchange,
'_pullbundle2extraprepare', pullbundle2extraprepare_widen)
# define a function that narrowbundle2 can call after creating the
# backup bundle, but before applying the bundle from the server
def setnewnarrowpats():
repo.setnarrowpats(newincludes, newexcludes)
repo.setnewnarrowpats = setnewnarrowpats
Pulkit Goyal
narrow: don't send the changelog information when widening without ellipses...
r39709 # silence the devel-warning of applying an empty changegroup
overrides = {('devel', 'all-warnings'): False}
Augie Fackler
narrow: import experimental extension from narrowhg revision cb51d673e9c5...
r36096
Kyle Lippincott
procutil: correct spelling of uninterruptable -> uninterruptible...
r41106 with ui.uninterruptible():
Augie Fackler
narrow: mark the critical chunks of narrowing/widening as unsafe...
r38547 common = commoninc[0]
Pulkit Goyal
narrow: don't do the dirstate dance if ellipses is not enabled...
r39999 if ellipsesremote:
ds = repo.dirstate
p1, p2 = ds.p1(), ds.p2()
with ds.parentchange():
ds.setparents(node.nullid, node.nullid)
Augie Fackler
cleanup: prefer nested context managers to \-continuations...
r41926 with wrappedextraprepare:
with repo.ui.configoverride(overrides, 'widen'):
exchange.pull(repo, remote, heads=common)
Pulkit Goyal
narrow: don't do the dirstate dance if ellipses is not enabled...
r39999 with ds.parentchange():
ds.setparents(p1, p2)
else:
Pulkit Goyal
narrow: the first version of narrow_widen wireprotocol command...
r40106 with remote.commandexecutor() as e:
bundle = e.callcommand('narrow_widen', {
'oldincludes': oldincludes,
'oldexcludes': oldexcludes,
'newincludes': newincludes,
'newexcludes': newexcludes,
'cgversion': '03',
'commonheads': common,
'known': [],
'ellipses': False,
}).result()
Augie Fackler
cleanup: prefer nested context managers to \-continuations...
r41926 with repo.transaction('widening') as tr:
with repo.ui.configoverride(overrides, 'widen'):
tgetter = lambda: tr
bundle2.processbundle(repo, bundle,
transactiongetter=tgetter)
Augie Fackler
narrow: import experimental extension from narrowhg revision cb51d673e9c5...
r36096
Martin von Zweigbergk
narrow: reuse narrowspec.updateworkingcopy() when widening...
r41273 with repo.transaction('widening'):
repo.setnewnarrowpats()
narrowspec.updateworkingcopy(repo)
narrowspec.copytoworkingcopy(repo)
Augie Fackler
narrow: import experimental extension from narrowhg revision cb51d673e9c5...
r36096
# TODO(rdamazio): Make new matcher format and update description
@command('tracked',
[('', 'addinclude', [], _('new paths to include')),
('', 'removeinclude', [], _('old paths to no longer include')),
('', 'addexclude', [], _('new paths to exclude')),
Pulkit Goyal
narrow: add '--import-rules' flag to tracked command...
r39471 ('', 'import-rules', '', _('import narrowspecs from a file')),
Augie Fackler
narrow: import experimental extension from narrowhg revision cb51d673e9c5...
r36096 ('', 'removeexclude', [], _('old paths to no longer exclude')),
('', 'clear', False, _('whether to replace the existing narrowspec')),
('', 'force-delete-local-changes', False,
_('forces deletion of local changes when narrowing')),
Martin von Zweigbergk
narrow: detect if narrowspec was changed in a different share...
r41072 ('', 'update-working-copy', False,
_('update working copy when the store has changed')),
Augie Fackler
narrow: import experimental extension from narrowhg revision cb51d673e9c5...
r36096 ] + commands.remoteopts,
_('[OPTIONS]... [REMOTE]'),
inferrepo=True)
def trackedcmd(ui, repo, remotepath=None, *pats, **opts):
"""show or change the current narrowspec
With no argument, shows the current narrowspec entries, one per line. Each
line will be prefixed with 'I' or 'X' for included or excluded patterns,
respectively.
The narrowspec is comprised of expressions to match remote files and/or
directories that should be pulled into your client.
The narrowspec has *include* and *exclude* expressions, with excludes always
trumping includes: that is, if a file matches an exclude expression, it will
be excluded even if it also matches an include expression.
Excluding files that were never included has no effect.
Each included or excluded entry is in the format described by
'hg help patterns'.
The options allow you to add or remove included and excluded expressions.
If --clear is specified, then all previous includes and excludes are DROPPED
and replaced by the new ones specified to --addinclude and --addexclude.
If --clear is specified without any further options, the narrowspec will be
empty and will not match any files.
Pulkit Goyal
tracked: add documentation about `--import-rules` flag...
r42146
--import-rules accepts a path to a file containing rules, allowing you to
add --addinclude, --addexclude rules in bulk. Like the other include and
exclude switches, the changes are applied immediately.
Augie Fackler
narrow: import experimental extension from narrowhg revision cb51d673e9c5...
r36096 """
Augie Fackler
narrowcommands: more byteskwargs cleanup...
r36184 opts = pycompat.byteskwargs(opts)
Martin von Zweigbergk
narrow: move requirement constant from changegroup to repository...
r38871 if repository.NARROW_REQUIREMENT not in repo.requirements:
Pulkit Goyal
narrow: fix command name in error messsage...
r41872 raise error.Abort(_('the tracked command is only supported on '
Martin von Zweigbergk
narrow: replace "ui.warn(); return 1" by "raise error.Abort()"...
r41056 'respositories cloned with --narrow'))
Augie Fackler
narrow: import experimental extension from narrowhg revision cb51d673e9c5...
r36096
# Before supporting, decide whether it "hg tracked --clear" should mean
# tracking no paths or all paths.
if opts['clear']:
Martin von Zweigbergk
narrow: replace "ui.warn(); return 1" by "raise error.Abort()"...
r41056 raise error.Abort(_('the --clear option is not yet supported'))
Augie Fackler
narrow: import experimental extension from narrowhg revision cb51d673e9c5...
r36096
Pulkit Goyal
narrow: add '--import-rules' flag to tracked command...
r39471 # import rules from a file
newrules = opts.get('import_rules')
if newrules:
try:
Matt Harbison
py3: rename pycompat.getcwd() to encoding.getcwd() (API)...
r39843 filepath = os.path.join(encoding.getcwd(), newrules)
Pulkit Goyal
narrow: add '--import-rules' flag to tracked command...
r39471 fdata = util.readfile(filepath)
except IOError as inst:
raise error.Abort(_("cannot read narrowspecs from '%s': %s") %
(filepath, encoding.strtolocal(inst.strerror)))
includepats, excludepats, profiles = sparse.parseconfig(ui, fdata,
'narrow')
if profiles:
raise error.Abort(_("including other spec files using '%include' "
"is not supported in narrowspec"))
opts['addinclude'].extend(includepats)
opts['addexclude'].extend(excludepats)
Augie Fackler
narrow: import experimental extension from narrowhg revision cb51d673e9c5...
r36096 addedincludes = narrowspec.parsepatterns(opts['addinclude'])
removedincludes = narrowspec.parsepatterns(opts['removeinclude'])
addedexcludes = narrowspec.parsepatterns(opts['addexclude'])
removedexcludes = narrowspec.parsepatterns(opts['removeexclude'])
Pulkit Goyal
narrow: rework logic to check whether we need to widen and narrow...
r40462
Martin von Zweigbergk
narrow: detect if narrowspec was changed in a different share...
r41072 update_working_copy = opts['update_working_copy']
Pulkit Goyal
narrow: rework logic to check whether we need to widen and narrow...
r40462 only_show = not (addedincludes or removedincludes or addedexcludes or
Martin von Zweigbergk
narrow: detect if narrowspec was changed in a different share...
r41072 removedexcludes or newrules or update_working_copy)
Pulkit Goyal
narrow: rework logic to check whether we need to widen and narrow...
r40462
oldincludes, oldexcludes = repo.narrowpats
# filter the user passed additions and deletions into actual additions and
# deletions of excludes and includes
Martin von Zweigbergk
narrow: replace filtering in list comprehension by set operations...
r40465 addedincludes -= oldincludes
removedincludes &= oldincludes
addedexcludes -= oldexcludes
removedexcludes &= oldexcludes
Pulkit Goyal
narrow: rework logic to check whether we need to widen and narrow...
r40462
Augie Fackler
narrow: import experimental extension from narrowhg revision cb51d673e9c5...
r36096 widening = addedincludes or removedexcludes
narrowing = removedincludes or addedexcludes
# Only print the current narrowspec.
if only_show:
ui.pager('tracked')
fm = ui.formatter('narrow', opts)
Pulkit Goyal
narrowcommands: remove an unrequired `repo.narrowpats` call...
r40802 for i in sorted(oldincludes):
Augie Fackler
narrow: import experimental extension from narrowhg revision cb51d673e9c5...
r36096 fm.startitem()
fm.write('status', '%s ', 'I', label='narrow.included')
fm.write('pat', '%s\n', i, label='narrow.included')
Pulkit Goyal
narrowcommands: remove an unrequired `repo.narrowpats` call...
r40802 for i in sorted(oldexcludes):
Augie Fackler
narrow: import experimental extension from narrowhg revision cb51d673e9c5...
r36096 fm.startitem()
fm.write('status', '%s ', 'X', label='narrow.excluded')
fm.write('pat', '%s\n', i, label='narrow.excluded')
fm.end()
return 0
Martin von Zweigbergk
narrow: detect if narrowspec was changed in a different share...
r41072 if update_working_copy:
Martin von Zweigbergk
narrow: copy store narrowspec to working copy immediately...
r41265 with repo.wlock(), repo.lock(), repo.transaction('narrow-wc'):
Martin von Zweigbergk
narrow: drop explicit dirstate write...
r41212 narrowspec.updateworkingcopy(repo)
Martin von Zweigbergk
narrow: copy store narrowspec to working copy immediately...
r41265 narrowspec.copytoworkingcopy(repo)
Martin von Zweigbergk
narrow: detect if narrowspec was changed in a different share...
r41072 return 0
Pulkit Goyal
narrow: rework logic to check whether we need to widen and narrow...
r40462 if not widening and not narrowing:
ui.status(_("nothing to widen or narrow\n"))
return 0
Augie Fackler
narrow: import experimental extension from narrowhg revision cb51d673e9c5...
r36096 with repo.wlock(), repo.lock():
cmdutil.bailifchanged(repo)
# Find the revisions we have in common with the remote. These will
# be used for finding local-only changes for narrowing. They will
# also define the set of revisions to update for widening.
remotepath = ui.expandpath(remotepath or 'default')
url, branches = hg.parseurl(remotepath)
ui.status(_('comparing with %s\n') % util.hidepassword(url))
remote = hg.peer(repo, opts, url)
Pulkit Goyal
narrow: check for servers' narrow support before doing anything (BC)...
r40000
# check narrow support before doing anything if widening needs to be
# performed. In future we should also abort if client is ellipses and
# server does not support ellipses
Pulkit Goyal
wireprotoserver: move narrow capabilities to wireprototypes.py...
r40110 if widening and wireprototypes.NARROWCAP not in remote.capabilities():
Pulkit Goyal
narrow: check for servers' narrow support before doing anything (BC)...
r40000 raise error.Abort(_("server does not support narrow clones"))
Augie Fackler
narrow: import experimental extension from narrowhg revision cb51d673e9c5...
r36096 commoninc = discovery.findcommonincoming(repo, remote)
if narrowing:
newincludes = oldincludes - removedincludes
newexcludes = oldexcludes | addedexcludes
_narrow(ui, repo, remote, commoninc, oldincludes, oldexcludes,
newincludes, newexcludes,
opts['force_delete_local_changes'])
# _narrow() updated the narrowspec and _widen() below needs to
# use the updated values as its base (otherwise removed includes
# and addedexcludes will be lost in the resulting narrowspec)
oldincludes = newincludes
oldexcludes = newexcludes
if widening:
newincludes = oldincludes | addedincludes
newexcludes = oldexcludes - removedexcludes
Pulkit Goyal
narrow: pass old includes and excludes to _widen()...
r40001 _widen(ui, repo, remote, commoninc, oldincludes, oldexcludes,
newincludes, newexcludes)
Augie Fackler
narrow: import experimental extension from narrowhg revision cb51d673e9c5...
r36096
return 0