hgext/sparse.py
author Gregory Szorc <gregory.szorc@gmail.com>
Fri, 07 Jul 2017 11:51:10 -0700
changeset 33353 160efb559f67
parent 33324 33d0859c37bd
child 33354 4695f1829045
permissions -rw-r--r--
sparse: move post commit actions into core Instead of wrapping committablectx.markcommitted(), we inline the call into workingctx.markcommitted(). Per smf's review, workingctx is the proper location for this code, as committablectx is the shared base class for it and memctx. Since this code touches the working directory, it belongs in workingctx.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
33289
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
     1
# sparse.py - allow sparse checkouts of the working directory
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
     2
#
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
     3
# Copyright 2014 Facebook, Inc.
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
     4
#
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
     5
# This software may be used and distributed according to the terms of the
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
     6
# GNU General Public License version 2 or any later version.
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
     7
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
     8
"""allow sparse checkouts of the working directory (EXPERIMENTAL)
33290
cd1c275c9482 sparse: expand module docstring
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33289
diff changeset
     9
cd1c275c9482 sparse: expand module docstring
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33289
diff changeset
    10
(This extension is not yet protected by backwards compatibility
cd1c275c9482 sparse: expand module docstring
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33289
diff changeset
    11
guarantees. Any aspect may break in future releases until this
cd1c275c9482 sparse: expand module docstring
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33289
diff changeset
    12
notice is removed.)
cd1c275c9482 sparse: expand module docstring
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33289
diff changeset
    13
cd1c275c9482 sparse: expand module docstring
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33289
diff changeset
    14
This extension allows the working directory to only consist of a
cd1c275c9482 sparse: expand module docstring
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33289
diff changeset
    15
subset of files for the revision. This allows specific files or
cd1c275c9482 sparse: expand module docstring
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33289
diff changeset
    16
directories to be explicitly included or excluded. Many repository
cd1c275c9482 sparse: expand module docstring
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33289
diff changeset
    17
operations have performance proportional to the number of files in
cd1c275c9482 sparse: expand module docstring
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33289
diff changeset
    18
the working directory. So only realizing a subset of files in the
cd1c275c9482 sparse: expand module docstring
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33289
diff changeset
    19
working directory can improve performance.
33294
a5921ad2eb99 sparse: document config file format
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33293
diff changeset
    20
a5921ad2eb99 sparse: document config file format
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33293
diff changeset
    21
Sparse Config Files
a5921ad2eb99 sparse: document config file format
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33293
diff changeset
    22
-------------------
a5921ad2eb99 sparse: document config file format
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33293
diff changeset
    23
a5921ad2eb99 sparse: document config file format
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33293
diff changeset
    24
The set of files that are part of a sparse checkout are defined by
a5921ad2eb99 sparse: document config file format
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33293
diff changeset
    25
a sparse config file. The file defines 3 things: includes (files to
a5921ad2eb99 sparse: document config file format
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33293
diff changeset
    26
include in the sparse checkout), excludes (files to exclude from the
a5921ad2eb99 sparse: document config file format
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33293
diff changeset
    27
sparse checkout), and profiles (links to other config files).
a5921ad2eb99 sparse: document config file format
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33293
diff changeset
    28
a5921ad2eb99 sparse: document config file format
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33293
diff changeset
    29
The file format is newline delimited. Empty lines and lines beginning
a5921ad2eb99 sparse: document config file format
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33293
diff changeset
    30
with ``#`` are ignored.
a5921ad2eb99 sparse: document config file format
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33293
diff changeset
    31
a5921ad2eb99 sparse: document config file format
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33293
diff changeset
    32
Lines beginning with ``%include `` denote another sparse config file
a5921ad2eb99 sparse: document config file format
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33293
diff changeset
    33
to include. e.g. ``%include tests.sparse``. The filename is relative
a5921ad2eb99 sparse: document config file format
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33293
diff changeset
    34
to the repository root.
a5921ad2eb99 sparse: document config file format
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33293
diff changeset
    35
a5921ad2eb99 sparse: document config file format
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33293
diff changeset
    36
The special lines ``[include]`` and ``[exclude]`` denote the section
a5921ad2eb99 sparse: document config file format
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33293
diff changeset
    37
for includes and excludes that follow, respectively. It is illegal to
a5921ad2eb99 sparse: document config file format
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33293
diff changeset
    38
have ``[include]`` after ``[exclude]``. If no sections are defined,
a5921ad2eb99 sparse: document config file format
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33293
diff changeset
    39
entries are assumed to be in the ``[include]`` section.
a5921ad2eb99 sparse: document config file format
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33293
diff changeset
    40
a5921ad2eb99 sparse: document config file format
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33293
diff changeset
    41
Non-special lines resemble file patterns to be added to either includes
a5921ad2eb99 sparse: document config file format
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33293
diff changeset
    42
or excludes. The syntax of these lines is documented by :hg:`help patterns`.
a5921ad2eb99 sparse: document config file format
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33293
diff changeset
    43
Patterns are interpreted as ``glob:`` by default and match against the
a5921ad2eb99 sparse: document config file format
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33293
diff changeset
    44
root of the repository.
a5921ad2eb99 sparse: document config file format
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33293
diff changeset
    45
a5921ad2eb99 sparse: document config file format
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33293
diff changeset
    46
Exclusion patterns take precedence over inclusion patterns. So even
a5921ad2eb99 sparse: document config file format
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33293
diff changeset
    47
if a file is explicitly included, an ``[exclude]`` entry can remove it.
a5921ad2eb99 sparse: document config file format
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33293
diff changeset
    48
a5921ad2eb99 sparse: document config file format
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33293
diff changeset
    49
For example, say you have a repository with 3 directories, ``frontend/``,
a5921ad2eb99 sparse: document config file format
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33293
diff changeset
    50
``backend/``, and ``tools/``. ``frontend/`` and ``backend/`` correspond
a5921ad2eb99 sparse: document config file format
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33293
diff changeset
    51
to different projects and it is uncommon for someone working on one
a5921ad2eb99 sparse: document config file format
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33293
diff changeset
    52
to need the files for the other. But ``tools/`` contains files shared
a5921ad2eb99 sparse: document config file format
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33293
diff changeset
    53
between both projects. Your sparse config files may resemble::
a5921ad2eb99 sparse: document config file format
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33293
diff changeset
    54
a5921ad2eb99 sparse: document config file format
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33293
diff changeset
    55
  # frontend.sparse
a5921ad2eb99 sparse: document config file format
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33293
diff changeset
    56
  frontend/**
a5921ad2eb99 sparse: document config file format
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33293
diff changeset
    57
  tools/**
a5921ad2eb99 sparse: document config file format
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33293
diff changeset
    58
a5921ad2eb99 sparse: document config file format
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33293
diff changeset
    59
  # backend.sparse
a5921ad2eb99 sparse: document config file format
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33293
diff changeset
    60
  backend/**
a5921ad2eb99 sparse: document config file format
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33293
diff changeset
    61
  tools/**
a5921ad2eb99 sparse: document config file format
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33293
diff changeset
    62
a5921ad2eb99 sparse: document config file format
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33293
diff changeset
    63
Say the backend grows in size. Or there's a directory with thousands
a5921ad2eb99 sparse: document config file format
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33293
diff changeset
    64
of files you wish to exclude. You can modify the profile to exclude
a5921ad2eb99 sparse: document config file format
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33293
diff changeset
    65
certain files::
a5921ad2eb99 sparse: document config file format
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33293
diff changeset
    66
a5921ad2eb99 sparse: document config file format
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33293
diff changeset
    67
  [include]
a5921ad2eb99 sparse: document config file format
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33293
diff changeset
    68
  backend/**
a5921ad2eb99 sparse: document config file format
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33293
diff changeset
    69
  tools/**
a5921ad2eb99 sparse: document config file format
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33293
diff changeset
    70
a5921ad2eb99 sparse: document config file format
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33293
diff changeset
    71
  [exclude]
a5921ad2eb99 sparse: document config file format
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33293
diff changeset
    72
  tools/tests/**
33289
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    73
"""
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    74
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    75
from __future__ import absolute_import
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    76
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    77
from mercurial.i18n import _
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    78
from mercurial.node import nullid
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    79
from mercurial import (
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    80
    cmdutil,
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    81
    commands,
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    82
    dirstate,
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    83
    error,
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    84
    extensions,
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    85
    hg,
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    86
    localrepo,
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    87
    match as matchmod,
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    88
    registrar,
33297
ba5d89774db6 sparse: move config parsing into core
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33296
diff changeset
    89
    sparse,
33289
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    90
    util,
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    91
)
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    92
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    93
# Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    94
# extensions which SHIP WITH MERCURIAL. Non-mainline extensions should
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    95
# be specifying the version(s) of Mercurial they are tested with, or
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    96
# leave the attribute unspecified.
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    97
testedwith = 'ships-with-hg-core'
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    98
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
    99
