hgext/largefiles/reposetup.py
author Matt Harbison <mharbison@atto.com>
Thu, 05 Sep 2024 15:37:14 -0400
branchstable
changeset 51682 6388fd855f66
parent 51634 e32f23f15623
child 51749 493034cc3265
permissions -rw-r--r--
setup: handle removal of old MSVC compiler from setuptools 65.0 (issue6910) It was removed a few years ago[1]. When trying to reproduce locally using a clean py3.12 as called out in the bug report, `setuptools` wasn't installed at all, and needed a `pip install` to fix a `ModuleNotFoundError` when building locally. Maybe that needs to be in the requirements clause now. It looks like this "private" module was added in setuptools 48.0.[2] I can't find a changelog of what version was included in which version of python, and the changelog for pip has a huge gap between when it called out 67.6.1 in `pip` 23.1 (2023-04-15), and 41.4.0 in `pip` 19.3 (2019-10-14).[3] So, we'll just add to the existing code instead of replacing it, for safety. [1] https://github.com/pypa/setuptools/commit/cc017c77948737d131f683e0c25cd37bc639b8fc [2] https://github.com/pypa/setuptools/commit/d034a5ec7f707499139f90eb846b9e720923124c [3] https://pip.pypa.io/en/stable/news/
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
     1
# Copyright 2009-2010 Gregory P. Ward
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
     2
# Copyright 2009-2010 Intelerad Medical Systems Incorporated
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
     3
# Copyright 2010-2011 Fog Creek Software
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
     4
# Copyright 2010-2011 Unity Technologies
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
     5
#
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
     6
# This software may be used and distributed according to the terms of the
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
     7
# GNU General Public License version 2 or any later version.
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
     8
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
     9
'''setup for largefiles repositories: reposetup'''
29314
bde283a1ad1a py3: make largefiles/reposetup.py use absolute_import
liscju <piotr.listkiewicz@gmail.com>
parents: 28878
diff changeset
    10
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    11
import copy
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    12
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    13
from mercurial.i18n import _
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    14
29314
bde283a1ad1a py3: make largefiles/reposetup.py use absolute_import
liscju <piotr.listkiewicz@gmail.com>
parents: 28878
diff changeset
    15
from mercurial import (
bde283a1ad1a py3: make largefiles/reposetup.py use absolute_import
liscju <piotr.listkiewicz@gmail.com>
parents: 28878
diff changeset
    16
    error,
43634
7f4d58c21aec largefiles: avoid dynamically subclassing context instances
Martin von Zweigbergk <martinvonz@google.com>
parents: 43633
diff changeset
    17
    extensions,
29314
bde283a1ad1a py3: make largefiles/reposetup.py use absolute_import
liscju <piotr.listkiewicz@gmail.com>
parents: 28878
diff changeset
    18
    localrepo,
29319
cc497d2830b0 largefiles: rename match_ to matchmod import in reposetup
liscju <piotr.listkiewicz@gmail.com>
parents: 29314
diff changeset
    19
    match as matchmod,
29314
bde283a1ad1a py3: make largefiles/reposetup.py use absolute_import
liscju <piotr.listkiewicz@gmail.com>
parents: 28878
diff changeset
    20
    scmutil,
43632
99b881195abf largefiles: use context manager for wlock in repo.status() override
Martin von Zweigbergk <martinvonz@google.com>
parents: 43487
diff changeset
    21
    util,
29314
bde283a1ad1a py3: make largefiles/reposetup.py use absolute_import
liscju <piotr.listkiewicz@gmail.com>
parents: 28878
diff changeset
    22
)
bde283a1ad1a py3: make largefiles/reposetup.py use absolute_import
liscju <piotr.listkiewicz@gmail.com>
parents: 28878
diff changeset
    23
48430
991e6f728b50 status: adapt largefile to gather stats at lookup time
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 48180
diff changeset
    24
from mercurial.dirstateutils import timestamp
991e6f728b50 status: adapt largefile to gather stats at lookup time
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 48180
diff changeset
    25
29314
bde283a1ad1a py3: make largefiles/reposetup.py use absolute_import
liscju <piotr.listkiewicz@gmail.com>
parents: 28878
diff changeset
    26
from . import (
bde283a1ad1a py3: make largefiles/reposetup.py use absolute_import
liscju <piotr.listkiewicz@gmail.com>
parents: 28878
diff changeset
    27
    lfcommands,
bde283a1ad1a py3: make largefiles/reposetup.py use absolute_import
liscju <piotr.listkiewicz@gmail.com>
parents: 28878
diff changeset
    28
    lfutil,
bde283a1ad1a py3: make largefiles/reposetup.py use absolute_import
liscju <piotr.listkiewicz@gmail.com>
parents: 28878
diff changeset
    29
)
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    30
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42930
diff changeset
    31
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    32
def reposetup(ui, repo):
20858
bc56ec9e64df hg: introduce "wirepeersetupfuncs" to setup wire peer by extensions (issue4109)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20177
diff changeset
    33
    # wire repositories should be given new wireproto functions
bc56ec9e64df hg: introduce "wirepeersetupfuncs" to setup wire peer by extensions (issue4109)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20177
diff changeset
    34
    # by "proto.wirereposetup()" via "hg.wirepeersetupfuncs"
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    35
    if not repo.local():
20858
bc56ec9e64df hg: introduce "wirepeersetupfuncs" to setup wire peer by extensions (issue4109)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20177
diff changeset
    36
        return
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    37
16247
d87d9d8a8e03 largefiles: remove use of underscores that breaks coding convention
Na'Tosha Bard <natosha@unity3d.com>
parents: 16141
diff changeset
    38
    class lfilesrepo(repo.__class__):
24158
d414c28db84d largefiles: access to specific fields only if largefiles enabled (issue4547)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 23958
diff changeset
    39
        # the mark to examine whether "repo" object enables largefiles or not
d414c28db84d largefiles: access to specific fields only if largefiles enabled (issue4547)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 23958
diff changeset
    40
        _largefilesenabled = True
d414c28db84d largefiles: access to specific fields only if largefiles enabled (issue4547)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 23958
diff changeset
    41
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    42
        lfstatus = False
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42930
diff changeset
    43
15252
6e809bb4f969 largefiles: improve comments, internal docstrings
Greg Ward <greg@gerg.ca>
parents: 15250
diff changeset
    44
        # When lfstatus is set, return a context that gives the names
6e809bb4f969 largefiles: improve comments, internal docstrings
Greg Ward <greg@gerg.ca>
parents: 15250
diff changeset
    45
        # of largefiles instead of their corresponding standins and
6e809bb4f969 largefiles: improve comments, internal docstrings
Greg Ward <greg@gerg.ca>
parents: 15250
diff changeset
    46
        # identifies the largefiles as always binary, regardless of
