hgext/largefiles/reposetup.py
author Patrick Mezard <patrick@mezard.eu>
Thu, 29 Mar 2012 16:55:08 +0200
changeset 16314 16ec050490fc
parent 16285 e53c0b2d7b60
child 16571 1ff42ee98446
permissions -rw-r--r--
graphlog: improve --only-branch handling The previous code was correct for command line as opts always contains the default empty lists for --branch and --only-branch options. But calling graphlog.revset() directly with only --only-branch set would leave it unprocessed.
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'''
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    10
import copy
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    11
import types
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    12
import os
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    13
15789
2c10ea43c801 largefiles: Fix parser warning: redefinition of unused 'node' from line 14
Levi Bard <levi@unity3d.com>
parents: 15783
diff changeset
    14
from mercurial import context, error, manifest, match as match_, util
2c10ea43c801 largefiles: Fix parser warning: redefinition of unused 'node' from line 14
Levi Bard <levi@unity3d.com>
parents: 15783
diff changeset
    15
from mercurial import node as node_
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    16
from mercurial.i18n import _
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    17
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    18
import lfcommands
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    19
import proto
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    20
import lfutil
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    21
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    22
def reposetup(ui, repo):
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    23
    # wire repositories should be given new wireproto functions but not the
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    24
    # other largefiles modifications
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    25
    if not repo.local():
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    26
        return proto.wirereposetup(ui, repo)
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    27
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    28
    for name in ('status', 'commitctx', 'commit', 'push'):
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    29
        method = getattr(repo, name)
15255
7ab05d752405 largefiles: cosmetics, whitespace, code style
Greg Ward <greg@gerg.ca>
parents: 15254
diff changeset
    30
        if (isinstance(method, types.FunctionType) and
7ab05d752405 largefiles: cosmetics, whitespace, code style
Greg Ward <greg@gerg.ca>
parents: 15254
diff changeset
    31
            method.func_name == 'wrap'):
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    32
            ui.warn(_('largefiles: repo method %r appears to have already been'
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    33
                    ' wrapped by another extension: '
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    34
                    'largefiles may behave incorrectly\n')
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    35
                    % name)
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    36
16247
d87d9d8a8e03 largefiles: remove use of underscores that breaks coding convention
Na'Tosha Bard <natosha@unity3d.com>
parents: 16141
diff changeset
    37
    class lfilesrepo(repo.__class__):
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    38
        lfstatus = False
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    39
        def status_nolfiles(self, *args, **kwargs):
16247
d87d9d8a8e03 largefiles: remove use of underscores that breaks coding convention
Na'Tosha Bard <natosha@unity3d.com>
parents: 16141
diff changeset
    40
            return super(lfilesrepo, self).status(*args, **kwargs)
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    41
15252
6e809bb4f969 largefiles: improve comments, internal docstrings
Greg Ward <greg@gerg.ca>
parents: 15250
diff changeset
    42
        # 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
    43
        # of largefiles instead of their corresponding standins and
6e809bb4f969 largefiles: improve comments, internal docstrings
Greg Ward <greg@gerg.ca>
parents: 15250
diff changeset
    44
        # identifies the largefiles as always binary, regardless of
6e809bb4f969 largefiles: improve comments, internal docstrings
Greg Ward <greg@gerg.ca>
parents: 15250
diff changeset
    45
        # their actual contents.
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    46
        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
    47
            ctx = super(lfilesrepo, self).__getitem__(changeid)
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    48
            if self.lfstatus:
16247
d87d9d8a8e03 largefiles: remove use of underscores that breaks coding convention
Na'Tosha Bard <natosha@unity3d.com>
parents: 16141
diff changeset
    49
                class lfilesmanifestdict(manifest.manifestdict):
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    50
                    def __contains__(self, filename):
16247
d87d9d8a8e03 largefiles: remove use of underscores that breaks coding convention
Na'Tosha Bard <natosha@unity3d.com>
parents: 16141
diff changeset
    51
                        if super(lfilesmanifestdict,
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    52
                                self).__contains__(filename):
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    53
                            return True
16247
d87d9d8a8e03 largefiles: remove use of underscores that breaks coding convention
Na'Tosha Bard <natosha@unity3d.com>
parents: 16141
diff changeset
    54
                        return super(lfilesmanifestdict,
15628
2b40513384ca largefiles: use lfutil functions
Martin Geisler <mg@aragost.com>
parents: 15626
diff changeset
    55
                            self).__contains__(lfutil.standin(filename))
16247
d87d9d8a8e03 largefiles: remove use of underscores that breaks coding convention
Na'Tosha Bard <natosha@unity3d.com>
parents: 16141
diff changeset
    56
                class lfilesctx(ctx.__class__):
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    57
                    def files(self):
16247
d87d9d8a8e03 largefiles: remove use of underscores that breaks coding convention
Na'Tosha Bard <natosha@unity3d.com>
parents: 16141
diff changeset
    58
                        filenames = super(lfilesctx, self).files()
15628
2b40513384ca largefiles: use lfutil functions
Martin Geisler <mg@aragost.com>
parents: 15626
diff changeset
    59
                        return [lfutil.splitstandin(f) or f for f in filenames]
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    60
                    def manifest(self):
16247
d87d9d8a8e03 largefiles: remove use of underscores that breaks coding convention
Na'Tosha Bard <natosha@unity3d.com>
parents: 16141
diff changeset
    61
                        man1 = super(lfilesctx, self).manifest()
d87d9d8a8e03 largefiles: remove use of underscores that breaks coding convention
Na'Tosha Bard <natosha@unity3d.com>
parents: 16141
diff changeset
    62
                        man1.__class__ = lfilesmanifestdict
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    63
                        return man1
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    64
                    def filectx(self, path, fileid=None, filelog=None):
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    65
                        try:
16141
f346de4dff57 largefiles: don't break filesets
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 16110
diff changeset
    66
                            if filelog is not None:
16247
d87d9d8a8e03 largefiles: remove use of underscores that breaks coding convention
Na'Tosha Bard <natosha@unity3d.com>
parents: 16141
diff changeset
    67
                                result = super(lfilesctx, self).filectx(
16141
f346de4dff57 largefiles: don't break filesets
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 16110
diff changeset
    68
                                    path, fileid, filelog)
f346de4dff57 largefiles: don't break filesets
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 16110
diff changeset
    69
                            else:
16247
d87d9d8a8e03 largefiles: remove use of underscores that breaks coding convention
Na'Tosha Bard <natosha@unity3d.com>
parents: 16141
diff changeset
    70
                                result = super(lfilesctx, self).filectx(
16141
f346de4dff57 largefiles: don't break filesets
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 16110
diff changeset
    71
                                    path, fileid)
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    72
                        except error.LookupError:
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    73
                            # Adding a null character will cause Mercurial to
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    74
                            # identify this as a binary file.
16141
f346de4dff57 largefiles: don't break filesets
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 16110
diff changeset
    75
                            if filelog is not None:
16247
d87d9d8a8e03 largefiles: remove use of underscores that breaks coding convention
Na'Tosha Bard <natosha@unity3d.com>
parents: 16141
diff changeset
    76
                                result = super(lfilesctx, self).filectx(
16141
f346de4dff57 largefiles: don't break filesets
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 16110
diff changeset
    77
                                    lfutil.standin(path), fileid, filelog)
f346de4dff57 largefiles: don't break filesets
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 16110
diff changeset
    78
                            else:
16247
d87d9d8a8e03 largefiles: remove use of underscores that breaks coding convention
Na'Tosha Bard <natosha@unity3d.com>
parents: 16141
diff changeset
    79
                                result = super(lfilesctx, self).filectx(
16141
f346de4dff57 largefiles: don't break filesets
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 16110
diff changeset
    80
                                    lfutil.standin(path), fileid)
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    81
                            olddata = result.data
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    82
                            result.data = lambda: olddata() + '\0'
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    83
                        return result
16247
d87d9d8a8e03 largefiles: remove use of underscores that breaks coding convention
Na'Tosha Bard <natosha@unity3d.com>
parents: 16141
diff changeset
    84
                ctx.__class__ = lfilesctx
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    85
            return ctx
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    86
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    87
        # 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
    88
        # appropriate list in the result. Also removes standin files
6e809bb4f969 largefiles: improve comments, internal docstrings
Greg Ward <greg@gerg.ca>
parents: 15250
diff changeset
    89
        # from the listing. Revert to the original status if
6e809bb4f969 largefiles: improve comments, internal docstrings
Greg Ward <greg@gerg.ca>
parents: 15250
diff changeset
    90
        # self.lfstatus is False.
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    91
        def status(self, node1='.', node2=None, match=None, ignored=False,
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    92
                clean=False, unknown=False, listsubrepos=False):
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    93
            listignored, listclean, listunknown = ignored, clean, unknown
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    94
            if not self.lfstatus:
16247
d87d9d8a8e03 largefiles: remove use of underscores that breaks coding convention
Na'Tosha Bard <natosha@unity3d.com>
parents: 16141
diff changeset
    95
                return super(lfilesrepo, self).status(node1, node2, match,
15626
931dc4af0d95 largefiles: remove pre-1.7 compatibility code
Martin Geisler <mg@aragost.com>
parents: 15617
diff changeset
    96
                    listignored, listclean, listunknown, listsubrepos)
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    97
            else:
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    98
                # some calls in this function rely on the old version of status
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    99
                self.lfstatus = False
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   100
                if isinstance(node1, context.changectx):
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   101
                    ctx1 = node1
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   102
                else:
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   103
                    ctx1 = repo[node1]
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   104
                if isinstance(node2, context.changectx):
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   105
                    ctx2 = node2
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   106
                else:
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   107
                    ctx2 = repo[node2]
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   108
                working = ctx2.rev() is None
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   109
                parentworking = working and ctx1 == self['.']
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   110
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   111
                def inctx(file, ctx):
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   112
                    try:
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   113
                        if ctx.rev() is None:
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   114
                            return file in ctx.manifest()
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   115
                        ctx[file]
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   116
                        return True
15171
547da6115d1d largefiles: eliminate naked exceptions
Matt Mackall <mpm@selenic.com>
parents: 15170
diff changeset
   117
                    except KeyError:
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   118
                        return False
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   119
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   120
                if match is None:
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   121
                    match = match_.always(self.root, self.getcwd())
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   122
15653
93c77d5b9752 largefiles: optimize status when files are specified (issue3144)
Na'Tosha Bard <natosha@unity3d.com>
parents: 15630
diff changeset
   123
                # First check if there were files specified on the
93c77d5b9752 largefiles: optimize status when files are specified (issue3144)
Na'Tosha Bard <natosha@unity3d.com>
parents: 15630
diff changeset
   124
                # command line.  If there were, and none of them were
93c77d5b9752 largefiles: optimize status when files are specified (issue3144)
Na'Tosha Bard <natosha@unity3d.com>
parents: 15630
diff changeset
   125
                # largefiles, we should just bail here and let super
93c77d5b9752 largefiles: optimize status when files are specified (issue3144)
Na'Tosha Bard <natosha@unity3d.com>
parents: 15630
diff changeset
   126
                # handle it -- thus gaining a big performance boost.
93c77d5b9752 largefiles: optimize status when files are specified (issue3144)
Na'Tosha Bard <natosha@unity3d.com>
parents: 15630
diff changeset
   127
                lfdirstate = lfutil.openlfdirstate(ui, self)
93c77d5b9752 largefiles: optimize status when files are specified (issue3144)
Na'Tosha Bard <natosha@unity3d.com>
parents: 15630
diff changeset
   128
                if match.files() and not match.anypats():
16110
41417443b7d0 largefiles: check whether specified patterns are related to largefiles strictly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 15982
diff changeset
   129
                    for f in lfdirstate:
41417443b7d0 largefiles: check whether specified patterns are related to largefiles strictly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 15982
diff changeset
   130
                        if match(f):
41417443b7d0 largefiles: check whether specified patterns are related to largefiles strictly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 15982
diff changeset
   131
                            break
41417443b7d0 largefiles: check whether specified patterns are related to largefiles strictly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 15982
diff changeset
   132
                    else:
16247
d87d9d8a8e03 largefiles: remove use of underscores that breaks coding convention
Na'Tosha Bard <natosha@unity3d.com>
parents: 16141
diff changeset
   133
                        return super(lfilesrepo, self).status(node1, node2,
15653
93c77d5b9752 largefiles: optimize status when files are specified (issue3144)
Na'Tosha Bard <natosha@unity3d.com>
parents: 15630
diff changeset
   134
                                match, listignored, listclean,
93c77d5b9752 largefiles: optimize status when files are specified (issue3144)
Na'Tosha Bard <natosha@unity3d.com>
parents: 15630
diff changeset
   135
                                listunknown, listsubrepos)
93c77d5b9752 largefiles: optimize status when files are specified (issue3144)
Na'Tosha Bard <natosha@unity3d.com>
parents: 15630
diff changeset
   136
15254
dd03d3a9f888 largefiles: more work on cleaning up comments
Greg Ward <greg@gerg.ca>
parents: 15253
diff changeset
   137
                # Create a copy of match that matches standins instead
dd03d3a9f888 largefiles: more work on cleaning up comments
Greg Ward <greg@gerg.ca>
parents: 15253
diff changeset
   138
                # of largefiles.
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   139
                def tostandin(file):
16282
50247a7a9983 largefiles: use 'dirstate.dirs()' for 'directory pattern' relation check
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16281
diff changeset
   140
                    if working:
50247a7a9983 largefiles: use 'dirstate.dirs()' for 'directory pattern' relation check
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16281
diff changeset
   141
                        sf = lfutil.standin(file)
50247a7a9983 largefiles: use 'dirstate.dirs()' for 'directory pattern' relation check
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16281
diff changeset
   142
                        dirstate = repo.dirstate
50247a7a9983 largefiles: use 'dirstate.dirs()' for 'directory pattern' relation check
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16281
diff changeset
   143
                        if sf in dirstate or sf in dirstate.dirs():
50247a7a9983 largefiles: use 'dirstate.dirs()' for 'directory pattern' relation check
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16281
diff changeset
   144
                            return sf
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   145
                    return file
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   146
15617
74e691b141c4 largefiles: optimize performance of status on largefiles repos (issue3136)
Na'Tosha Bard <natosha@unity3d.com>
parents: 15385
diff changeset
   147
                # Create a function that we can use to override what is
74e691b141c4 largefiles: optimize performance of status on largefiles repos (issue3136)
Na'Tosha Bard <natosha@unity3d.com>
parents: 15385
diff changeset
   148
                # normally the ignore matcher.  We've already checked
74e691b141c4 largefiles: optimize performance of status on largefiles repos (issue3136)
Na'Tosha Bard <natosha@unity3d.com>
parents: 15385
diff changeset
   149
                # for ignored files on the first dirstate walk, and
74e691b141c4 largefiles: optimize performance of status on largefiles repos (issue3136)
Na'Tosha Bard <natosha@unity3d.com>
parents: 15385
diff changeset
   150
                # unecessarily re-checking here causes a huge performance
74e691b141c4 largefiles: optimize performance of status on largefiles repos (issue3136)
Na'Tosha Bard <natosha@unity3d.com>
parents: 15385
diff changeset
   151
                # hit because lfdirstate only knows about largefiles
74e691b141c4 largefiles: optimize performance of status on largefiles repos (issue3136)
Na'Tosha Bard <natosha@unity3d.com>
parents: 15385
diff changeset
   152
                def _ignoreoverride(self):
74e691b141c4 largefiles: optimize performance of status on largefiles repos (issue3136)
Na'Tosha Bard <natosha@unity3d.com>
parents: 15385
diff changeset
   153
                    return False
74e691b141c4 largefiles: optimize performance of status on largefiles repos (issue3136)
Na'Tosha Bard <natosha@unity3d.com>
parents: 15385
diff changeset
   154
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   155
                m = copy.copy(match)
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   156
                m._files = [tostandin(f) for f in m._files]
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   157
15617
74e691b141c4 largefiles: optimize performance of status on largefiles repos (issue3136)
Na'Tosha Bard <natosha@unity3d.com>
parents: 15385
diff changeset
   158
                # Get ignored files here even if we weren't asked for them; we
74e691b141c4 largefiles: optimize performance of status on largefiles repos (issue3136)
Na'Tosha Bard <natosha@unity3d.com>
parents: 15385
diff changeset
   159
                # must use the result here for filtering later
16247
d87d9d8a8e03 largefiles: remove use of underscores that breaks coding convention
Na'Tosha Bard <natosha@unity3d.com>
parents: 16141
diff changeset
   160
                result = super(lfilesrepo, self).status(node1, node2, m,
15626
931dc4af0d95 largefiles: remove pre-1.7 compatibility code
Martin Geisler <mg@aragost.com>
parents: 15617
diff changeset
   161
                    True, clean, unknown, listsubrepos)
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   162
                if working:
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   163
                    try:
15252
6e809bb4f969 largefiles: improve comments, internal docstrings
Greg Ward <greg@gerg.ca>
parents: 15250
diff changeset
   164
                        # Any non-largefiles that were explicitly listed must be
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   165
                        # taken out or lfdirstate.status will report an error.
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   166
                        # The status of these files was already computed using
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   167
                        # super's status.
15617
74e691b141c4 largefiles: optimize performance of status on largefiles repos (issue3136)
Na'Tosha Bard <natosha@unity3d.com>
parents: 15385
diff changeset
   168
                        # Override lfdirstate's ignore matcher to not do
74e691b141c4 largefiles: optimize performance of status on largefiles repos (issue3136)
Na'Tosha Bard <natosha@unity3d.com>
parents: 15385
diff changeset
   169
                        # anything
16247
d87d9d8a8e03 largefiles: remove use of underscores that breaks coding convention
Na'Tosha Bard <natosha@unity3d.com>
parents: 16141
diff changeset
   170
                        origignore = lfdirstate._ignore
15617
74e691b141c4 largefiles: optimize performance of status on largefiles repos (issue3136)
Na'Tosha Bard <natosha@unity3d.com>
parents: 15385
diff changeset
   171
                        lfdirstate._ignore = _ignoreoverride
74e691b141c4 largefiles: optimize performance of status on largefiles repos (issue3136)
Na'Tosha Bard <natosha@unity3d.com>
parents: 15385
diff changeset
   172
16282
50247a7a9983 largefiles: use 'dirstate.dirs()' for 'directory pattern' relation check
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16281
diff changeset
   173
                        def sfindirstate(f):
50247a7a9983 largefiles: use 'dirstate.dirs()' for 'directory pattern' relation check
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16281
diff changeset
   174
                            sf = lfutil.standin(f)
50247a7a9983 largefiles: use 'dirstate.dirs()' for 'directory pattern' relation check
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16281
diff changeset
   175
                            dirstate = repo.dirstate
50247a7a9983 largefiles: use 'dirstate.dirs()' for 'directory pattern' relation check
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16281
diff changeset
   176
                            return sf in dirstate or sf in dirstate.dirs()
50247a7a9983 largefiles: use 'dirstate.dirs()' for 'directory pattern' relation check
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16281
diff changeset
   177
                        match._files = [f for f in match._files
50247a7a9983 largefiles: use 'dirstate.dirs()' for 'directory pattern' relation check
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16281
diff changeset
   178
                                        if sfindirstate(f)]
15617
74e691b141c4 largefiles: optimize performance of status on largefiles repos (issue3136)
Na'Tosha Bard <natosha@unity3d.com>
parents: 15385
diff changeset
   179
                        # Don't waste time getting the ignored and unknown
74e691b141c4 largefiles: optimize performance of status on largefiles repos (issue3136)
Na'Tosha Bard <natosha@unity3d.com>
parents: 15385
diff changeset
   180
                        # files again; we already have them
74e691b141c4 largefiles: optimize performance of status on largefiles repos (issue3136)
Na'Tosha Bard <natosha@unity3d.com>
parents: 15385
diff changeset
   181
                        s = lfdirstate.status(match, [], False,
74e691b141c4 largefiles: optimize performance of status on largefiles repos (issue3136)
Na'Tosha Bard <natosha@unity3d.com>
parents: 15385
diff changeset
   182
                                listclean, False)
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   183
                        (unsure, modified, added, removed, missing, unknown,
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   184
                                ignored, clean) = s
15617
74e691b141c4 largefiles: optimize performance of status on largefiles repos (issue3136)
Na'Tosha Bard <natosha@unity3d.com>
parents: 15385
diff changeset
   185
                        # Replace the list of ignored and unknown files with
74e691b141c4 largefiles: optimize performance of status on largefiles repos (issue3136)
Na'Tosha Bard <natosha@unity3d.com>
parents: 15385
diff changeset
   186
                        # the previously caclulated lists, and strip out the
74e691b141c4 largefiles: optimize performance of status on largefiles repos (issue3136)
Na'Tosha Bard <natosha@unity3d.com>
parents: 15385
diff changeset
   187
                        # largefiles
74e691b141c4 largefiles: optimize performance of status on largefiles repos (issue3136)
Na'Tosha Bard <natosha@unity3d.com>
parents: 15385
diff changeset
   188
                        lfiles = set(lfdirstate._map)
74e691b141c4 largefiles: optimize performance of status on largefiles repos (issue3136)
Na'Tosha Bard <natosha@unity3d.com>
parents: 15385
diff changeset
   189
                        ignored = set(result[5]).difference(lfiles)
74e691b141c4 largefiles: optimize performance of status on largefiles repos (issue3136)
Na'Tosha Bard <natosha@unity3d.com>
parents: 15385
diff changeset
   190
                        unknown = set(result[4]).difference(lfiles)
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   191
                        if parentworking:
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   192
                            for lfile in unsure:
15629
5b66e55c0d93 largefiles: fix 'hg status' abort after merge
Martin Geisler <mg@aragost.com>
parents: 15385
diff changeset
   193
                                standin = lfutil.standin(lfile)
5b66e55c0d93 largefiles: fix 'hg status' abort after merge
Martin Geisler <mg@aragost.com>
parents: 15385
diff changeset
   194
                                if standin not in ctx1:
5b66e55c0d93 largefiles: fix 'hg status' abort after merge
Martin Geisler <mg@aragost.com>
parents: 15385
diff changeset
   195
                                    # from second parent
5b66e55c0d93 largefiles: fix 'hg status' abort after merge
Martin Geisler <mg@aragost.com>
parents: 15385
diff changeset
   196
                                    modified.append(lfile)
5b66e55c0d93 largefiles: fix 'hg status' abort after merge
Martin Geisler <mg@aragost.com>
parents: 15385
diff changeset
   197
                                elif ctx1[standin].data().strip() \
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   198
                                        != lfutil.hashfile(self.wjoin(lfile)):
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   199
                                    modified.append(lfile)
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   200
                                else:
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   201
                                    clean.append(lfile)
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   202
                                    lfdirstate.normal(lfile)
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   203
                        else:
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   204
                            tocheck = unsure + modified + added + clean
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   205
                            modified, added, clean = [], [], []
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   206
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   207
                            for lfile in tocheck:
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   208
                                standin = lfutil.standin(lfile)
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   209
                                if inctx(standin, ctx1):
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   210
                                    if ctx1[standin].data().strip() != \
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   211
                                            lfutil.hashfile(self.wjoin(lfile)):
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   212
                                        modified.append(lfile)
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   213
                                    else:
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   214
                                        clean.append(lfile)
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   215
                                else:
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   216
                                    added.append(lfile)
15794
0d91211dd12f largefiles: fix inappropriate locking (issue3182)
Levi Bard <levi@unity3d.com>
parents: 15793
diff changeset
   217
                    finally:
15617
74e691b141c4 largefiles: optimize performance of status on largefiles repos (issue3136)
Na'Tosha Bard <natosha@unity3d.com>
parents: 15385
diff changeset
   218
                        # Replace the original ignore function
16247
d87d9d8a8e03 largefiles: remove use of underscores that breaks coding convention
Na'Tosha Bard <natosha@unity3d.com>
parents: 16141
diff changeset
   219
                        lfdirstate._ignore = origignore
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   220
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   221
                    for standin in ctx1.manifest():
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   222
                        if not lfutil.isstandin(standin):
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   223
                            continue
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   224
                        lfile = lfutil.splitstandin(standin)
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   225
                        if not match(lfile):
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   226
                            continue
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   227
                        if lfile not in lfdirstate:
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   228
                            removed.append(lfile)
15663
9036c7d106bf largefiles: handle merges between normal files and largefiles (issue3084)
Martin Geisler <mg@aragost.com>
parents: 15629
diff changeset
   229
9036c7d106bf largefiles: handle merges between normal files and largefiles (issue3084)
Martin Geisler <mg@aragost.com>
parents: 15629
diff changeset
   230
                    # Filter result lists
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   231
                    result = list(result)
15663
9036c7d106bf largefiles: handle merges between normal files and largefiles (issue3084)
Martin Geisler <mg@aragost.com>
parents: 15629
diff changeset
   232
9036c7d106bf largefiles: handle merges between normal files and largefiles (issue3084)
Martin Geisler <mg@aragost.com>
parents: 15629
diff changeset
   233
                    # Largefiles are not really removed when they're
9036c7d106bf largefiles: handle merges between normal files and largefiles (issue3084)
Martin Geisler <mg@aragost.com>
parents: 15629
diff changeset
   234
                    # still in the normal dirstate. Likewise, normal
9036c7d106bf largefiles: handle merges between normal files and largefiles (issue3084)
Martin Geisler <mg@aragost.com>
parents: 15629
diff changeset
   235
                    # files are not really removed if it's still in
9036c7d106bf largefiles: handle merges between normal files and largefiles (issue3084)
Martin Geisler <mg@aragost.com>
parents: 15629
diff changeset
   236
                    # lfdirstate. This happens in merges where files
9036c7d106bf largefiles: handle merges between normal files and largefiles (issue3084)
Martin Geisler <mg@aragost.com>
parents: 15629
diff changeset
   237
                    # change type.
9036c7d106bf largefiles: handle merges between normal files and largefiles (issue3084)
Martin Geisler <mg@aragost.com>
parents: 15629
diff changeset
   238
                    removed = [f for f in removed if f not in repo.dirstate]
9036c7d106bf largefiles: handle merges between normal files and largefiles (issue3084)
Martin Geisler <mg@aragost.com>
parents: 15629
diff changeset
   239
                    result[2] = [f for f in result[2] if f not in lfdirstate]
9036c7d106bf largefiles: handle merges between normal files and largefiles (issue3084)
Martin Geisler <mg@aragost.com>
parents: 15629
diff changeset
   240
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   241
                    # Unknown files
15617
74e691b141c4 largefiles: optimize performance of status on largefiles repos (issue3136)
Na'Tosha Bard <natosha@unity3d.com>
parents: 15385
diff changeset
   242
                    unknown = set(unknown).difference(ignored)
15255
7ab05d752405 largefiles: cosmetics, whitespace, code style
Greg Ward <greg@gerg.ca>
parents: 15254
diff changeset
   243
                    result[4] = [f for f in unknown
7ab05d752405 largefiles: cosmetics, whitespace, code style
Greg Ward <greg@gerg.ca>
parents: 15254
diff changeset
   244
                                 if (repo.dirstate[f] == '?' and
7ab05d752405 largefiles: cosmetics, whitespace, code style
Greg Ward <greg@gerg.ca>
parents: 15254
diff changeset
   245
                                     not lfutil.isstandin(f))]
15617
74e691b141c4 largefiles: optimize performance of status on largefiles repos (issue3136)
Na'Tosha Bard <natosha@unity3d.com>
parents: 15385
diff changeset
   246
                    # Ignored files were calculated earlier by the dirstate,
74e691b141c4 largefiles: optimize performance of status on largefiles repos (issue3136)
Na'Tosha Bard <natosha@unity3d.com>
parents: 15385
diff changeset
   247
                    # and we already stripped out the largefiles from the list
74e691b141c4 largefiles: optimize performance of status on largefiles repos (issue3136)
Na'Tosha Bard <natosha@unity3d.com>
parents: 15385
diff changeset
   248
                    result[5] = ignored
15254
dd03d3a9f888 largefiles: more work on cleaning up comments
Greg Ward <greg@gerg.ca>
parents: 15253
diff changeset
   249
                    # combine normal files and largefiles
15255
7ab05d752405 largefiles: cosmetics, whitespace, code style
Greg Ward <greg@gerg.ca>
parents: 15254
diff changeset
   250
                    normals = [[fn for fn in filelist
7ab05d752405 largefiles: cosmetics, whitespace, code style
Greg Ward <greg@gerg.ca>
parents: 15254
diff changeset
   251
                                if not lfutil.isstandin(fn)]
7ab05d752405 largefiles: cosmetics, whitespace, code style
Greg Ward <greg@gerg.ca>
parents: 15254
diff changeset
   252
                               for filelist in result]
15663
9036c7d106bf largefiles: handle merges between normal files and largefiles (issue3084)
Martin Geisler <mg@aragost.com>
parents: 15629
diff changeset
   253
                    lfiles = (modified, added, removed, missing, [], [], clean)
15255
7ab05d752405 largefiles: cosmetics, whitespace, code style
Greg Ward <greg@gerg.ca>
parents: 15254
diff changeset
   254
                    result = [sorted(list1 + list2)
7ab05d752405 largefiles: cosmetics, whitespace, code style
Greg Ward <greg@gerg.ca>
parents: 15254
diff changeset
   255
                              for (list1, list2) in zip(normals, lfiles)]
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   256
                else:
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   257
                    def toname(f):
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   258
                        if lfutil.isstandin(f):
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   259
                            return lfutil.splitstandin(f)
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   260
                        return f
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   261
                    result = [[toname(f) for f in items] for items in result]
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   262
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   263
                if not listunknown:
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   264
                    result[4] = []
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   265
                if not listignored:
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   266
                    result[5] = []
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   267
                if not listclean:
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   268
                    result[6] = []
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   269
                self.lfstatus = True
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   270
                return result
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   271
15254
dd03d3a9f888 largefiles: more work on cleaning up comments
Greg Ward <greg@gerg.ca>
parents: 15253
diff changeset
   272
        # As part of committing, copy all of the largefiles into the
dd03d3a9f888 largefiles: more work on cleaning up comments
Greg Ward <greg@gerg.ca>
parents: 15253
diff changeset
   273
        # cache.
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   274
        def commitctx(self, *args, **kwargs):
16247
d87d9d8a8e03 largefiles: remove use of underscores that breaks coding convention
Na'Tosha Bard <natosha@unity3d.com>
parents: 16141
diff changeset
   275
            node = super(lfilesrepo, self).commitctx(*args, **kwargs)
15796
3e5b6045ccfc largefiles: factor out a copyalltostore() function
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 15794
diff changeset
   276
            lfutil.copyalltostore(self, node)
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   277
            return node
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   278
15254
dd03d3a9f888 largefiles: more work on cleaning up comments
Greg Ward <greg@gerg.ca>
parents: 15253
diff changeset
   279
        # 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
   280
        # 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
   281
        # Do that here.
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   282
        def commit(self, text="", user=None, date=None, match=None,
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   283
                force=False, editor=False, extra={}):
16247
d87d9d8a8e03 largefiles: remove use of underscores that breaks coding convention
Na'Tosha Bard <natosha@unity3d.com>
parents: 16141
diff changeset
   284
            orig = super(lfilesrepo, self).commit
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   285
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   286
            wlock = repo.wlock()
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   287
            try:
15982
bf502ccc46d7 largefiles: fix transplant for all cases (issue3192)
Na'Tosha Bard <natosha@unity3d.com>
parents: 15796
diff changeset
   288
                # Case 0: Rebase or Transplant
15793
3ef07ecdb0d5 largefiles: correctly handle dirstate status when rebasing
Na'Tosha Bard <natosha@unity3d.com>
parents: 15789
diff changeset
   289
                # We have to take the time to pull down the new largefiles now.
15982
bf502ccc46d7 largefiles: fix transplant for all cases (issue3192)
Na'Tosha Bard <natosha@unity3d.com>
parents: 15796
diff changeset
   290
                # Otherwise, any largefiles that were modified in the
bf502ccc46d7 largefiles: fix transplant for all cases (issue3192)
Na'Tosha Bard <natosha@unity3d.com>
parents: 15796
diff changeset
   291
                # destination changesets get overwritten, either by the rebase
bf502ccc46d7 largefiles: fix transplant for all cases (issue3192)
Na'Tosha Bard <natosha@unity3d.com>
parents: 15796
diff changeset
   292
                # or in the first commit after the rebase or transplant.
15793
3ef07ecdb0d5 largefiles: correctly handle dirstate status when rebasing
Na'Tosha Bard <natosha@unity3d.com>
parents: 15789
diff changeset
   293
                # updatelfiles will update the dirstate to mark any pulled
3ef07ecdb0d5 largefiles: correctly handle dirstate status when rebasing
Na'Tosha Bard <natosha@unity3d.com>
parents: 15789
diff changeset
   294
                # largefiles as modified
15982
bf502ccc46d7 largefiles: fix transplant for all cases (issue3192)
Na'Tosha Bard <natosha@unity3d.com>
parents: 15796
diff changeset
   295
                if getattr(repo, "_isrebasing", False) or \
bf502ccc46d7 largefiles: fix transplant for all cases (issue3192)
Na'Tosha Bard <natosha@unity3d.com>
parents: 15796
diff changeset
   296
                        getattr(repo, "_istransplanting", False):
bf502ccc46d7 largefiles: fix transplant for all cases (issue3192)
Na'Tosha Bard <natosha@unity3d.com>
parents: 15796
diff changeset
   297
                    lfcommands.updatelfiles(repo.ui, repo, filelist=None,
bf502ccc46d7 largefiles: fix transplant for all cases (issue3192)
Na'Tosha Bard <natosha@unity3d.com>
parents: 15796
diff changeset
   298
                                            printmessage=False)
15793
3ef07ecdb0d5 largefiles: correctly handle dirstate status when rebasing
Na'Tosha Bard <natosha@unity3d.com>
parents: 15789
diff changeset
   299
                    result = orig(text=text, user=user, date=date, match=match,
3ef07ecdb0d5 largefiles: correctly handle dirstate status when rebasing
Na'Tosha Bard <natosha@unity3d.com>
parents: 15789
diff changeset
   300
                                    force=force, editor=editor, extra=extra)
3ef07ecdb0d5 largefiles: correctly handle dirstate status when rebasing
Na'Tosha Bard <natosha@unity3d.com>
parents: 15789
diff changeset
   301
                    return result
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   302
                # Case 1: user calls commit with no specific files or
15250
f172292cd416 largefiles: speed up commit by only rewriting standins for modified largefiles
Na'Tosha Bard <natosha@unity3d.com>
parents: 15224
diff changeset
   303
                # include/exclude patterns: refresh and commit all files that
f172292cd416 largefiles: speed up commit by only rewriting standins for modified largefiles
Na'Tosha Bard <natosha@unity3d.com>
parents: 15224
diff changeset
   304
                # are "dirty".
15255
7ab05d752405 largefiles: cosmetics, whitespace, code style
Greg Ward <greg@gerg.ca>
parents: 15254
diff changeset
   305
                if ((match is None) or
7ab05d752405 largefiles: cosmetics, whitespace, code style
Greg Ward <greg@gerg.ca>
parents: 15254
diff changeset
   306
                    (not match.anypats() and not match.files())):
15250
f172292cd416 largefiles: speed up commit by only rewriting standins for modified largefiles
Na'Tosha Bard <natosha@unity3d.com>
parents: 15224
diff changeset
   307
                    # Spend a bit of time here to get a list of files we know
f172292cd416 largefiles: speed up commit by only rewriting standins for modified largefiles
Na'Tosha Bard <natosha@unity3d.com>
parents: 15224
diff changeset
   308
                    # are modified so we can compare only against those.
f172292cd416 largefiles: speed up commit by only rewriting standins for modified largefiles
Na'Tosha Bard <natosha@unity3d.com>
parents: 15224
diff changeset
   309
                    # It can cost a lot of time (several seconds)
f172292cd416 largefiles: speed up commit by only rewriting standins for modified largefiles
Na'Tosha Bard <natosha@unity3d.com>
parents: 15224
diff changeset
   310
                    # otherwise to update all standins if the largefiles are
f172292cd416 largefiles: speed up commit by only rewriting standins for modified largefiles
Na'Tosha Bard <natosha@unity3d.com>
parents: 15224
diff changeset
   311
                    # large.
f172292cd416 largefiles: speed up commit by only rewriting standins for modified largefiles
Na'Tosha Bard <natosha@unity3d.com>
parents: 15224
diff changeset
   312
                    lfdirstate = lfutil.openlfdirstate(ui, self)
f172292cd416 largefiles: speed up commit by only rewriting standins for modified largefiles
Na'Tosha Bard <natosha@unity3d.com>
parents: 15224
diff changeset
   313
                    dirtymatch = match_.always(repo.root, repo.getcwd())
f172292cd416 largefiles: speed up commit by only rewriting standins for modified largefiles
Na'Tosha Bard <natosha@unity3d.com>
parents: 15224
diff changeset
   314
                    s = lfdirstate.status(dirtymatch, [], False, False, False)
f172292cd416 largefiles: speed up commit by only rewriting standins for modified largefiles
Na'Tosha Bard <natosha@unity3d.com>
parents: 15224
diff changeset
   315
                    modifiedfiles = []
f172292cd416 largefiles: speed up commit by only rewriting standins for modified largefiles
Na'Tosha Bard <natosha@unity3d.com>
parents: 15224
diff changeset
   316
                    for i in s:
f172292cd416 largefiles: speed up commit by only rewriting standins for modified largefiles
Na'Tosha Bard <natosha@unity3d.com>
parents: 15224
diff changeset
   317
                        modifiedfiles.extend(i)
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   318
                    lfiles = lfutil.listlfiles(self)
15254
dd03d3a9f888 largefiles: more work on cleaning up comments
Greg Ward <greg@gerg.ca>
parents: 15253
diff changeset
   319
                    # this only loops through largefiles that exist (not
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   320
                    # removed/renamed)
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   321
                    for lfile in lfiles:
15250
f172292cd416 largefiles: speed up commit by only rewriting standins for modified largefiles
Na'Tosha Bard <natosha@unity3d.com>
parents: 15224
diff changeset
   322
                        if lfile in modifiedfiles:
16248
51e6f318bdf1 largefiles: fix check-code errors.
Na'Tosha Bard <natosha@unity3d.com>
parents: 16247
diff changeset
   323
                            if os.path.exists(
51e6f318bdf1 largefiles: fix check-code errors.
Na'Tosha Bard <natosha@unity3d.com>
parents: 16247
diff changeset
   324
                                    self.wjoin(lfutil.standin(lfile))):
15250
f172292cd416 largefiles: speed up commit by only rewriting standins for modified largefiles
Na'Tosha Bard <natosha@unity3d.com>
parents: 15224
diff changeset
   325
                                # this handles the case where a rebase is being
f172292cd416 largefiles: speed up commit by only rewriting standins for modified largefiles
Na'Tosha Bard <natosha@unity3d.com>
parents: 15224
diff changeset
   326
                                # performed and the working copy is not updated
f172292cd416 largefiles: speed up commit by only rewriting standins for modified largefiles
Na'Tosha Bard <natosha@unity3d.com>
parents: 15224
diff changeset
   327
                                # yet.
f172292cd416 largefiles: speed up commit by only rewriting standins for modified largefiles
Na'Tosha Bard <natosha@unity3d.com>
parents: 15224
diff changeset
   328
                                if os.path.exists(self.wjoin(lfile)):
f172292cd416 largefiles: speed up commit by only rewriting standins for modified largefiles
Na'Tosha Bard <natosha@unity3d.com>
parents: 15224
diff changeset
   329
                                    lfutil.updatestandin(self,
f172292cd416 largefiles: speed up commit by only rewriting standins for modified largefiles
Na'Tosha Bard <natosha@unity3d.com>
parents: 15224
diff changeset
   330
                                        lfutil.standin(lfile))
f172292cd416 largefiles: speed up commit by only rewriting standins for modified largefiles
Na'Tosha Bard <natosha@unity3d.com>
parents: 15224
diff changeset
   331
                                    lfdirstate.normal(lfile)
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   332
                    for lfile in lfdirstate:
15250
f172292cd416 largefiles: speed up commit by only rewriting standins for modified largefiles
Na'Tosha Bard <natosha@unity3d.com>
parents: 15224
diff changeset
   333
                        if lfile in modifiedfiles:
f172292cd416 largefiles: speed up commit by only rewriting standins for modified largefiles
Na'Tosha Bard <natosha@unity3d.com>
parents: 15224
diff changeset
   334
                            if not os.path.exists(
f172292cd416 largefiles: speed up commit by only rewriting standins for modified largefiles
Na'Tosha Bard <natosha@unity3d.com>
parents: 15224
diff changeset
   335
                                    repo.wjoin(lfutil.standin(lfile))):
f172292cd416 largefiles: speed up commit by only rewriting standins for modified largefiles
Na'Tosha Bard <natosha@unity3d.com>
parents: 15224
diff changeset
   336
                                lfdirstate.drop(lfile)
15794
0d91211dd12f largefiles: fix inappropriate locking (issue3182)
Levi Bard <levi@unity3d.com>
parents: 15793
diff changeset
   337
0d91211dd12f largefiles: fix inappropriate locking (issue3182)
Levi Bard <levi@unity3d.com>
parents: 15793
diff changeset
   338
                    result = orig(text=text, user=user, date=date, match=match,
0d91211dd12f largefiles: fix inappropriate locking (issue3182)
Levi Bard <levi@unity3d.com>
parents: 15793
diff changeset
   339
                                    force=force, editor=editor, extra=extra)
0d91211dd12f largefiles: fix inappropriate locking (issue3182)
Levi Bard <levi@unity3d.com>
parents: 15793
diff changeset
   340
                    # This needs to be after commit; otherwise precommit hooks
0d91211dd12f largefiles: fix inappropriate locking (issue3182)
Levi Bard <levi@unity3d.com>
parents: 15793
diff changeset
   341
                    # get the wrong status
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   342
                    lfdirstate.write()
15794
0d91211dd12f largefiles: fix inappropriate locking (issue3182)
Levi Bard <levi@unity3d.com>
parents: 15793
diff changeset
   343
                    return result
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   344
15253
67d010779907 largefiles: improve error reporting
Greg Ward <greg@gerg.ca>
parents: 15252
diff changeset
   345
                for f in match.files():
67d010779907 largefiles: improve error reporting
Greg Ward <greg@gerg.ca>
parents: 15252
diff changeset
   346
                    if lfutil.isstandin(f):
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   347
                        raise util.Abort(
15253
67d010779907 largefiles: improve error reporting
Greg Ward <greg@gerg.ca>
parents: 15252
diff changeset
   348
                            _('file "%s" is a largefile standin') % f,
67d010779907 largefiles: improve error reporting
Greg Ward <greg@gerg.ca>
parents: 15252
diff changeset
   349
                            hint=('commit the largefile itself instead'))
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   350
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   351
                # Case 2: user calls commit with specified patterns: refresh
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   352
                # any matching big files.
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   353
                smatcher = lfutil.composestandinmatcher(self, match)
16247
d87d9d8a8e03 largefiles: remove use of underscores that breaks coding convention
Na'Tosha Bard <natosha@unity3d.com>
parents: 16141
diff changeset
   354
                standins = lfutil.dirstatewalk(self.dirstate, smatcher)
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   355
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   356
                # No matching big files: get out of the way and pass control to
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   357
                # the usual commit() method.
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   358
                if not standins:
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   359
                    return orig(text=text, user=user, date=date, match=match,
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   360
                                    force=force, editor=editor, extra=extra)
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   361
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   362
                # Refresh all matching big files.  It's possible that the
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   363
                # commit will end up failing, in which case the big files will
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   364
                # stay refreshed.  No harm done: the user modified them and
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   365
                # asked to commit them, so sooner or later we're going to
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   366
                # refresh the standins.  Might as well leave them refreshed.
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   367
                lfdirstate = lfutil.openlfdirstate(ui, self)
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   368
                for standin in standins:
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   369
                    lfile = lfutil.splitstandin(standin)
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   370
                    if lfdirstate[lfile] <> 'r':
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   371
                        lfutil.updatestandin(self, standin)
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   372
                        lfdirstate.normal(lfile)
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   373
                    else:
15224
7c604d8c7e83 largefiles: remove pre-1.9 code from extension first bundled with 1.9
Na'Tosha Bard <natosha@unity3d.com>
parents: 15171
diff changeset
   374
                        lfdirstate.drop(lfile)
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   375
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   376
                # Cook up a new matcher that only matches regular files or
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   377
                # standins corresponding to the big files requested by the
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   378
                # user.  Have to modify _files to prevent commit() from
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   379
                # complaining "not tracked" for big files.
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   380
                lfiles = lfutil.listlfiles(repo)
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   381
                match = copy.copy(match)
16247
d87d9d8a8e03 largefiles: remove use of underscores that breaks coding convention
Na'Tosha Bard <natosha@unity3d.com>
parents: 16141
diff changeset
   382
                origmatchfn = match.matchfn
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   383
15254
dd03d3a9f888 largefiles: more work on cleaning up comments
Greg Ward <greg@gerg.ca>
parents: 15253
diff changeset
   384
                # Check both the list of largefiles and the list of
dd03d3a9f888 largefiles: more work on cleaning up comments
Greg Ward <greg@gerg.ca>
parents: 15253
diff changeset
   385
                # standins because if a largefile was removed, it
dd03d3a9f888 largefiles: more work on cleaning up comments
Greg Ward <greg@gerg.ca>
parents: 15253
diff changeset
   386
                # won't be in the list of largefiles at this point
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   387
                match._files += sorted(standins)
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   388
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   389
                actualfiles = []
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   390
                for f in match._files:
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   391
                    fstandin = lfutil.standin(f)
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   392
15252
6e809bb4f969 largefiles: improve comments, internal docstrings
Greg Ward <greg@gerg.ca>
parents: 15250
diff changeset
   393
                    # ignore known largefiles and standins
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   394
                    if f in lfiles or fstandin in standins:
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   395
                        continue
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   396
15252
6e809bb4f969 largefiles: improve comments, internal docstrings
Greg Ward <greg@gerg.ca>
parents: 15250
diff changeset
   397
                    # append directory separator to avoid collisions
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   398
                    if not fstandin.endswith(os.sep):
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   399
                        fstandin += os.sep
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   400
15252
6e809bb4f969 largefiles: improve comments, internal docstrings
Greg Ward <greg@gerg.ca>
parents: 15250
diff changeset
   401
                    # prevalidate matching standin directories
15319
9da7e96cd5c2 largefiles: remove redundant any_ function
Benjamin Pollack <benjamin@bitquabit.com>
parents: 15316
diff changeset
   402
                    if util.any(st for st in match._files
15255
7ab05d752405 largefiles: cosmetics, whitespace, code style
Greg Ward <greg@gerg.ca>
parents: 15254
diff changeset
   403
                                   if st.startswith(fstandin)):
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   404
                        continue
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   405
                    actualfiles.append(f)
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   406
                match._files = actualfiles
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   407
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   408
                def matchfn(f):
16247
d87d9d8a8e03 largefiles: remove use of underscores that breaks coding convention
Na'Tosha Bard <natosha@unity3d.com>
parents: 16141
diff changeset
   409
                    if origmatchfn(f):
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   410
                        return f not in lfiles
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   411
                    else:
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   412
                        return f in standins
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   413
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   414
                match.matchfn = matchfn
15794
0d91211dd12f largefiles: fix inappropriate locking (issue3182)
Levi Bard <levi@unity3d.com>
parents: 15793
diff changeset
   415
                result = orig(text=text, user=user, date=date, match=match,
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   416
                                force=force, editor=editor, extra=extra)
15794
0d91211dd12f largefiles: fix inappropriate locking (issue3182)
Levi Bard <levi@unity3d.com>
parents: 15793
diff changeset
   417
                # This needs to be after commit; otherwise precommit hooks
0d91211dd12f largefiles: fix inappropriate locking (issue3182)
Levi Bard <levi@unity3d.com>
parents: 15793
diff changeset
   418
                # get the wrong status
0d91211dd12f largefiles: fix inappropriate locking (issue3182)
Levi Bard <levi@unity3d.com>
parents: 15793
diff changeset
   419
                lfdirstate.write()
0d91211dd12f largefiles: fix inappropriate locking (issue3182)
Levi Bard <levi@unity3d.com>
parents: 15793
diff changeset
   420
                return result
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   421
            finally:
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   422
                wlock.release()
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   423
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   424
        def push(self, remote, force=False, revs=None, newbranch=False):
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   425
            o = lfutil.findoutgoing(repo, remote, force)
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   426
            if o:
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   427
                toupload = set()
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   428
                o = repo.changelog.nodesbetween(o, revs)[0]
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   429
                for n in o:
15255
7ab05d752405 largefiles: cosmetics, whitespace, code style
Greg Ward <greg@gerg.ca>
parents: 15254
diff changeset
   430
                    parents = [p for p in repo.changelog.parents(n)
15789
2c10ea43c801 largefiles: Fix parser warning: redefinition of unused 'node' from line 14
Levi Bard <levi@unity3d.com>
parents: 15783
diff changeset
   431
                               if p != node_.nullid]
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   432
                    ctx = repo[n]
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   433
                    files = set(ctx.files())
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   434
                    if len(parents) == 2:
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   435
                        mc = ctx.manifest()
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   436
                        mp1 = ctx.parents()[0].manifest()
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   437
                        mp2 = ctx.parents()[1].manifest()
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   438
                        for f in mp1:
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   439
                            if f not in mc:
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   440
                                files.add(f)
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   441
                        for f in mp2:
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   442
                            if f not in mc:
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   443
                                files.add(f)
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   444
                        for f in mc:
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   445
                            if mc[f] != mp1.get(f, None) or mc[f] != mp2.get(f,
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   446
                                    None):
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   447
                                files.add(f)
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   448
15255
7ab05d752405 largefiles: cosmetics, whitespace, code style
Greg Ward <greg@gerg.ca>
parents: 15254
diff changeset
   449
                    toupload = toupload.union(
7ab05d752405 largefiles: cosmetics, whitespace, code style
Greg Ward <greg@gerg.ca>
parents: 15254
diff changeset
   450
                        set([ctx[f].data().strip()
7ab05d752405 largefiles: cosmetics, whitespace, code style
Greg Ward <greg@gerg.ca>
parents: 15254
diff changeset
   451
                             for f in files
7ab05d752405 largefiles: cosmetics, whitespace, code style
Greg Ward <greg@gerg.ca>
parents: 15254
diff changeset
   452
                             if lfutil.isstandin(f) and f in ctx]))
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   453
                lfcommands.uploadlfiles(ui, self, remote, toupload)
16247
d87d9d8a8e03 largefiles: remove use of underscores that breaks coding convention
Na'Tosha Bard <natosha@unity3d.com>
parents: 16141
diff changeset
   454
            return super(lfilesrepo, self).push(remote, force, revs,
15224
7c604d8c7e83 largefiles: remove pre-1.9 code from extension first bundled with 1.9
Na'Tosha Bard <natosha@unity3d.com>
parents: 15171
diff changeset
   455
                newbranch)
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   456
16247
d87d9d8a8e03 largefiles: remove use of underscores that breaks coding convention
Na'Tosha Bard <natosha@unity3d.com>
parents: 16141
diff changeset
   457
    repo.__class__ = lfilesrepo
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   458
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   459
    def checkrequireslfiles(ui, repo, **kwargs):
15319
9da7e96cd5c2 largefiles: remove redundant any_ function
Benjamin Pollack <benjamin@bitquabit.com>
parents: 15316
diff changeset
   460
        if 'largefiles' not in repo.requirements and util.any(
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   461
                lfutil.shortname+'/' in f[0] for f in repo.store.datafiles()):
15312
8d862e7b96d4 largefiles: remove 1.9 compat code
Eli Carter <eli.carter@tektronix.com>
parents: 15305
diff changeset
   462
            repo.requirements.add('largefiles')
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   463
            repo._writerequirements()
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   464
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   465
    ui.setconfig('hooks', 'changegroup.lfiles', checkrequireslfiles)
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   466
    ui.setconfig('hooks', 'commit.lfiles', checkrequireslfiles)