cmdtable = {}
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   100
command = registrar.command(cmdtable)
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   101
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   102
def extsetup(ui):
33299
41448fc51510 sparse: variable to track if sparse is enabled
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33298
diff changeset
   103
    sparse.enabled = True
41448fc51510 sparse: variable to track if sparse is enabled
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33298
diff changeset
   104
33289
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   105
    _setupclone(ui)
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   106
    _setuplog(ui)
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   107
    _setupadd(ui)
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   108
    _setupdirstate(ui)
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   109
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   110
def reposetup(ui, repo):
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   111
    if not util.safehasattr(repo, 'dirstate'):
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   112
        return
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   113
33321
d09e948dc303 sparse: move pruning of temporary includes into core
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33320
diff changeset
   114
    if 'dirstate' in repo._filecache:
d09e948dc303 sparse: move pruning of temporary includes into core
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33320
diff changeset
   115
        repo.dirstate.repo = repo
33289
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   116
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   117
def replacefilecache(cls, propname, replacement):
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   118
    """Replace a filecache property with a new class. This allows changing the
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   119
    cache invalidation condition."""
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   120
    origcls = cls
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   121
    assert callable(replacement)
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   122
    while cls is not object:
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   123
        if propname in cls.__dict__:
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   124
            orig = cls.__dict__[propname]
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   125
            setattr(cls, propname, replacement(orig))
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   126
            break
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   127
        cls = cls.__bases__[0]
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   128
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   129
    if cls is object:
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   130
        raise AttributeError(_("type '%s' has no property '%s'") % (origcls,
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   131
                             propname))
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   132
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   133
def _setuplog(ui):
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   134
    entry = commands.table['^log|history']
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   135
    entry[1].append(('', 'sparse', None,
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   136
        "limit to changesets affecting the sparse checkout"))
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   137
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   138
    def _logrevs(orig, repo, opts):
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   139
        revs = orig(repo, opts)
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   140
        if opts.get('sparse'):