6e809bb4f969 largefiles: improve comments, internal docstrings
Greg Ward <greg@gerg.ca>
parents: 15250
diff changeset
    47
        # their actual contents.
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    48
        def __getitem__(self, changeid):
16247
d87d9d8a8e03 largefiles: remove use of underscores that breaks coding convention
Na'Tosha Bard <natosha@unity3d.com>
parents: 16141
diff changeset
    49
            ctx = super(lfilesrepo, self).__getitem__(changeid)
23958
df463ca0adef largefiles: revert to lfilesrepo.status() being an unfiltered method
Matt Harbison <matt_harbison@yahoo.com>
parents: 23923
diff changeset
    50
            if self.lfstatus:
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42930
diff changeset
    51
43634
7f4d58c21aec largefiles: avoid dynamically subclassing context instances
Martin von Zweigbergk <martinvonz@google.com>
parents: 43633
diff changeset
    52
                def files(orig):
7f4d58c21aec largefiles: avoid dynamically subclassing context instances
Martin von Zweigbergk <martinvonz@google.com>
parents: 43633
diff changeset
    53
                    filenames = orig()
7f4d58c21aec largefiles: avoid dynamically subclassing context instances
Martin von Zweigbergk <martinvonz@google.com>
parents: 43633
diff changeset
    54
                    return [lfutil.splitstandin(f) or f for f in filenames]
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42930
diff changeset
    55
43634
7f4d58c21aec largefiles: avoid dynamically subclassing context instances
Martin von Zweigbergk <martinvonz@google.com>
parents: 43633
diff changeset
    56
                extensions.wrapfunction(ctx, 'files', files)
7f4d58c21aec largefiles: avoid dynamically subclassing context instances
Martin von Zweigbergk <martinvonz@google.com>
parents: 43633
diff changeset
    57
7f4d58c21aec largefiles: avoid dynamically subclassing context instances
Martin von Zweigbergk <martinvonz@google.com>
parents: 43633
diff changeset
    58
                def manifest(orig):
7f4d58c21aec largefiles: avoid dynamically subclassing context instances
Martin von Zweigbergk <martinvonz@google.com>
parents: 43633
diff changeset
    59
                    man1 = orig()
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42930
diff changeset
    60
43634
7f4d58c21aec largefiles: avoid dynamically subclassing context instances
Martin von Zweigbergk <martinvonz@google.com>
parents: 43633
diff changeset
    61
                    class lfilesmanifest(man1.__class__):
7f4d58c21aec largefiles: avoid dynamically subclassing context instances
Martin von Zweigbergk <martinvonz@google.com>
parents: 43633
diff changeset
    62
                        def __contains__(self, filename):
7f4d58c21aec largefiles: avoid dynamically subclassing context instances
Martin von Zweigbergk <martinvonz@google.com>
parents: 43633
diff changeset
    63
                            orig = super(lfilesmanifest, self).__contains__
7f4d58c21aec largefiles: avoid dynamically subclassing context instances
Martin von Zweigbergk <martinvonz@google.com>
parents: 43633
diff changeset
    64
                            return orig(filename) or orig(
7f4d58c21aec largefiles: avoid dynamically subclassing context instances
Martin von Zweigbergk <martinvonz@google.com>
parents: 43633
diff changeset
    65
                                lfutil.standin(filename)
7f4d58c21aec largefiles: avoid dynamically subclassing context instances
Martin von Zweigbergk <martinvonz@google.com>
parents: 43633
diff changeset
    66
                            )
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42930
diff changeset
    67
43634
7f4d58c21aec largefiles: avoid dynamically subclassing context instances
Martin von Zweigbergk <martinvonz@google.com>
parents: 43633
diff changeset
    68
                    man1.__class__ = lfilesmanifest
7f4d58c21aec largefiles: avoid dynamically subclassing context instances
Martin von Zweigbergk <martinvonz@google.com>
parents: 43633
diff changeset
    69
                    return man1
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42930
diff changeset
    70
43634
7f4d58c21aec largefiles: avoid dynamically subclassing context instances
Martin von Zweigbergk <martinvonz@google.com>
parents: 43633
diff changeset
    71
                extensions.wrapfunction(ctx, 'manifest', manifest)
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42930
diff changeset
    72
43634
7f4d58c21aec largefiles: avoid dynamically subclassing context instances
Martin von Zweigbergk <martinvonz@google.com>
parents: 43633
diff changeset
    73
                def filectx(orig, path, fileid=None, filelog=None):
7f4d58c21aec largefiles: avoid dynamically subclassing context instances
Martin von Zweigbergk <martinvonz@google.com>
parents: 43633
diff changeset
    74
                    try:
7f4d58c21aec largefiles: avoid dynamically subclassing context instances
Martin von Zweigbergk <martinvonz@google.com>
parents: 43633
diff changeset
    75
                        if filelog is not None:
7f4d58c21aec largefiles: avoid dynamically subclassing context instances
Martin von Zweigbergk <martinvonz@google.com>
parents: 43633
diff changeset
    76
                            result = orig(path, fileid, filelog)
7f4d58c21aec largefiles: avoid dynamically subclassing context instances
Martin von Zweigbergk <martinvonz@google.com>
parents: 43633
diff changeset
    77
                        else:
7f4d58c21aec largefiles: avoid dynamically subclassing context instances
Martin von Zweigbergk <martinvonz@google.com>
parents: 43633
diff changeset
    78
                            result = orig(path, fileid)
7f4d58c21aec largefiles: avoid dynamically subclassing context instances
Martin von Zweigbergk <martinvonz@google.com>
parents: 43633
diff changeset
    79
                    except error.LookupError:
7f4d58c21aec largefiles: avoid dynamically subclassing context instances
Martin von Zweigbergk <martinvonz@google.com>
parents: 43633
diff changeset
    80
                        # Adding a null character will cause Mercurial to
7f4d58c21aec largefiles: avoid dynamically subclassing context instances
Martin von Zweigbergk <martinvonz@google.com>
parents: 43633
diff changeset
    81
                        # identify this as a binary file.
7f4d58c21aec largefiles: avoid dynamically subclassing context instances
Martin von Zweigbergk <martinvonz@google.com>
parents: 43633
diff changeset
    82
                        if filelog is not None:
7f4d58c21aec largefiles: avoid dynamically subclassing context instances
Martin von Zweigbergk <martinvonz@google.com>
parents: 43633
diff changeset
    83
                            result = orig(lfutil.standin(path), fileid, filelog)
7f4d58c21aec largefiles: avoid dynamically subclassing context instances
Martin von Zweigbergk <martinvonz@google.com>
parents: 43633
diff changeset
    84
                        else:
7f4d58c21aec largefiles: avoid dynamically subclassing context instances
Martin von Zweigbergk <martinvonz@google.com>
parents: 43633
diff changeset
    85
                            result = orig(lfutil.standin(path), fileid)
7f4d58c21aec largefiles: avoid dynamically subclassing context instances
Martin von Zweigbergk <martinvonz@google.com>
parents: 43633
diff changeset
    86
                        olddata = result.data
7f4d58c21aec largefiles: avoid dynamically subclassing context instances
Martin von Zweigbergk <martinvonz@google.com>
parents: 43633
diff changeset
    87
                        result.data = lambda: olddata() + b'\0'
7f4d58c21aec largefiles: avoid dynamically subclassing context instances
Martin von Zweigbergk <martinvonz@google.com>
parents: 43633
diff changeset
    88
                    return result
7f4d58c21aec largefiles: avoid dynamically subclassing context instances
Martin von Zweigbergk <martinvonz@google.com>
parents: 43633
diff changeset
    89
7f4d58c21aec largefiles: avoid dynamically subclassing context instances
Martin von Zweigbergk <martinvonz@google.com>
parents: 43633
diff changeset
    90
                extensions.wrapfunction(ctx, 'filectx', filectx)
7f4d58c21aec largefiles: avoid dynamically subclassing context instances
Martin von Zweigbergk <martinvonz@google.com>
parents: 43633
diff changeset
    91
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    92
            return ctx
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    93
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    94
        # Figure out the status of big files and insert them into the
15252
6e809bb4f969 largefiles: improve comments, internal docstrings
Greg Ward <greg@gerg.ca>
parents: 15250
diff changeset
    95
        # appropriate list in the result. Also removes standin files
6e809bb4f969 largefiles: improve comments, internal docstrings
Greg Ward <greg@gerg.ca>
parents: 15250
diff changeset
    96
        # from the listing. Revert to the original status if
6e809bb4f969 largefiles: improve comments, internal docstrings
Greg Ward <greg@gerg.ca>
parents: 15250
diff changeset
    97
        # self.lfstatus is False.
23958
df463ca0adef largefiles: revert to lfilesrepo.status() being an unfiltered method
Matt Harbison <matt_harbison@yahoo.com>
parents: 23923
diff changeset
    98
        # XXX large file status is buggy when used on repo proxy.
df463ca0adef largefiles: revert to lfilesrepo.status() being an unfiltered method
Matt Harbison <matt_harbison@yahoo.com>
parents: 23923
diff changeset
    99
        # XXX this needs to be investigated.
df463ca0adef largefiles: revert to lfilesrepo.status() being an unfiltered method
Matt Harbison <matt_harbison@yahoo.com>
parents: 23923
diff changeset
   100
        @localrepo.unfilteredmethod
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42930
diff changeset
   101
        def status(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42930
diff changeset
   102
            self,
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   103
            node1=b'.',
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42930
diff changeset
   104
            node2=None,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42930
diff changeset
   105
            match=None,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42930
diff changeset
   106
            ignored=False,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42930
diff changeset
   107
            clean=False,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42930
diff changeset
   108
            unknown=False,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42930
diff changeset
   109
            listsubrepos=False,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42930
diff changeset
   110
        ):
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   111
            listignored, listclean, listunknown = ignored, clean, unknown
22518
52dd6e25121f largefiles: extract 'orig' method in reposetup.status
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22517
diff changeset
   112
            orig = super(lfilesrepo, self).status
23958
df463ca0adef largefiles: revert to lfilesrepo.status() being an unfiltered method
Matt Harbison <matt_harbison@yahoo.com>
parents: 23923
diff changeset
   113
            if not self.lfstatus:
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42930
diff changeset
   114
                return orig(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42930
diff changeset
   115
                    node1,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42930
diff changeset
   116
                    node2,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42930
diff changeset
   117
                    match,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42930
diff changeset
   118
                    listignored,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42930
diff changeset
   119
                    listclean,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42930
diff changeset
   120
                    listunknown,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42930
diff changeset
   121
                    listsubrepos,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42930
diff changeset
   122
                )
22515
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   123
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   124
            # some calls in this function rely on the old version of status
23958
df463ca0adef largefiles: revert to lfilesrepo.status() being an unfiltered method
Matt Harbison <matt_harbison@yahoo.com>
parents: 23923
diff changeset
   125
            self.lfstatus = False
22515
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   126
            ctx1 = self[node1]
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   127
            ctx2 = self[node2]
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   128
            working = ctx2.rev() is None
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   129
            parentworking = working and ctx1 == self[b'.']
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   130
22515
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   131
            if match is None:
41687
0531dff73d0b match: delete unused root and cwd arguments from {always,never,exact}() (API)
Martin von Zweigbergk <martinvonz@google.com>
parents: 35107
diff changeset
   132
                match = matchmod.always()
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   133
22515
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   134
            try:
43632
99b881195abf largefiles: use context manager for wlock in repo.status() override
Martin von Zweigbergk <martinvonz@google.com>
parents: 43487
diff changeset
   135
                # updating the dirstate is optional
99b881195abf largefiles: use context manager for wlock in repo.status() override
Martin von Zweigbergk <martinvonz@google.com>
parents: 43487
diff changeset
   136
                # so we don't wait on the lock
99b881195abf largefiles: use context manager for wlock in repo.status() override
Martin von Zweigbergk <martinvonz@google.com>
parents: 43487
diff changeset
   137
                wlock = self.wlock(False)
99b881195abf largefiles: use context manager for wlock in repo.status() override
Martin von Zweigbergk <martinvonz@google.com>
parents: 43487
diff changeset
   138
                gotlock = True
99b881195abf largefiles: use context manager for wlock in repo.status() override
Martin von Zweigbergk <martinvonz@google.com>
parents: 43487
diff changeset
   139
            except error.LockError:
99b881195abf largefiles: use context manager for wlock in repo.status() override
Martin von Zweigbergk <martinvonz@google.com>
parents: 43487
diff changeset
   140
                wlock = util.nullcontextmanager()
99b881195abf largefiles: use context manager for wlock in repo.status() override
Martin von Zweigbergk <martinvonz@google.com>
parents: 43487
diff changeset
   141
                gotlock = False
50185
b38b53c5674e large-files: wrap reposetup's status in a `running_status` context
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 48966
diff changeset
   142
            with wlock, self.dirstate.running_status(self):
15653
93c77d5b9752 largefiles: optimize status when files are specified (issue3144)
Na'Tosha Bard <natosha@unity3d.com>
parents: 15630
diff changeset
   143