33320
153456f02426 sparse: move function for resolving sparse matcher into core
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33319
diff changeset
   141
            sparsematch = sparse.matcher(repo)
33289
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   142
            def ctxmatch(rev):
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   143
                ctx = repo[rev]
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   144
                return any(f for f in ctx.files() if sparsematch(f))
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   145
            revs = revs.filter(ctxmatch)
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   146
        return revs
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   147
    extensions.wrapfunction(cmdutil, '_logrevs', _logrevs)
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   148
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   149
def _clonesparsecmd(orig, ui, repo, *args, **opts):
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   150
    include_pat = opts.get('include')
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   151
    exclude_pat = opts.get('exclude')
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   152
    enableprofile_pat = opts.get('enable_profile')
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   153
    include = exclude = enableprofile = False
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   154
    if include_pat:
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   155
        pat = include_pat
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   156
        include = True
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   157
    if exclude_pat:
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   158
        pat = exclude_pat
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   159
        exclude = True
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   160
    if enableprofile_pat:
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   161
        pat = enableprofile_pat
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   162
        enableprofile = True
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   163
    if sum([include, exclude, enableprofile]) > 1:
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   164
        raise error.Abort(_("too many flags specified."))
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   165
    if include or exclude or enableprofile:
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   166
        def clonesparse(orig, self, node, overwrite, *args, **kwargs):
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   167
            _config(self.ui, self.unfiltered(), pat, {}, include=include,
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   168
                    exclude=exclude, enableprofile=enableprofile)
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   169
            return orig(self, node, overwrite, *args, **kwargs)
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   170
        extensions.wrapfunction(hg, 'updaterepo', clonesparse)
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   171
    return orig(ui, repo, *args, **opts)
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   172
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   173
def _setupclone(ui):
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   174
    entry = commands.table['^clone']
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   175
    entry[1].append(('', 'enable-profile', [],
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   176
                    'enable a sparse profile'))
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   177
    entry[1].append(('', 'include', [],
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   178
                    'include sparse pattern'))
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   179
    entry[1].append(('', 'exclude', [],
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   180
                    'exclude sparse pattern'))
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   181
    extensions.wrapcommand(commands.table, 'clone', _clonesparsecmd)
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   182
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   183
def _setupadd(ui):
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   184
    entry = commands.table['^add']
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   185
    entry[1].append(('s', 'sparse', None,
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   186
                    'also include directories of added files in sparse config'))
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   187
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   188
    def _add(orig, ui, repo, *pats, **opts):
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   189
        if opts.get('sparse'):
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   190
            dirs = set()
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   191
            for pat in pats:
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   192
                dirname, basename = util.split(pat)
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   193
                dirs.add(dirname)
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   194
            _config(ui, repo, list(dirs), opts, include=True)
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   195
        return orig(ui, repo, *pats, **opts)
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   196
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   197
    extensions.wrapcommand(commands.table, 'add', _add)
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   198
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   199
def _setupdirstate(ui):
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   200
    """Modify the dirstate to prevent stat'ing excluded files,
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   201
    and to prevent modifications to files outside the checkout.
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   202
    """
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   203
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   204
    def _dirstate(orig, repo):
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   205
        dirstate = orig(repo)
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   206
        dirstate.repo = repo
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   207
        return dirstate
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   208
    extensions.wrapfunction(
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   209
        localrepo.localrepository.dirstate, 'func', _dirstate)
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   210
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   211
    # The atrocity below is needed to wrap dirstate._ignore. It is a cached
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   212
    # property, which means normal function wrapping doesn't work.
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   213
    class ignorewrapper(object):
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   214
        def __init__(self, orig):
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   215
            self.orig = orig
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   216
            self.origignore = None
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   217
            self.func = None
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   218
            self.sparsematch = None
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   219
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   220
        def __get__(self, obj, type=None):
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   221
            repo = obj.repo
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   222
            origignore = self.orig.__get__(obj)