23146
5311de37b86f largefiles: shortcircuit status code also for non-matching patterns
Martin von Zweigbergk <martinvonz@google.com>
parents: 23139
diff changeset
   144
                # First check if paths or patterns were specified on the
5311de37b86f largefiles: shortcircuit status code also for non-matching patterns
Martin von Zweigbergk <martinvonz@google.com>
parents: 23139
diff changeset
   145
                # command line.  If there were, and they don't match any
22515
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   146
                # largefiles, we should just bail here and let super
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   147
                # handle it -- thus gaining a big performance boost.
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   148
                lfdirstate = lfutil.openlfdirstate(ui, self)
23146
5311de37b86f largefiles: shortcircuit status code also for non-matching patterns
Martin von Zweigbergk <martinvonz@google.com>
parents: 23139
diff changeset
   149
                if not match.always():
22515
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   150
                    for f in lfdirstate:
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   151
                        if match(f):
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   152
                            break
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   153
                    else:
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42930
diff changeset
   154
                        return orig(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42930
diff changeset
   155
                            node1,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42930
diff changeset
   156
                            node2,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42930
diff changeset
   157
                            match,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42930
diff changeset
   158
                            listignored,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42930
diff changeset
   159
                            listclean,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42930
diff changeset
   160
                            listunknown,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42930
diff changeset
   161
                            listsubrepos,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42930
diff changeset
   162
                        )
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   163
22515
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   164
                # Create a copy of match that matches standins instead
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   165
                # of largefiles.
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   166
                def tostandins(files):
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   167
                    if not working:
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   168
                        return files
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   169
                    newfiles = []
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   170
                    dirstate = self.dirstate
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   171
                    for f in files:
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   172
                        sf = lfutil.standin(f)
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   173
                        if sf in dirstate:
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   174
                            newfiles.append(sf)
35107
61888bd0b300 dirstate: add explicit methods for querying directories (API)
Mark Thomas <mbthomas@fb.com>
parents: 34351
diff changeset
   175
                        elif dirstate.hasdir(sf):
22515
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   176
                            # Directory entries could be regular or
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   177
                            # standin, check both
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   178
                            newfiles.extend((f, sf))
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   179
                        else:
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   180
                            newfiles.append(f)
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   181
                    return newfiles
18149
2dcc3653b361 largefiles: unindent code
Mads Kiilerich <madski@unity3d.com>
parents: 18148
diff changeset
   182
22515
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   183
                m = copy.copy(match)
51634
e32f23f15623 largefiles: mark more matchers as having been tampered with
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents: 50538
diff changeset
   184
                m._was_tampered_with = True
22515
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   185
                m._files = tostandins(m._files)
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   186
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42930
diff changeset
   187
                result = orig(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42930
diff changeset
   188
                    node1, node2, m, ignored, clean, unknown, listsubrepos
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42930
diff changeset
   189
                )
22515
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   190
                if working:
15617
74e691b141c4 largefiles: optimize performance of status on largefiles repos (issue3136)
Na'Tosha Bard <natosha@unity3d.com>
parents: 15385
diff changeset
   191
22515
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   192
                    def sfindirstate(f):
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   193
                        sf = lfutil.standin(f)
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   194
                        dirstate = self.dirstate
35107
61888bd0b300 dirstate: add explicit methods for querying directories (API)
Mark Thomas <mbthomas@fb.com>
parents: 34351
diff changeset
   195
                        return sf in dirstate or dirstate.hasdir(sf)
18149
2dcc3653b361 largefiles: unindent code
Mads Kiilerich <madski@unity3d.com>
parents: 18148
diff changeset
   196
51634
e32f23f15623 largefiles: mark more matchers as having been tampered with
Arseniy Alekseyev <aalekseyev@janestreet.com>
parents: 50538
diff changeset
   197
                    match._was_tampered_with = True
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42930
diff changeset
   198
                    match._files = [f for f in match._files if sfindirstate(f)]
22515
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   199
                    # Don't waste time getting the ignored and unknown
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   200
                    # files from lfdirstate
48438
322525db4c98 status: use filesystem time boundary to invalidate racy mtime
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 48430
diff changeset
   201
                    unsure, s, mtime_boundary = lfdirstate.status(
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42930
diff changeset
   202
                        match,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42930
diff changeset
   203
                        subrepos=[],
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42930
diff changeset
   204
                        ignored=False,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42930
diff changeset
   205
                        clean=listclean,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42930
diff changeset
   206
                        unknown=False,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42930
diff changeset
   207
                    )
30191
328545c7d8a1 largefiles: fix 'deleted' files sometimes persistently appearing with R status
Mads Kiilerich <madski@unity3d.com>
parents: 29319
diff changeset
   208
                    (modified, added, removed, deleted, clean) = (
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42930
diff changeset
   209
                        s.modified,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42930
diff changeset
   210
                        s.added,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42930
diff changeset
   211
                        s.removed,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42930
diff changeset
   212
                        s.deleted,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42930
diff changeset
   213
                        s.clean,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42930
diff changeset
   214
                    )
22515
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   215
                    if parentworking:
48430
991e6f728b50 status: adapt largefile to gather stats at lookup time
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 48180
diff changeset
   216
                        wctx = repo[None]
22515
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   217
                        for lfile in unsure:
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   218
                            standin = lfutil.standin(lfile)
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   219
                            if standin not in ctx1:
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   220
                                # from second parent
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   221
                                modified.append(lfile)
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42930
diff changeset
   222
                            elif lfutil.readasstandin(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42930
diff changeset
   223
                                ctx1[standin]
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42930
diff changeset
   224
                            ) != lfutil.hashfile(self.wjoin(lfile)):
22515
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   225
                                modified.append(lfile)
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   226
                            else:
22523
8cd91f481ffd largefiles: remove unnecessary clearing of status fields
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22518
diff changeset
   227
                                if listclean:
8cd91f481ffd largefiles: remove unnecessary clearing of status fields
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22518
diff changeset
   228
                                    clean.append(lfile)
48430
991e6f728b50 status: adapt largefile to gather stats at lookup time
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 48180
diff changeset
   229
                                s = wctx[lfile].lstat()
991e6f728b50 status: adapt largefile to gather stats at lookup time
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 48180
diff changeset
   230
                                mode = s.st_mode
991e6f728b50 status: adapt largefile to gather stats at lookup time
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 48180
diff changeset
   231
                                size = s.st_size
48444
c0d88407b7d4 largefile: use the proper "mtime boundary" logic during fixup
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 48438
diff changeset
   232
                                mtime = timestamp.reliable_mtime_of(
c0d88407b7d4 largefile: use the proper "mtime boundary" logic during fixup
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 48438
diff changeset
   233
                                    s, mtime_boundary
c0d88407b7d4 largefile: use the proper "mtime boundary" logic during fixup
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 48438
diff changeset
   234
                                )
c0d88407b7d4 largefile: use the proper "mtime boundary" logic during fixup
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 48438
diff changeset
   235
                                if mtime is not None:
c0d88407b7d4 largefile: use the proper "mtime boundary" logic during fixup
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 48438
diff changeset
   236
                                    cache_data = (mode, size, mtime)
c0d88407b7d4 largefile: use the proper "mtime boundary" logic during fixup
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 48438
diff changeset
   237
                                    lfdirstate.set_clean(lfile, cache_data)
22515
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   238
                    else:
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   239
                        tocheck = unsure + modified + added + clean
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   240
                        modified, added, clean = [], [], []
23383
7f8d27e1f862 largefiles: avoid exec-bit examination on the platform being unaware of it
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 23090
diff changeset
   241
                        checkexec = self.dirstate._checkexec
22515
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   242
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   243
                        for lfile in tocheck:
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   244
                            standin = lfutil.standin(lfile)
23043
244dbb646ab7 largefiles: inline redundant inctx function in status
Mads Kiilerich <madski@unity3d.com>
parents: 22919
diff changeset
   245
                            if standin in ctx1:
23090
24600c9d7f4e largefiles: add examination of exec bit in "hg status --rev REV" case
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 23089
diff changeset
   246
                                abslfile = self.wjoin(lfile)
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42930
diff changeset
   247
                                if (
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42930
diff changeset
   248
                                    lfutil.readasstandin(ctx1[standin])
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42930
diff changeset
   249
                                    != lfutil.hashfile(abslfile)
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42930
diff changeset
   250
                                ) or (
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42930
diff changeset
   251
                                    checkexec
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   252
                                    and (b'x' in ctx1.flags(standin))
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42930
diff changeset
   253
                                    != bool(lfutil.getexecutable(abslfile))
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42930
diff changeset
   254
                                ):
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   255
                                    modified.append(lfile)
22523
8cd91f481ffd largefiles: remove unnecessary clearing of status fields
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22518
diff changeset
   256
                                elif listclean:
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   257
                                    clean.append(lfile)
22515
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   258
                            else:
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   259
                                added.append(lfile)
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   260
23089
197dc4580da2 largefiles: ignore removal status of files not managed in the target context
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 23044
diff changeset
   261
                        # at this point, 'removed' contains largefiles
197dc4580da2 largefiles: ignore removal status of files not managed in the target context
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 23044
diff changeset
   262
                        # marked as 'R' in the working context.
197dc4580da2 largefiles: ignore removal status of files not managed in the target context
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 23044
diff changeset
   263
                        # then, largefiles not managed also in the target
197dc4580da2 largefiles: ignore removal status of files not managed in the target context
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 23044
diff changeset
   264
                        # context should be excluded from 'removed'.
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42930
diff changeset
   265
                        removed = [
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42930
diff changeset
   266
                            lfile
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42930
diff changeset
   267
                            for lfile in removed
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42930
diff changeset
   268
                            if lfutil.standin(lfile) in ctx1
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42930
diff changeset
   269
                        ]
23089
197dc4580da2 largefiles: ignore removal status of files not managed in the target context
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 23044
diff changeset
   270
30191
328545c7d8a1 largefiles: fix 'deleted' files sometimes persistently appearing with R status
Mads Kiilerich <madski@unity3d.com>
parents: 29319
diff changeset
   271
                    # Standins no longer found in lfdirstate have been deleted
22525
764127f58903 largefiles: simplify iteration over standins
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22524
diff changeset
   272
                    for standin in ctx1.walk(lfutil.getstandinmatcher(self)):
22515
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   273
                        lfile = lfutil.splitstandin(standin)
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   274
                        if not match(lfile):
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   275
                            continue
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   276
                        if lfile not in lfdirstate:
30191
328545c7d8a1 largefiles: fix 'deleted' files sometimes persistently appearing with R status
Mads Kiilerich <madski@unity3d.com>
parents: 29319
diff changeset
   277
                            deleted.append(lfile)
328545c7d8a1 largefiles: fix 'deleted' files sometimes persistently appearing with R status
Mads Kiilerich <madski@unity3d.com>
parents: 29319
diff changeset
   278
                            # Sync "largefile has been removed" back to the
328545c7d8a1 largefiles: fix 'deleted' files sometimes persistently appearing with R status
Mads Kiilerich <madski@unity3d.com>
parents: 29319
diff changeset
   279
                            # standin. Removing a file as a side effect of
328545c7d8a1 largefiles: fix 'deleted' files sometimes persistently appearing with R status
Mads Kiilerich <madski@unity3d.com>
parents: 29319
diff changeset
   280
                            # running status is gross, but the alternatives (if
328545c7d8a1 largefiles: fix 'deleted' files sometimes persistently appearing with R status
Mads Kiilerich <madski@unity3d.com>
parents: 29319
diff changeset
   281
                            # any) are worse.
30233
3afde791dce1 largefiles: handle that a found standin file doesn't exist when removing it
Mads Kiilerich <madski@unity3d.com>
parents: 30191
diff changeset
   282
                            self.wvfs.unlinkpath(standin, ignoremissing=True)
15663
9036c7d106bf largefiles: handle merges between normal files and largefiles (issue3084)
Martin Geisler <mg@aragost.com>
parents: 15629
diff changeset
   283
22515
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   284
                    # Filter result lists
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   285
                    result = list(result)
19056
ac41bb76c737 largefiles: wlock in status before lfdirstate.write()
Mads Kiilerich <madski@unity3d.com>
parents: 18969
diff changeset
   286
22515
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   287
                    # Largefiles are not really removed when they're
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   288
                    # still in the normal dirstate. Likewise, normal
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   289
                    # files are not really removed if they are still in
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   290
                    # lfdirstate. This happens in merges where files
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   291
                    # change type.
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42930
diff changeset
   292
                    removed = [f for f in removed if f not in self.dirstate]
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42930
diff changeset
   293
                    result[2] = [f for f in result[2] if f not in lfdirstate]
15663
9036c7d106bf largefiles: handle merges between normal files and largefiles (issue3084)
Martin Geisler <mg@aragost.com>
parents: 15629
diff changeset
   294
42930
34ed651ba7e4 cleanup: fix leakage of dirstate._map to client code
Augie Fackler <augie@google.com>
parents: 41768
diff changeset
   295
                    lfiles = set(lfdirstate)