33320
153456f02426 sparse: move function for resolving sparse matcher into core
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33319
diff changeset
   223
153456f02426 sparse: move function for resolving sparse matcher into core
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33319
diff changeset
   224
            sparsematch = sparse.matcher(repo)
153456f02426 sparse: move function for resolving sparse matcher into core
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33319
diff changeset
   225
            if sparsematch.always():
33289
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   226
                return origignore
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   227
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   228
            if self.sparsematch != sparsematch or self.origignore != origignore:
33319
3c84591e7321 match: move matchers from sparse into core
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33317
diff changeset
   229
                self.func = matchmod.unionmatcher([
3c84591e7321 match: move matchers from sparse into core
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33317
diff changeset
   230
                    origignore, matchmod.negatematcher(sparsematch)])
33289
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   231
                self.sparsematch = sparsematch
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   232
                self.origignore = origignore
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   233
            return self.func
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   234
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   235
        def __set__(self, obj, value):
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   236
            return self.orig.__set__(obj, value)
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   237
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   238
        def __delete__(self, obj):
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   239
            return self.orig.__delete__(obj)
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   240
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   241
    replacefilecache(dirstate.dirstate, '_ignore', ignorewrapper)
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   242
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   243
    # dirstate.rebuild should not add non-matching files
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   244
    def _rebuild(orig, self, parent, allfiles, changedfiles=None):
33320
153456f02426 sparse: move function for resolving sparse matcher into core
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33319
diff changeset
   245
        matcher = sparse.matcher(self.repo)
153456f02426 sparse: move function for resolving sparse matcher into core
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33319
diff changeset
   246
        if not matcher.always():
33289
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   247
            allfiles = allfiles.matches(matcher)
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   248
            if changedfiles:
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   249
                changedfiles = [f for f in changedfiles if matcher(f)]
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   250
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   251
            if changedfiles is not None:
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   252
                # In _rebuild, these files will be deleted from the dirstate
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   253
                # when they are not found to be in allfiles
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   254
                dirstatefilestoremove = set(f for f in self if not matcher(f))
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   255
                changedfiles = dirstatefilestoremove.union(changedfiles)
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   256
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   257
        return orig(self, parent, allfiles, changedfiles)
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   258
    extensions.wrapfunction(dirstate.dirstate, 'rebuild', _rebuild)
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   259
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   260
    # Prevent adding files that are outside the sparse checkout
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   261
    editfuncs = ['normal', 'add', 'normallookup', 'copy', 'remove', 'merge']