22515
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   296
                    # Unknown files
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   297
                    result[4] = set(result[4]).difference(lfiles)
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   298
                    # Ignored files
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   299
                    result[5] = set(result[5]).difference(lfiles)
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   300
                    # combine normal files and largefiles
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42930
diff changeset
   301
                    normals = [
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42930
diff changeset
   302
                        [fn for fn in filelist if not lfutil.isstandin(fn)]
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42930
diff changeset
   303
                        for filelist in result
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42930
diff changeset
   304
                    ]
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42930
diff changeset
   305
                    lfstatus = (
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42930
diff changeset
   306
                        modified,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42930
diff changeset
   307
                        added,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42930
diff changeset
   308
                        removed,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42930
diff changeset
   309
                        deleted,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42930
diff changeset
   310
                        [],
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42930
diff changeset
   311
                        [],
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42930
diff changeset
   312
                        clean,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42930
diff changeset
   313
                    )
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42930
diff changeset
   314
                    result = [
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42930
diff changeset
   315
                        sorted(list1 + list2)
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42930
diff changeset
   316
                        for (list1, list2) in zip(normals, lfstatus)
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42930
diff changeset
   317
                    ]
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42930
diff changeset
   318
                else:  # not against working directory
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42930
diff changeset
   319
                    result = [
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42930
diff changeset
   320
                        [lfutil.splitstandin(f) or f for f in items]
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42930
diff changeset
   321
                        for items in result
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42930
diff changeset
   322
                    ]
15663
9036c7d106bf largefiles: handle merges between normal files and largefiles (issue3084)
Martin Geisler <mg@aragost.com>
parents: 15629
diff changeset
   323
43632
99b881195abf largefiles: use context manager for wlock in repo.status() override
Martin von Zweigbergk <martinvonz@google.com>
parents: 43487
diff changeset
   324
                if gotlock:
48180
df3021c1f093 largefiles: pass current transaction to `lfdirstate.write()`
Pulkit Goyal <7895pulkit@gmail.com>
parents: 47715
diff changeset
   325
                    lfdirstate.write(self.currenttransaction())
50185
b38b53c5674e large-files: wrap reposetup's status in a `running_status` context
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 48966
diff changeset
   326
                else:
b38b53c5674e large-files: wrap reposetup's status in a `running_status` context
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 48966
diff changeset
   327
                    lfdirstate.invalidate()
22515
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   328
23958
df463ca0adef largefiles: revert to lfilesrepo.status() being an unfiltered method
Matt Harbison <matt_harbison@yahoo.com>
parents: 23923
diff changeset
   329
            self.lfstatus = True
22914
c95db3208a33 status: update various other methods to return new class
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22911
diff changeset
   330
            return scmutil.status(*result)
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   331
23184
3100d1cbce32 largefiles: factor out procedures to update lfdirstate for post-committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 23147
diff changeset
   332
        def commitctx(self, ctx, *args, **kwargs):
3100d1cbce32 largefiles: factor out procedures to update lfdirstate for post-committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 23147
diff changeset
   333
            node = super(lfilesrepo, self).commitctx(ctx, *args, **kwargs)
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42930
diff changeset
   334
23184
3100d1cbce32 largefiles: factor out procedures to update lfdirstate for post-committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 23147
diff changeset
   335
            class lfilesctx(ctx.__class__):
3100d1cbce32 largefiles: factor out procedures to update lfdirstate for post-committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 23147
diff changeset
   336
                def markcommitted(self, node):
3100d1cbce32 largefiles: factor out procedures to update lfdirstate for post-committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 23147
diff changeset
   337
                    orig = super(lfilesctx, self).markcommitted
3100d1cbce32 largefiles: factor out procedures to update lfdirstate for post-committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 23147
diff changeset
   338
                    return lfutil.markcommitted(orig, self, node)
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42930
diff changeset
   339
23184
3100d1cbce32 largefiles: factor out procedures to update lfdirstate for post-committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 23147
diff changeset
   340
            ctx.__class__ = lfilesctx
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   341
            return node
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   342
15254
dd03d3a9f888 largefiles: more work on cleaning up comments
Greg Ward <greg@gerg.ca>
parents: 15253
diff changeset
   343
        # Before commit, largefile standins have not had their
dd03d3a9f888 largefiles: more work on cleaning up comments
Greg Ward <greg@gerg.ca>
parents: 15253
diff changeset
   344
        # contents updated to reflect the hash of their largefile.
dd03d3a9f888 largefiles: more work on cleaning up comments
Greg Ward <greg@gerg.ca>
parents: 15253
diff changeset
   345
        # Do that here.
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42930
diff changeset
   346
        def commit(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42930
diff changeset
   347
            self,
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   348
            text=b"",
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42930
diff changeset
   349
            user=None,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42930
diff changeset
   350
            date=None,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42930
diff changeset
   351
            match=None,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42930
diff changeset
   352
            force=False,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42930
diff changeset
   353
            editor=False,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42930
diff changeset
   354
            extra=None,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42930
diff changeset
   355
        ):
31419
86dfd31c0329 largefiles: don't use mutable default argument value
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30233
diff changeset
   356
            if extra is None:
86dfd31c0329 largefiles: don't use mutable default argument value
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 30233
diff changeset
   357
                extra = {}
16247
d87d9d8a8e03 largefiles: remove use of underscores that breaks coding convention
Na'Tosha Bard <natosha@unity3d.com>
parents: 16141
diff changeset
   358
            orig = super(lfilesrepo, self).commit
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   359
27842
002108b219e3 with: use context manager in largefiles commit
Bryan O'Sullivan <bryano@fb.com>
parents: 26587
diff changeset
   360
            with self.wlock():
23186
6de61d0b773f largefiles: introduce "_lfcommithooks" to abstract pre-committing procedures
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 23185
diff changeset
   361
                lfcommithook = self._lfcommithooks[-1]
6de61d0b773f largefiles: introduce "_lfcommithooks" to abstract pre-committing procedures
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 23185
diff changeset
   362
                match = lfcommithook(self, match)
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42930
diff changeset
   363
                result = orig(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42930
diff changeset
   364
                    text=text,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42930
diff changeset
   365
                    user=user,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42930
diff changeset
   366
                    date=date,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42930
diff changeset
   367
                    match=match,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42930
diff changeset
   368
                    force=force,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42930
diff changeset
   369
                    editor=editor,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42930
diff changeset
   370
                    extra=extra,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42930
diff changeset
   371
                )
15794
0d91211dd12f largefiles: fix inappropriate locking (issue3182)
Levi Bard <levi@unity3d.com>
parents: 15793
diff changeset
   372
                return result
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   373
23185
9870173e0b48 largefiles: factor out procedures to update standins for pre-committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 23184
diff changeset
   374
        # TODO: _subdirlfs should be moved into "lfutil.py", because
9870173e0b48 largefiles: factor out procedures to update standins for pre-committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 23184
diff changeset
   375
        # it is referred only from "lfutil.updatestandinsbymatch"