33293
c9cbf4de27ba sparse: rename command to debugsparse
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33292
diff changeset
   262
    hint = _('include file with `hg debugsparse --include <pattern>` or use ' +
33289
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   263
             '`hg add -s <file>` to include file directory while adding')
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   264
    for func in editfuncs:
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   265
        def _wrapper(orig, self, *args):
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   266
            repo = self.repo
33320
153456f02426 sparse: move function for resolving sparse matcher into core
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33319
diff changeset
   267
            sparsematch = sparse.matcher(repo)
153456f02426 sparse: move function for resolving sparse matcher into core
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33319
diff changeset
   268
            if not sparsematch.always():
33289
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   269
                dirstate = repo.dirstate
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   270
                for f in args:
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   271
                    if (f is not None and not sparsematch(f) and
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   272
                        f not in dirstate):
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   273
                        raise error.Abort(_("cannot add '%s' - it is outside "
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   274
                                            "the sparse checkout") % f,
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   275
                                          hint=hint)
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   276
            return orig(self, *args)
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   277
        extensions.wrapfunction(dirstate.dirstate, func, _wrapper)
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   278
33293
c9cbf4de27ba sparse: rename command to debugsparse
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33292
diff changeset
   279
@command('^debugsparse', [
33289
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   280
    ('I', 'include', False, _('include files in the sparse checkout')),
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   281
    ('X', 'exclude', False, _('exclude files in the sparse checkout')),
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   282
    ('d', 'delete', False, _('delete an include/exclude rule')),
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   283
    ('f', 'force', False, _('allow changing rules even with pending changes')),
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   284
    ('', 'enable-profile', False, _('enables the specified profile')),
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   285
    ('', 'disable-profile', False, _('disables the specified profile')),
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   286
    ('', 'import-rules', False, _('imports rules from a file')),
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   287
    ('', 'clear-rules', False, _('clears local include/exclude rules')),
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   288
    ('', 'refresh', False, _('updates the working after sparseness changes')),
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   289
    ('', 'reset', False, _('makes the repo full again')),
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   290
    ] + commands.templateopts,
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   291
    _('[--OPTION] PATTERN...'))
33293
c9cbf4de27ba sparse: rename command to debugsparse
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33292
diff changeset
   292
def debugsparse(ui, repo, *pats, **opts):
33289
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   293
    """make the current checkout sparse, or edit the existing checkout
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   294
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   295
    The sparse command is used to make the current checkout sparse.
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   296
    This means files that don't meet the sparse condition will not be
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   297
    written to disk, or show up in any working copy operations. It does
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   298
    not affect files in history in any way.
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   299
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   300
    Passing no arguments prints the currently applied sparse rules.
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   301
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   302
    --include and --exclude are used to add and remove files from the sparse
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   303
    checkout. The effects of adding an include or exclude rule are applied
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   304
    immediately. If applying the new rule would cause a file with pending
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   305
    changes to be added or removed, the command will fail. Pass --force to
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   306
    force a rule change even with pending changes (the changes on disk will
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   307
    be preserved).
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   308
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   309
    --delete removes an existing include/exclude rule. The effects are
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   310
    immediate.
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   311
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   312
    --refresh refreshes the files on disk based on the sparse rules. This is
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   313
    only necessary if .hg/sparse was changed by hand.
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   314
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   315
    --enable-profile and --disable-profile accept a path to a .hgsparse file.
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   316
    This allows defining sparse checkouts and tracking them inside the
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   317
    repository. This is useful for defining commonly used sparse checkouts for
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   318
    many people to use. As the profile definition changes over time, the sparse
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   319
    checkout will automatically be updated appropriately, depending on which
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   320
    changeset is checked out. Changes to .hgsparse are not applied until they
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   321
    have been committed.
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   322
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   323
    --import-rules accepts a path to a file containing rules in the .hgsparse
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   324
    format, allowing you to add --include, --exclude and --enable-profile rules
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   325
    in bulk. Like the --include, --exclude and --enable-profile switches, the
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   326
    changes are applied immediately.
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   327
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   328
    --clear-rules removes all local include and exclude rules, while leaving
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   329
    any enabled profiles in place.
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   330
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   331
    Returns 0 if editing the sparse checkout succeeds.
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   332
    """
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   333
    include = opts.get('include')
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   334
    exclude = opts.get('exclude')
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   335
    force = opts.get('force')
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   336
    enableprofile = opts.get('enable_profile')
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   337
    disableprofile = opts.get('disable_profile')
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   338
    importrules = opts.get('import_rules')
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   339
    clearrules = opts.get('clear_rules')
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   340
    delete = opts.get('delete')
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   341
    refresh = opts.get('refresh')
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   342
    reset = opts.get('reset')
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   343
    count = sum([include, exclude, enableprofile, disableprofile, delete,
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   344
                 importrules, refresh, clearrules, reset])
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   345
    if count > 1:
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   346
        raise error.Abort(_("too many flags specified"))
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   347
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   348
    if count == 0:
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   349
        if repo.vfs.exists('sparse'):
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   350
            ui.status(repo.vfs.read("sparse") + "\n")