18064
7e2b9f6a2cd0 largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents: 17803
diff changeset
   376
        def _subdirlfs(self, files, lfiles):
45957
89a2afe31e82 formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents: 45106
diff changeset
   377
            """
18064
7e2b9f6a2cd0 largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents: 17803
diff changeset
   378
            Adjust matched file list
23543
4dd8a6a1240d spelling: fixes from proofreading of spell checker issues
Mads Kiilerich <madski@unity3d.com>
parents: 23394
diff changeset
   379
            If we pass a directory to commit whose only committable files
18064
7e2b9f6a2cd0 largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents: 17803
diff changeset
   380
            are largefiles, the core commit code aborts before finding
7e2b9f6a2cd0 largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents: 17803
diff changeset
   381
            the largefiles.
7e2b9f6a2cd0 largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents: 17803
diff changeset
   382
            So we do the following:
7e2b9f6a2cd0 largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents: 17803
diff changeset
   383
            For directories that only have largefiles as matches,
18644
3e92772d5383 spelling: fix some minor issues found by spell checker
Mads Kiilerich <mads@kiilerich.com>
parents: 18182
diff changeset
   384
            we explicitly add the largefiles to the match list and remove
18064
7e2b9f6a2cd0 largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents: 17803
diff changeset
   385
            the directory.
7e2b9f6a2cd0 largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents: 17803
diff changeset
   386
            In other cases, we leave the match list unmodified.
45957
89a2afe31e82 formating: upgrade to black 20.8b1
Augie Fackler <raf@durin42.com>
parents: 45106
diff changeset
   387
            """
18064
7e2b9f6a2cd0 largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents: 17803
diff changeset
   388
            actualfiles = []
7e2b9f6a2cd0 largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents: 17803
diff changeset
   389
            dirs = []
7e2b9f6a2cd0 largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents: 17803
diff changeset
   390
            regulars = []
7e2b9f6a2cd0 largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents: 17803
diff changeset
   391
7e2b9f6a2cd0 largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents: 17803
diff changeset
   392
            for f in files:
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   393
                if lfutil.isstandin(f + b'/'):
26587
56b2bcea2529 error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents: 25149
diff changeset
   394
                    raise error.Abort(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   395
                        _(b'file "%s" is a largefile standin') % f,
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   396
                        hint=b'commit the largefile itself instead',
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42930
diff changeset
   397
                    )
18064
7e2b9f6a2cd0 largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents: 17803
diff changeset
   398
                # Scan directories
28716
5c14af475f61 largefiles: replace invocation of os.path module by vfs in reposetup.py
liscju <piotr.listkiewicz@gmail.com>
parents: 27842
diff changeset
   399
                if self.wvfs.isdir(f):
18064
7e2b9f6a2cd0 largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents: 17803
diff changeset
   400
                    dirs.append(f)
7e2b9f6a2cd0 largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents: 17803
diff changeset
   401
                else:
7e2b9f6a2cd0 largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents: 17803
diff changeset
   402
                    regulars.append(f)
7e2b9f6a2cd0 largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents: 17803
diff changeset
   403
7e2b9f6a2cd0 largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents: 17803
diff changeset
   404
            for f in dirs:
7e2b9f6a2cd0 largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents: 17803
diff changeset
   405
                matcheddir = False
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   406
                d = self.dirstate.normalize(f) + b'/'
18064
7e2b9f6a2cd0 largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents: 17803
diff changeset
   407
                # Check for matched normal files
7e2b9f6a2cd0 largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents: 17803
diff changeset
   408
                for mf in regulars:
7e2b9f6a2cd0 largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents: 17803
diff changeset
   409
                    if self.dirstate.normalize(mf).startswith(d):
7e2b9f6a2cd0 largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents: 17803
diff changeset
   410
                        actualfiles.append(f)
7e2b9f6a2cd0 largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents: 17803
diff changeset
   411
                        matcheddir = True
7e2b9f6a2cd0 largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents: 17803
diff changeset
   412
                        break
7e2b9f6a2cd0 largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents: 17803
diff changeset
   413
                if not matcheddir:
7e2b9f6a2cd0 largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents: 17803
diff changeset
   414
                    # If no normal match, manually append
7e2b9f6a2cd0 largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents: 17803
diff changeset
   415
                    # any matching largefiles
7e2b9f6a2cd0 largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents: 17803
diff changeset
   416
                    for lf in lfiles:
7e2b9f6a2cd0 largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents: 17803
diff changeset
   417
                        if self.dirstate.normalize(lf).startswith(d):
7e2b9f6a2cd0 largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents: 17803
diff changeset
   418
                            actualfiles.append(lf)
7e2b9f6a2cd0 largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents: 17803
diff changeset
   419
                            if not matcheddir:
23923
ab6fd3205dad largefiles: fix commit of a directory with no largefile changes (issue4330)
Matt Harbison <matt_harbison@yahoo.com>
parents: 23660
diff changeset
   420
                                # There may still be normal files in the dir, so
24180
d8e0c591781c spelling: fixes from proofreading of spell checker issues
Mads Kiilerich <madski@unity3d.com>
parents: 24163
diff changeset
   421
                                # add a directory to the list, which
24007
240343e13c4d largefiles: update _subdirlfs() comment
Matt Harbison <matt_harbison@yahoo.com>
parents: 23958
diff changeset
   422
                                # forces status/dirstate to walk all files and
240343e13c4d largefiles: update _subdirlfs() comment
Matt Harbison <matt_harbison@yahoo.com>
parents: 23958
diff changeset
   423
                                # call the match function on the matcher, even
24180
d8e0c591781c spelling: fixes from proofreading of spell checker issues
Mads Kiilerich <madski@unity3d.com>
parents: 24163
diff changeset
   424
                                # on case sensitive filesystems.
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   425
                                actualfiles.append(b'.')
18064
7e2b9f6a2cd0 largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents: 17803
diff changeset
   426
                                matcheddir = True
7e2b9f6a2cd0 largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents: 17803
diff changeset
   427
                # Nothing in dir, so readd it
7e2b9f6a2cd0 largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents: 17803
diff changeset
   428
                # and let commit reject it
7e2b9f6a2cd0 largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents: 17803
diff changeset
   429
                if not matcheddir:
7e2b9f6a2cd0 largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents: 17803
diff changeset
   430
                    actualfiles.append(f)
7e2b9f6a2cd0 largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents: 17803
diff changeset
   431
7e2b9f6a2cd0 largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents: 17803
diff changeset
   432
            # Always add normal files
7e2b9f6a2cd0 largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents: 17803
diff changeset
   433
            actualfiles += regulars
7e2b9f6a2cd0 largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents: 17803
diff changeset
   434
            return actualfiles
7e2b9f6a2cd0 largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents: 17803
diff changeset
   435
16247
d87d9d8a8e03 largefiles: remove use of underscores that breaks coding convention
Na'Tosha Bard <natosha@unity3d.com>
parents: 16141
diff changeset
   436
    repo.__class__ = lfilesrepo
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   437
23186
6de61d0b773f largefiles: introduce "_lfcommithooks" to abstract pre-committing procedures
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 23185
diff changeset
   438
    # stack of hooks being executed before committing.
6de61d0b773f largefiles: introduce "_lfcommithooks" to abstract pre-committing procedures
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 23185
diff changeset
   439
    # only last element ("_lfcommithooks[-1]") is used for each committing.
6de61d0b773f largefiles: introduce "_lfcommithooks" to abstract pre-committing procedures
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 23185
diff changeset
   440
    repo._lfcommithooks = [lfutil.updatestandinsbymatch]
6de61d0b773f largefiles: introduce "_lfcommithooks" to abstract pre-committing procedures
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 23185
diff changeset
   441
23188
94ac64bcf6fe largefiles: introduce "_lfstatuswriters" to customize status reporting
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 23186
diff changeset
   442
    # Stack of status writer functions taking "*msg, **opts" arguments
23543
4dd8a6a1240d spelling: fixes from proofreading of spell checker issues
Mads Kiilerich <madski@unity3d.com>
parents: 23394
diff changeset
   443
    # like "ui.status()". Only last element ("_lfstatuswriters[-1]")
23188
94ac64bcf6fe largefiles: introduce "_lfstatuswriters" to customize status reporting
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 23186
diff changeset
   444
    # is used to write status out.
94ac64bcf6fe largefiles: introduce "_lfstatuswriters" to customize status reporting
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 23186
diff changeset
   445
    repo._lfstatuswriters = [ui.status]
94ac64bcf6fe largefiles: introduce "_lfstatuswriters" to customize status reporting
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 23186
diff changeset
   446
28876
79b8f052ee51 localrepo: refactor prepushoutgoinghook to take a pushop
Mads Kiilerich <madski@unity3d.com>
parents: 28716
diff changeset
   447
    def prepushoutgoinghook(pushop):
28878
a75c9665ef06 largefiles: introduce push --lfrev to control which revisions are pushed
Mads Kiilerich <madski@unity3d.com>
parents: 28876
diff changeset
   448
        """Push largefiles for pushop before pushing revisions."""
a75c9665ef06 largefiles: introduce push --lfrev to control which revisions are pushed
Mads Kiilerich <madski@unity3d.com>
parents: 28876
diff changeset
   449
        lfrevs = pushop.lfrevs
a75c9665ef06 largefiles: introduce push --lfrev to control which revisions are pushed
Mads Kiilerich <madski@unity3d.com>
parents: 28876
diff changeset
   450
        if lfrevs is None:
a75c9665ef06 largefiles: introduce push --lfrev to control which revisions are pushed
Mads Kiilerich <madski@unity3d.com>
parents: 28876
diff changeset
   451
            lfrevs = pushop.outgoing.missing
a75c9665ef06 largefiles: introduce push --lfrev to control which revisions are pushed
Mads Kiilerich <madski@unity3d.com>
parents: 28876
diff changeset
   452
        if lfrevs:
21044
52a5eabf1f2f largefiles: reuse "findcommonoutgoing()" result at "hg push"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 21042
diff changeset
   453
            toupload = set()
52a5eabf1f2f largefiles: reuse "findcommonoutgoing()" result at "hg push"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 21042
diff changeset
   454
            addfunc = lambda fn, lfhash: toupload.add(lfhash)
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42930
diff changeset
   455
            lfutil.getlfilestoupload(pushop.repo, lfrevs, addfunc)
28876
79b8f052ee51 localrepo: refactor prepushoutgoinghook to take a pushop
Mads Kiilerich <madski@unity3d.com>
parents: 28716
diff changeset
   456
            lfcommands.uploadlfiles(ui, pushop.repo, pushop.remote, toupload)
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42930
diff changeset
   457
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   458
    repo.prepushoutgoinghooks.add(b"largefiles", prepushoutgoinghook)
21044
52a5eabf1f2f largefiles: reuse "findcommonoutgoing()" result at "hg push"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 21042
diff changeset
   459
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   460
    def checkrequireslfiles(ui, repo, **kwargs):
48686
497c2655c71e largefiles: take lock before writing requirements
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 48444
diff changeset
   461
        with repo.lock():
50522
b4a9c8f18928 store: use StoreEntry API instead of parsing filename in largefile
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 50505
diff changeset
   462
            if b'largefiles' in repo.requirements:
b4a9c8f18928 store: use StoreEntry API instead of parsing filename in largefile
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 50505
diff changeset
   463
                return
b4a9c8f18928 store: use StoreEntry API instead of parsing filename in largefile
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 50505
diff changeset
   464
            marker = lfutil.shortnameslash
50538
862e3a13da44 store: rename `datafiles` to `data_entries`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 50522
diff changeset
   465
            for entry in repo.store.data_entries():
50522
b4a9c8f18928 store: use StoreEntry API instead of parsing filename in largefile
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 50505
diff changeset
   466
                # XXX note that this match is not rooted and can wrongly match
b4a9c8f18928 store: use StoreEntry API instead of parsing filename in largefile
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 50505
diff changeset
   467
                # directory ending with ".hglf"
b4a9c8f18928 store: use StoreEntry API instead of parsing filename in largefile
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 50505
diff changeset
   468
                if entry.is_revlog and marker in entry.target_id:
b4a9c8f18928 store: use StoreEntry API instead of parsing filename in largefile
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 50505
diff changeset
   469
                    repo.requirements.add(b'largefiles')
b4a9c8f18928 store: use StoreEntry API instead of parsing filename in largefile
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 50505
diff changeset
   470
                    scmutil.writereporequirements(repo)
b4a9c8f18928 store: use StoreEntry API instead of parsing filename in largefile
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 50505
diff changeset
   471
                    break
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   472
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42930
diff changeset
   473
    ui.setconfig(
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   474
        b'hooks', b'changegroup.lfiles', checkrequireslfiles, b'largefiles'
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42930
diff changeset
   475
    )
43077
687b865b95ad formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents: 43076
diff changeset
   476
    ui.setconfig(b'hooks', b'commit.lfiles', checkrequireslfiles, b'largefiles')