33304
3e1accab7447 sparse: move some temporary includes functions into core
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33303
diff changeset
   351
            temporaryincludes = sparse.readtemporaryincludes(repo)
33289
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   352
            if temporaryincludes:
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   353
                ui.status(_("Temporarily Included Files (for merge/rebase):\n"))
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   354
                ui.status(("\n".join(temporaryincludes) + "\n"))
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   355
        else:
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   356
            ui.status(_('repo is not sparse\n'))
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   357
        return
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   358
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   359
    if include or exclude or delete or reset or enableprofile or disableprofile:
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   360
        _config(ui, repo, pats, opts, include=include, exclude=exclude,
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   361
                reset=reset, delete=delete, enableprofile=enableprofile,
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   362
                disableprofile=disableprofile, force=force)
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   363
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   364
    if importrules:
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   365
        _import(ui, repo, pats, opts, force=force)
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   366
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   367
    if clearrules:
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   368
        _clear(ui, repo, pats, force=force)
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   369
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   370
    if refresh:
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   371
        try:
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   372
            wlock = repo.wlock()
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   373
            fcounts = map(
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   374
                len,
33324
33d0859c37bd sparse: move working directory refreshing into core
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33323
diff changeset
   375
                sparse.refreshwdir(repo, repo.status(), sparse.matcher(repo),
33d0859c37bd sparse: move working directory refreshing into core
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33323
diff changeset
   376
                                   force=force))
33289
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   377
            _verbose_output(ui, opts, 0, 0, 0, *fcounts)
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   378
        finally:
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   379
            wlock.release()
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   380
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   381
def _config(ui, repo, pats, opts, include=False, exclude=False, reset=False,
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   382
            delete=False, enableprofile=False, disableprofile=False,
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   383
            force=False):
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   384
    """
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   385
    Perform a sparse config update. Only one of the kwargs may be specified.
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   386
    """
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   387
    wlock = repo.wlock()
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   388
    try:
33320
153456f02426 sparse: move function for resolving sparse matcher into core
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33319
diff changeset
   389
        oldsparsematch = sparse.matcher(repo)
33289
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   390
33296
ee616196227c sparse: use vfs.tryread()
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33295
diff changeset
   391
        raw = repo.vfs.tryread('sparse')
ee616196227c sparse: use vfs.tryread()
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33295
diff changeset
   392
        if raw:
33289
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   393
            oldinclude, oldexclude, oldprofiles = map(
33297
ba5d89774db6 sparse: move config parsing into core
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33296
diff changeset
   394
                set, sparse.parseconfig(ui, raw))
33289
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   395
        else:
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   396
            oldinclude = set()
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   397
            oldexclude = set()
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   398
            oldprofiles = set()
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   399
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   400
        try:
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   401
            if reset:
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   402
                newinclude = set()
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   403
                newexclude = set()
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   404
                newprofiles = set()
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   405
            else:
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   406
                newinclude = set(oldinclude)
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   407
                newexclude = set(oldexclude)
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   408
                newprofiles = set(oldprofiles)
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   409
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   410
            oldstatus = repo.status()
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   411
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   412
            if any(pat.startswith('/') for pat in pats):
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   413
                ui.warn(_('warning: paths cannot start with /, ignoring: %s\n')
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   414
                          % ([pat for pat in pats if pat.startswith('/')]))
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   415
            elif include:
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   416
                newinclude.update(pats)
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   417
            elif exclude:
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   418
                newexclude.update(pats)
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   419
            elif enableprofile:
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   420
                newprofiles.update(pats)
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   421
            elif disableprofile:
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   422
                newprofiles.difference_update(pats)
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   423
            elif delete:
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   424
                newinclude.difference_update(pats)
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   425
                newexclude.difference_update(pats)
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   426
33303
8b571495d811 sparse: move config file writing into core
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33302
diff changeset
   427
            sparse.writeconfig(repo, newinclude, newexclude, newprofiles)
8b571495d811 sparse: move config file writing into core
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33302
diff changeset
   428
33289
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   429
            fcounts = map(
33324
33d0859c37bd sparse: move working directory refreshing into core
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33323
diff changeset
   430
                len,
33d0859c37bd sparse: move working directory refreshing into core
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33323
diff changeset
   431
                sparse.refreshwdir(repo, oldstatus, oldsparsematch,
33d0859c37bd sparse: move working directory refreshing into core
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33323
diff changeset
   432
                                   force=force))
33289
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   433
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   434
            profilecount = (len(newprofiles - oldprofiles) -
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   435
                            len(oldprofiles - newprofiles))
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   436
            includecount = (len(newinclude - oldinclude) -
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   437
                            len(oldinclude - newinclude))
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   438
            excludecount = (len(newexclude - oldexclude) -
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   439
                            len(oldexclude - newexclude))
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   440
            _verbose_output(
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   441
                ui, opts, profilecount, includecount, excludecount, *fcounts)
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   442
        except Exception:
33303
8b571495d811 sparse: move config file writing into core
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33302
diff changeset
   443
            sparse.writeconfig(repo, oldinclude, oldexclude, oldprofiles)
33289
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   444
            raise
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   445
    finally:
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   446
        wlock.release()
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   447
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   448
def _import(ui, repo, files, opts, force=False):
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   449
    with repo.wlock():
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   450
        # load union of current active profile
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   451
        revs = [repo.changelog.rev(node) for node in
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   452
                repo.dirstate.parents() if node != nullid]
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   453
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   454
        # read current configuration
33296
ee616196227c sparse: use vfs.tryread()
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33295
diff changeset
   455
        raw = repo.vfs.tryread('sparse')
33297
ba5d89774db6 sparse: move config parsing into core
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33296
diff changeset
   456
        oincludes, oexcludes, oprofiles = sparse.parseconfig(ui, raw)
33289
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   457
        includes, excludes, profiles = map(
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   458
                set, (oincludes, oexcludes, oprofiles))
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   459
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   460
        # all active rules
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   461
        aincludes, aexcludes, aprofiles = set(), set(), set()
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   462
        for rev in revs:
33300
f7a106b3f089 sparse: move resolving of sparse patterns for rev into core
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33299
diff changeset
   463
            rincludes, rexcludes, rprofiles = sparse.patternsforrev(repo, rev)
33289
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   464
            aincludes.update(rincludes)
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   465
            aexcludes.update(rexcludes)
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   466
            aprofiles.update(rprofiles)
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   467
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   468
        # import rules on top; only take in rules that are not yet
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   469
        # part of the active rules.
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   470
        changed = False
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   471
        for file in files:
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   472
            with util.posixfile(util.expandpath(file)) as importfile:
33297
ba5d89774db6 sparse: move config parsing into core
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33296
diff changeset
   473
                iincludes, iexcludes, iprofiles = sparse.parseconfig(
ba5d89774db6 sparse: move config parsing into core
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33296
diff changeset
   474
                    ui, importfile.read())
33289
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   475
                oldsize = len(includes) + len(excludes) + len(profiles)
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   476
                includes.update(iincludes - aincludes)
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   477
                excludes.update(iexcludes - aexcludes)
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   478
                profiles.update(set(iprofiles) - aprofiles)
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   479
                if len(includes) + len(excludes) + len(profiles) > oldsize:
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   480
                    changed = True
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   481
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   482
        profilecount = includecount = excludecount = 0
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   483
        fcounts = (0, 0, 0)
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   484
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   485
        if changed:
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   486
            profilecount = len(profiles - aprofiles)
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   487
            includecount = len(includes - aincludes)
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   488
            excludecount = len(excludes - aexcludes)
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   489
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   490
            oldstatus = repo.status()
33320
153456f02426 sparse: move function for resolving sparse matcher into core
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33319
diff changeset
   491
            oldsparsematch = sparse.matcher(repo)
33303
8b571495d811 sparse: move config file writing into core
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33302
diff changeset
   492
            sparse.writeconfig(repo, includes, excludes, profiles)
33289
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   493
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   494
            try:
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   495
                fcounts = map(
33324
33d0859c37bd sparse: move working directory refreshing into core
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33323
diff changeset
   496
                    len,
33d0859c37bd sparse: move working directory refreshing into core
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33323
diff changeset
   497
                    sparse.refreshwdir(repo, oldstatus, oldsparsematch,
33d0859c37bd sparse: move working directory refreshing into core
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33323
diff changeset
   498
                                       force=force))
33289
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   499
            except Exception:
33303
8b571495d811 sparse: move config file writing into core
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33302
diff changeset
   500
                sparse.writeconfig(repo, oincludes, oexcludes, oprofiles)
33289
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   501
                raise
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   502
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   503
        _verbose_output(ui, opts, profilecount, includecount, excludecount,
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   504
                        *fcounts)
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   505
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   506
def _clear(ui, repo, files, force=False):
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   507
    with repo.wlock():
33296
ee616196227c sparse: use vfs.tryread()
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33295
diff changeset
   508
        raw = repo.vfs.tryread('sparse')
33297
ba5d89774db6 sparse: move config parsing into core
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33296
diff changeset
   509
        includes, excludes, profiles = sparse.parseconfig(ui, raw)
33289
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   510
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   511
        if includes or excludes:
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   512
            oldstatus = repo.status()
33320
153456f02426 sparse: move function for resolving sparse matcher into core
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33319
diff changeset
   513
            oldsparsematch = sparse.matcher(repo)
33303
8b571495d811 sparse: move config file writing into core
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33302
diff changeset
   514
            sparse.writeconfig(repo, set(), set(), profiles)
33324
33d0859c37bd sparse: move working directory refreshing into core
Gregory Szorc <gregory.szorc@gmail.com>
parents: 33323
diff changeset
   515
            sparse.refreshwdir(repo, oldstatus, oldsparsematch, force)
33289
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   516
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   517
def _verbose_output(ui, opts, profilecount, includecount, excludecount, added,
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   518
                    dropped, lookup):
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   519
    """Produce --verbose and templatable output
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   520
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   521
    This specifically enables -Tjson, providing machine-readable stats on how
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   522
    the sparse profile changed.
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   523
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   524
    """
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   525
    with ui.formatter('sparse', opts) as fm:
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   526
        fm.startitem()
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   527
        fm.condwrite(ui.verbose, 'profiles_added', 'Profile # change: %d\n',
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   528
                     profilecount)
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   529
        fm.condwrite(ui.verbose, 'include_rules_added',
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   530
                     'Include rule # change: %d\n', includecount)
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   531
        fm.condwrite(ui.verbose, 'exclude_rules_added',
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   532
                     'Exclude rule # change: %d\n', excludecount)
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   533
        # In 'plain' verbose mode, mergemod.applyupdates already outputs what
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   534
        # files are added or removed outside of the templating formatter
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   535
        # framework. No point in repeating ourselves in that case.
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   536
        if not fm.isplain():
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   537
            fm.condwrite(ui.verbose, 'files_added', 'Files added: %d\n',
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   538
                         added)
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   539
            fm.condwrite(ui.verbose, 'files_dropped', 'Files dropped: %d\n',
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   540
                         dropped)
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   541
            fm.condwrite(ui.verbose, 'files_conflicting',
abd7dedbaa36 sparse: vendor Facebook-developed extension
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
   542
                         'Files conflicting: %d\n', lookup)