hgext/largefiles/reposetup.py
author Kevin Bullock <kbullock@ringworld.org>
Fri, 15 Feb 2013 15:06:43 -0600
branchstable
changeset 18699 7d66a44e87ed
parent 18182 e6db64abfa87
child 18644 3e92772d5383
child 18726 431b246cfb12
permissions -rw-r--r--
mergetools: refine vimdiff warning message We explicitly redraw before echoing the message so that it simply displays at the bottom of the window. Also simplifies the message printing by using 'echomsg' (which uses 'echohl' internally) and adds the names of the software involved for improved Googleability.
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
18152
4454607b5d25 largefiles: remove findoutgoing portability wrapper
Mads Kiilerich <madski@unity3d.com>
parents: 18149
diff changeset
    14
from mercurial import context, error, manifest, match as match_, util, \
4454607b5d25 largefiles: remove findoutgoing portability wrapper
Mads Kiilerich <madski@unity3d.com>
parents: 18149
diff changeset
    15
    discovery
15789
2c10ea43c801 largefiles: Fix parser warning: redefinition of unused 'node' from line 14
Levi Bard <levi@unity3d.com>
parents: 15783
diff changeset
    16
from mercurial import node as node_
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    17
from mercurial.i18n import _
18012
848c428bb5ee largefile: status is buggy on repoproxy, so run unfiltered
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 17803
diff changeset
    18
from mercurial import localrepo
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    19
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    20
import lfcommands
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    21
import proto
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    22
import lfutil
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    23
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    24
def reposetup(ui, repo):
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    25
    # wire repositories should be given new wireproto functions but not the
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    26
    # other largefiles modifications
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    27
    if not repo.local():
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    28
        return proto.wirereposetup(ui, repo)
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    29
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    30
    for name in ('status', 'commitctx', 'commit', 'push'):
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    31
        method = getattr(repo, name)
15255
7ab05d752405 largefiles: cosmetics, whitespace, code style
Greg Ward <greg@gerg.ca>
parents: 15254
diff changeset
    32
        if (isinstance(method, types.FunctionType) and
7ab05d752405 largefiles: cosmetics, whitespace, code style
Greg Ward <greg@gerg.ca>
parents: 15254
diff changeset
    33
            method.func_name == 'wrap'):
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    34
            ui.warn(_('largefiles: repo method %r appears to have already been'
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    35
                    ' wrapped by another extension: '
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    36
                    'largefiles may behave incorrectly\n')
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    37
                    % name)
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    38
16247
d87d9d8a8e03 largefiles: remove use of underscores that breaks coding convention
Na'Tosha Bard <natosha@unity3d.com>
parents: 16141
diff changeset
    39
    class lfilesrepo(repo.__class__):
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    40
        lfstatus = False
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    41
        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
    42
            return super(lfilesrepo, self).status(*args, **kwargs)
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
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)
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    50
            if self.lfstatus:
16247
d87d9d8a8e03 largefiles: remove use of underscores that breaks coding convention
Na'Tosha Bard <natosha@unity3d.com>
parents: 16141
diff changeset
    51
                class lfilesmanifestdict(manifest.manifestdict):
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    52
                    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
    53
                        if super(lfilesmanifestdict,
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    54
                                self).__contains__(filename):
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    55
                            return True
16247
d87d9d8a8e03 largefiles: remove use of underscores that breaks coding convention
Na'Tosha Bard <natosha@unity3d.com>
parents: 16141
diff changeset
    56
                        return super(lfilesmanifestdict,
15628
2b40513384ca largefiles: use lfutil functions
Martin Geisler <mg@aragost.com>
parents: 15626
diff changeset
    57
                            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
    58
                class lfilesctx(ctx.__class__):
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    59
                    def files(self):
16247
d87d9d8a8e03 largefiles: remove use of underscores that breaks coding convention
Na'Tosha Bard <natosha@unity3d.com>
parents: 16141
diff changeset
    60
                        filenames = super(lfilesctx, self).files()
15628
2b40513384ca largefiles: use lfutil functions
Martin Geisler <mg@aragost.com>
parents: 15626
diff changeset
    61
                        return [lfutil.splitstandin(f) or f for f in filenames]
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    62
                    def manifest(self):
16247
d87d9d8a8e03 largefiles: remove use of underscores that breaks coding convention
Na'Tosha Bard <natosha@unity3d.com>
parents: 16141
diff changeset
    63
                        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
    64
                        man1.__class__ = lfilesmanifestdict
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    65
                        return man1
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    66
                    def filectx(self, path, fileid=None, filelog=None):
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    67
                        try:
16141
f346de4dff57 largefiles: don't break filesets
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 16110
diff changeset
    68
                            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
    69
                                result = super(lfilesctx, self).filectx(
16141
f346de4dff57 largefiles: don't break filesets
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 16110
diff changeset
    70
                                    path, fileid, filelog)
f346de4dff57 largefiles: don't break filesets
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 16110
diff changeset
    71
                            else:
16247
d87d9d8a8e03 largefiles: remove use of underscores that breaks coding convention
Na'Tosha Bard <natosha@unity3d.com>
parents: 16141
diff changeset
    72
                                result = super(lfilesctx, self).filectx(
16141
f346de4dff57 largefiles: don't break filesets
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 16110
diff changeset
    73
                                    path, fileid)
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    74
                        except error.LookupError:
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    75
                            # Adding a null character will cause Mercurial to
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    76
                            # identify this as a binary file.
16141
f346de4dff57 largefiles: don't break filesets
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 16110
diff changeset
    77
                            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
    78
                                result = super(lfilesctx, self).filectx(
16141
f346de4dff57 largefiles: don't break filesets
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 16110
diff changeset
    79
                                    lfutil.standin(path), fileid, filelog)
f346de4dff57 largefiles: don't break filesets
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 16110
diff changeset
    80
                            else:
16247
d87d9d8a8e03 largefiles: remove use of underscores that breaks coding convention
Na'Tosha Bard <natosha@unity3d.com>
parents: 16141
diff changeset
    81
                                result = super(lfilesctx, self).filectx(
16141
f346de4dff57 largefiles: don't break filesets
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 16110
diff changeset
    82
                                    lfutil.standin(path), fileid)
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    83
                            olddata = result.data
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    84
                            result.data = lambda: olddata() + '\0'
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    85
                        return result
16247
d87d9d8a8e03 largefiles: remove use of underscores that breaks coding convention
Na'Tosha Bard <natosha@unity3d.com>
parents: 16141
diff changeset
    86
                ctx.__class__ = lfilesctx
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    87
            return ctx
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    88
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    89
        # 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
    90
        # appropriate list in the result. Also removes standin files
6e809bb4f969 largefiles: improve comments, internal docstrings
Greg Ward <greg@gerg.ca>
parents: 15250
diff changeset
    91
        # from the listing. Revert to the original status if
6e809bb4f969 largefiles: improve comments, internal docstrings
Greg Ward <greg@gerg.ca>
parents: 15250
diff changeset
    92
        # self.lfstatus is False.
18012
848c428bb5ee largefile: status is buggy on repoproxy, so run unfiltered
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 17803
diff changeset
    93
        # XXX large file status is buggy when used on repo proxy.
848c428bb5ee largefile: status is buggy on repoproxy, so run unfiltered
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 17803
diff changeset
    94
        # XXX this needs to be investigated.
18016
2a393df0f5cc clfilter: rename `unfilteredmeth` to `unfilteredmethod`
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 18012
diff changeset
    95
        @localrepo.unfilteredmethod
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    96
        def status(self, node1='.', node2=None, match=None, ignored=False,
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    97
                clean=False, unknown=False, listsubrepos=False):
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    98
            listignored, listclean, listunknown = ignored, clean, unknown
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    99
            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
   100
                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
   101
                    listignored, listclean, listunknown, listsubrepos)
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   102
            else:
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   103
                # some calls in this function rely on the old version of status
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   104
                self.lfstatus = False
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   105
                if isinstance(node1, context.changectx):
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   106
                    ctx1 = node1
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   107
                else:
17803
1479572db256 largefile: use `self` in repo method instead of `repo`
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 17424
diff changeset
   108
                    ctx1 = self[node1]
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   109
                if isinstance(node2, context.changectx):
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   110
                    ctx2 = node2
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   111
                else:
17803
1479572db256 largefile: use `self` in repo method instead of `repo`
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 17424
diff changeset
   112
                    ctx2 = self[node2]
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   113
                working = ctx2.rev() is None
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   114
                parentworking = working and ctx1 == self['.']
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   115
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   116
                def inctx(file, ctx):
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   117
                    try:
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   118
                        if ctx.rev() is None:
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   119
                            return file in ctx.manifest()
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   120
                        ctx[file]
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   121
                        return True
15171
547da6115d1d largefiles: eliminate naked exceptions
Matt Mackall <mpm@selenic.com>
parents: 15170
diff changeset
   122
                    except KeyError:
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   123
                        return False
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   124
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   125
                if match is None:
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   126
                    match = match_.always(self.root, self.getcwd())
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   127
15653
93c77d5b9752 largefiles: optimize status when files are specified (issue3144)
Na'Tosha Bard <natosha@unity3d.com>
parents: 15630
diff changeset
   128
                # 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
   129
                # 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
   130
                # 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
   131
                # 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
   132
                lfdirstate = lfutil.openlfdirstate(ui, self)
93c77d5b9752 largefiles: optimize status when files are specified (issue3144)
Na'Tosha Bard <natosha@unity3d.com>
parents: 15630
diff changeset
   133
                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
   134
                    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
   135
                        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
   136
                            break
41417443b7d0 largefiles: check whether specified patterns are related to largefiles strictly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 15982
diff changeset
   137
                    else:
16247
d87d9d8a8e03 largefiles: remove use of underscores that breaks coding convention
Na'Tosha Bard <natosha@unity3d.com>
parents: 16141
diff changeset
   138
                        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
   139
                                match, listignored, listclean,
93c77d5b9752 largefiles: optimize status when files are specified (issue3144)
Na'Tosha Bard <natosha@unity3d.com>
parents: 15630
diff changeset
   140
                                listunknown, listsubrepos)
93c77d5b9752 largefiles: optimize status when files are specified (issue3144)
Na'Tosha Bard <natosha@unity3d.com>
parents: 15630
diff changeset
   141
15254
dd03d3a9f888 largefiles: more work on cleaning up comments
Greg Ward <greg@gerg.ca>
parents: 15253
diff changeset
   142
                # 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
   143
                # of largefiles.
16586
ebd2ead59f1c largefiles: fix "hg status dir" missing regular files (issue3421)
Patrick Mezard <patrick@mezard.eu>
parents: 16571
diff changeset
   144
                def tostandins(files):
ebd2ead59f1c largefiles: fix "hg status dir" missing regular files (issue3421)
Patrick Mezard <patrick@mezard.eu>
parents: 16571
diff changeset
   145
                    if not working:
ebd2ead59f1c largefiles: fix "hg status dir" missing regular files (issue3421)
Patrick Mezard <patrick@mezard.eu>
parents: 16571
diff changeset
   146
                        return files
ebd2ead59f1c largefiles: fix "hg status dir" missing regular files (issue3421)
Patrick Mezard <patrick@mezard.eu>
parents: 16571
diff changeset
   147
                    newfiles = []
17803
1479572db256 largefile: use `self` in repo method instead of `repo`
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 17424
diff changeset
   148
                    dirstate = self.dirstate
16586
ebd2ead59f1c largefiles: fix "hg status dir" missing regular files (issue3421)
Patrick Mezard <patrick@mezard.eu>
parents: 16571
diff changeset
   149
                    for f in files:
ebd2ead59f1c largefiles: fix "hg status dir" missing regular files (issue3421)
Patrick Mezard <patrick@mezard.eu>
parents: 16571
diff changeset
   150
                        sf = lfutil.standin(f)
ebd2ead59f1c largefiles: fix "hg status dir" missing regular files (issue3421)
Patrick Mezard <patrick@mezard.eu>
parents: 16571
diff changeset
   151
                        if sf in dirstate:
ebd2ead59f1c largefiles: fix "hg status dir" missing regular files (issue3421)
Patrick Mezard <patrick@mezard.eu>
parents: 16571
diff changeset
   152
                            newfiles.append(sf)
ebd2ead59f1c largefiles: fix "hg status dir" missing regular files (issue3421)
Patrick Mezard <patrick@mezard.eu>
parents: 16571
diff changeset
   153
                        elif sf in dirstate.dirs():
ebd2ead59f1c largefiles: fix "hg status dir" missing regular files (issue3421)
Patrick Mezard <patrick@mezard.eu>
parents: 16571
diff changeset
   154
                            # Directory entries could be regular or
ebd2ead59f1c largefiles: fix "hg status dir" missing regular files (issue3421)
Patrick Mezard <patrick@mezard.eu>
parents: 16571
diff changeset
   155
                            # standin, check both
ebd2ead59f1c largefiles: fix "hg status dir" missing regular files (issue3421)
Patrick Mezard <patrick@mezard.eu>
parents: 16571
diff changeset
   156
                            newfiles.extend((f, sf))
ebd2ead59f1c largefiles: fix "hg status dir" missing regular files (issue3421)
Patrick Mezard <patrick@mezard.eu>
parents: 16571
diff changeset
   157
                        else:
ebd2ead59f1c largefiles: fix "hg status dir" missing regular files (issue3421)
Patrick Mezard <patrick@mezard.eu>
parents: 16571
diff changeset
   158
                            newfiles.append(f)
ebd2ead59f1c largefiles: fix "hg status dir" missing regular files (issue3421)
Patrick Mezard <patrick@mezard.eu>
parents: 16571
diff changeset
   159
                    return newfiles
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   160
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   161
                m = copy.copy(match)
16586
ebd2ead59f1c largefiles: fix "hg status dir" missing regular files (issue3421)
Patrick Mezard <patrick@mezard.eu>
parents: 16571
diff changeset
   162
                m._files = tostandins(m._files)
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   163
16247
d87d9d8a8e03 largefiles: remove use of underscores that breaks coding convention
Na'Tosha Bard <natosha@unity3d.com>
parents: 16141
diff changeset
   164
                result = super(lfilesrepo, self).status(node1, node2, m,
18141
a907826c158c largefiles: don't walk through all ignored files
Mads Kiilerich <madski@unity3d.com>
parents: 18139
diff changeset
   165
                    ignored, clean, unknown, listsubrepos)
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   166
                if working:
18149
2dcc3653b361 largefiles: unindent code
Mads Kiilerich <madski@unity3d.com>
parents: 18148
diff changeset
   167
2dcc3653b361 largefiles: unindent code
Mads Kiilerich <madski@unity3d.com>
parents: 18148
diff changeset
   168
                    def sfindirstate(f):
2dcc3653b361 largefiles: unindent code
Mads Kiilerich <madski@unity3d.com>
parents: 18148
diff changeset
   169
                        sf = lfutil.standin(f)
2dcc3653b361 largefiles: unindent code
Mads Kiilerich <madski@unity3d.com>
parents: 18148
diff changeset
   170
                        dirstate = self.dirstate
2dcc3653b361 largefiles: unindent code
Mads Kiilerich <madski@unity3d.com>
parents: 18148
diff changeset
   171
                        return sf in dirstate or sf in dirstate.dirs()
15617
74e691b141c4 largefiles: optimize performance of status on largefiles repos (issue3136)
Na'Tosha Bard <natosha@unity3d.com>
parents: 15385
diff changeset
   172
18149
2dcc3653b361 largefiles: unindent code
Mads Kiilerich <madski@unity3d.com>
parents: 18148
diff changeset
   173
                    match._files = [f for f in match._files
2dcc3653b361 largefiles: unindent code
Mads Kiilerich <madski@unity3d.com>
parents: 18148
diff changeset
   174
                                    if sfindirstate(f)]
2dcc3653b361 largefiles: unindent code
Mads Kiilerich <madski@unity3d.com>
parents: 18148
diff changeset
   175
                    # Don't waste time getting the ignored and unknown
2dcc3653b361 largefiles: unindent code
Mads Kiilerich <madski@unity3d.com>
parents: 18148
diff changeset
   176
                    # files from lfdirstate
2dcc3653b361 largefiles: unindent code
Mads Kiilerich <madski@unity3d.com>
parents: 18148
diff changeset
   177
                    s = lfdirstate.status(match, [], False,
2dcc3653b361 largefiles: unindent code
Mads Kiilerich <madski@unity3d.com>
parents: 18148
diff changeset
   178
                            listclean, False)
2dcc3653b361 largefiles: unindent code
Mads Kiilerich <madski@unity3d.com>
parents: 18148
diff changeset
   179
                    (unsure, modified, added, removed, missing, _unknown,
2dcc3653b361 largefiles: unindent code
Mads Kiilerich <madski@unity3d.com>
parents: 18148
diff changeset
   180
                            _ignored, clean) = s
2dcc3653b361 largefiles: unindent code
Mads Kiilerich <madski@unity3d.com>
parents: 18148
diff changeset
   181
                    if parentworking:
2dcc3653b361 largefiles: unindent code
Mads Kiilerich <madski@unity3d.com>
parents: 18148
diff changeset
   182
                        for lfile in unsure:
2dcc3653b361 largefiles: unindent code
Mads Kiilerich <madski@unity3d.com>
parents: 18148
diff changeset
   183
                            standin = lfutil.standin(lfile)
2dcc3653b361 largefiles: unindent code
Mads Kiilerich <madski@unity3d.com>
parents: 18148
diff changeset
   184
                            if standin not in ctx1:
2dcc3653b361 largefiles: unindent code
Mads Kiilerich <madski@unity3d.com>
parents: 18148
diff changeset
   185
                                # from second parent
2dcc3653b361 largefiles: unindent code
Mads Kiilerich <madski@unity3d.com>
parents: 18148
diff changeset
   186
                                modified.append(lfile)
2dcc3653b361 largefiles: unindent code
Mads Kiilerich <madski@unity3d.com>
parents: 18148
diff changeset
   187
                            elif ctx1[standin].data().strip() \
2dcc3653b361 largefiles: unindent code
Mads Kiilerich <madski@unity3d.com>
parents: 18148
diff changeset
   188
                                    != lfutil.hashfile(self.wjoin(lfile)):
2dcc3653b361 largefiles: unindent code
Mads Kiilerich <madski@unity3d.com>
parents: 18148
diff changeset
   189
                                modified.append(lfile)
2dcc3653b361 largefiles: unindent code
Mads Kiilerich <madski@unity3d.com>
parents: 18148
diff changeset
   190
                            else:
2dcc3653b361 largefiles: unindent code
Mads Kiilerich <madski@unity3d.com>
parents: 18148
diff changeset
   191
                                clean.append(lfile)
2dcc3653b361 largefiles: unindent code
Mads Kiilerich <madski@unity3d.com>
parents: 18148
diff changeset
   192
                                lfdirstate.normal(lfile)
2dcc3653b361 largefiles: unindent code
Mads Kiilerich <madski@unity3d.com>
parents: 18148
diff changeset
   193
                    else:
2dcc3653b361 largefiles: unindent code
Mads Kiilerich <madski@unity3d.com>
parents: 18148
diff changeset
   194
                        tocheck = unsure + modified + added + clean
2dcc3653b361 largefiles: unindent code
Mads Kiilerich <madski@unity3d.com>
parents: 18148
diff changeset
   195
                        modified, added, clean = [], [], []
2dcc3653b361 largefiles: unindent code
Mads Kiilerich <madski@unity3d.com>
parents: 18148
diff changeset
   196
2dcc3653b361 largefiles: unindent code
Mads Kiilerich <madski@unity3d.com>
parents: 18148
diff changeset
   197
                        for lfile in tocheck:
2dcc3653b361 largefiles: unindent code
Mads Kiilerich <madski@unity3d.com>
parents: 18148
diff changeset
   198
                            standin = lfutil.standin(lfile)
2dcc3653b361 largefiles: unindent code
Mads Kiilerich <madski@unity3d.com>
parents: 18148
diff changeset
   199
                            if inctx(standin, ctx1):
2dcc3653b361 largefiles: unindent code
Mads Kiilerich <madski@unity3d.com>
parents: 18148
diff changeset
   200
                                if ctx1[standin].data().strip() != \
2dcc3653b361 largefiles: unindent code
Mads Kiilerich <madski@unity3d.com>
parents: 18148
diff changeset
   201
                                        lfutil.hashfile(self.wjoin(lfile)):
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   202
                                    modified.append(lfile)
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   203
                                else:
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   204
                                    clean.append(lfile)
18149
2dcc3653b361 largefiles: unindent code
Mads Kiilerich <madski@unity3d.com>
parents: 18148
diff changeset
   205
                            else:
2dcc3653b361 largefiles: unindent code
Mads Kiilerich <madski@unity3d.com>
parents: 18148
diff changeset
   206
                                added.append(lfile)
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   207
18145
93206823bd61 largefiles: remove overly complex handling of ignored and unknown files
Mads Kiilerich <madski@unity3d.com>
parents: 18142
diff changeset
   208
                    # Standins no longer found in lfdirstate has been removed
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   209
                    for standin in ctx1.manifest():
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   210
                        if not lfutil.isstandin(standin):
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   211
                            continue
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   212
                        lfile = lfutil.splitstandin(standin)
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   213
                        if not match(lfile):
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   214
                            continue
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   215
                        if lfile not in lfdirstate:
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   216
                            removed.append(lfile)
15663
9036c7d106bf largefiles: handle merges between normal files and largefiles (issue3084)
Martin Geisler <mg@aragost.com>
parents: 15629
diff changeset
   217
9036c7d106bf largefiles: handle merges between normal files and largefiles (issue3084)
Martin Geisler <mg@aragost.com>
parents: 15629
diff changeset
   218
                    # Filter result lists
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   219
                    result = list(result)
15663
9036c7d106bf largefiles: handle merges between normal files and largefiles (issue3084)
Martin Geisler <mg@aragost.com>
parents: 15629
diff changeset
   220
9036c7d106bf largefiles: handle merges between normal files and largefiles (issue3084)
Martin Geisler <mg@aragost.com>
parents: 15629
diff changeset
   221
                    # 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
   222
                    # still in the normal dirstate. Likewise, normal
18145
93206823bd61 largefiles: remove overly complex handling of ignored and unknown files
Mads Kiilerich <madski@unity3d.com>
parents: 18142
diff changeset
   223
                    # files are not really removed if they are still in
15663
9036c7d106bf largefiles: handle merges between normal files and largefiles (issue3084)
Martin Geisler <mg@aragost.com>
parents: 15629
diff changeset
   224
                    # 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
   225
                    # change type.
17803
1479572db256 largefile: use `self` in repo method instead of `repo`
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 17424
diff changeset
   226
                    removed = [f for f in removed if f not in self.dirstate]
15663
9036c7d106bf largefiles: handle merges between normal files and largefiles (issue3084)
Martin Geisler <mg@aragost.com>
parents: 15629
diff changeset
   227
                    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
   228
18145
93206823bd61 largefiles: remove overly complex handling of ignored and unknown files
Mads Kiilerich <madski@unity3d.com>
parents: 18142
diff changeset
   229
                    lfiles = set(lfdirstate._map)
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   230
                    # Unknown files
18145
93206823bd61 largefiles: remove overly complex handling of ignored and unknown files
Mads Kiilerich <madski@unity3d.com>
parents: 18142
diff changeset
   231
                    result[4] = set(result[4]).difference(lfiles)
93206823bd61 largefiles: remove overly complex handling of ignored and unknown files
Mads Kiilerich <madski@unity3d.com>
parents: 18142
diff changeset
   232
                    # Ignored files
93206823bd61 largefiles: remove overly complex handling of ignored and unknown files
Mads Kiilerich <madski@unity3d.com>
parents: 18142
diff changeset
   233
                    result[5] = set(result[5]).difference(lfiles)
15254
dd03d3a9f888 largefiles: more work on cleaning up comments
Greg Ward <greg@gerg.ca>
parents: 15253
diff changeset
   234
                    # combine normal files and largefiles
15255
7ab05d752405 largefiles: cosmetics, whitespace, code style
Greg Ward <greg@gerg.ca>
parents: 15254
diff changeset
   235
                    normals = [[fn for fn in filelist
7ab05d752405 largefiles: cosmetics, whitespace, code style
Greg Ward <greg@gerg.ca>
parents: 15254
diff changeset
   236
                                if not lfutil.isstandin(fn)]
7ab05d752405 largefiles: cosmetics, whitespace, code style
Greg Ward <greg@gerg.ca>
parents: 15254
diff changeset
   237
                               for filelist in result]
15663
9036c7d106bf largefiles: handle merges between normal files and largefiles (issue3084)
Martin Geisler <mg@aragost.com>
parents: 15629
diff changeset
   238
                    lfiles = (modified, added, removed, missing, [], [], clean)
15255
7ab05d752405 largefiles: cosmetics, whitespace, code style
Greg Ward <greg@gerg.ca>
parents: 15254
diff changeset
   239
                    result = [sorted(list1 + list2)
7ab05d752405 largefiles: cosmetics, whitespace, code style
Greg Ward <greg@gerg.ca>
parents: 15254
diff changeset
   240
                              for (list1, list2) in zip(normals, lfiles)]
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   241
                else:
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   242
                    def toname(f):
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   243
                        if lfutil.isstandin(f):
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   244
                            return lfutil.splitstandin(f)
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   245
                        return f
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   246
                    result = [[toname(f) for f in items] for items in result]
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   247
18139
03faf12fbee7 largefiles status: update lfdirstate with result from cleanliness check
Mads Kiilerich <madski@unity3d.com>
parents: 18064
diff changeset
   248
                lfdirstate.write()
03faf12fbee7 largefiles status: update lfdirstate with result from cleanliness check
Mads Kiilerich <madski@unity3d.com>
parents: 18064
diff changeset
   249
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   250
                if not listunknown:
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   251
                    result[4] = []
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   252
                if not listignored:
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   253
                    result[5] = []
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   254
                if not listclean:
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   255
                    result[6] = []
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   256
                self.lfstatus = True
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   257
                return result
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   258
15254
dd03d3a9f888 largefiles: more work on cleaning up comments
Greg Ward <greg@gerg.ca>
parents: 15253
diff changeset
   259
        # 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
   260
        # cache.
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   261
        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
   262
            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
   263
            lfutil.copyalltostore(self, node)
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   264
            return node
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   265
15254
dd03d3a9f888 largefiles: more work on cleaning up comments
Greg Ward <greg@gerg.ca>
parents: 15253
diff changeset
   266
        # 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
   267
        # 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
   268
        # Do that here.
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   269
        def commit(self, text="", user=None, date=None, match=None,
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   270
                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
   271
            orig = super(lfilesrepo, self).commit
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   272
17803
1479572db256 largefile: use `self` in repo method instead of `repo`
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 17424
diff changeset
   273
            wlock = self.wlock()
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   274
            try:
15982
bf502ccc46d7 largefiles: fix transplant for all cases (issue3192)
Na'Tosha Bard <natosha@unity3d.com>
parents: 15796
diff changeset
   275
                # Case 0: Rebase or Transplant
15793
3ef07ecdb0d5 largefiles: correctly handle dirstate status when rebasing
Na'Tosha Bard <natosha@unity3d.com>
parents: 15789
diff changeset
   276
                # 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
   277
                # 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
   278
                # 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
   279
                # 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
   280
                # 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
   281
                # largefiles as modified
17803
1479572db256 largefile: use `self` in repo method instead of `repo`
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 17424
diff changeset
   282
                if getattr(self, "_isrebasing", False) or \
1479572db256 largefile: use `self` in repo method instead of `repo`
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 17424
diff changeset
   283
                        getattr(self, "_istransplanting", False):
1479572db256 largefile: use `self` in repo method instead of `repo`
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 17424
diff changeset
   284
                    lfcommands.updatelfiles(self.ui, self, filelist=None,
15982
bf502ccc46d7 largefiles: fix transplant for all cases (issue3192)
Na'Tosha Bard <natosha@unity3d.com>
parents: 15796
diff changeset
   285
                                            printmessage=False)
15793
3ef07ecdb0d5 largefiles: correctly handle dirstate status when rebasing
Na'Tosha Bard <natosha@unity3d.com>
parents: 15789
diff changeset
   286
                    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
   287
                                    force=force, editor=editor, extra=extra)
3ef07ecdb0d5 largefiles: correctly handle dirstate status when rebasing
Na'Tosha Bard <natosha@unity3d.com>
parents: 15789
diff changeset
   288
                    return result
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   289
                # 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
   290
                # 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
   291
                # are "dirty".
15255
7ab05d752405 largefiles: cosmetics, whitespace, code style
Greg Ward <greg@gerg.ca>
parents: 15254
diff changeset
   292
                if ((match is None) or
7ab05d752405 largefiles: cosmetics, whitespace, code style
Greg Ward <greg@gerg.ca>
parents: 15254
diff changeset
   293
                    (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
   294
                    # 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
   295
                    # 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
   296
                    # 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
   297
                    # 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
   298
                    # large.
f172292cd416 largefiles: speed up commit by only rewriting standins for modified largefiles
Na'Tosha Bard <natosha@unity3d.com>
parents: 15224
diff changeset
   299
                    lfdirstate = lfutil.openlfdirstate(ui, self)
17803
1479572db256 largefile: use `self` in repo method instead of `repo`
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 17424
diff changeset
   300
                    dirtymatch = match_.always(self.root, self.getcwd())
15250
f172292cd416 largefiles: speed up commit by only rewriting standins for modified largefiles
Na'Tosha Bard <natosha@unity3d.com>
parents: 15224
diff changeset
   301
                    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
   302
                    modifiedfiles = []
f172292cd416 largefiles: speed up commit by only rewriting standins for modified largefiles
Na'Tosha Bard <natosha@unity3d.com>
parents: 15224
diff changeset
   303
                    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
   304
                        modifiedfiles.extend(i)
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   305
                    lfiles = lfutil.listlfiles(self)
15254
dd03d3a9f888 largefiles: more work on cleaning up comments
Greg Ward <greg@gerg.ca>
parents: 15253
diff changeset
   306
                    # this only loops through largefiles that exist (not
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   307
                    # removed/renamed)
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   308
                    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
   309
                        if lfile in modifiedfiles:
16248
51e6f318bdf1 largefiles: fix check-code errors.
Na'Tosha Bard <natosha@unity3d.com>
parents: 16247
diff changeset
   310
                            if os.path.exists(
51e6f318bdf1 largefiles: fix check-code errors.
Na'Tosha Bard <natosha@unity3d.com>
parents: 16247
diff changeset
   311
                                    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
   312
                                # 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
   313
                                # 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
   314
                                # yet.
f172292cd416 largefiles: speed up commit by only rewriting standins for modified largefiles
Na'Tosha Bard <natosha@unity3d.com>
parents: 15224
diff changeset
   315
                                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
   316
                                    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
   317
                                        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
   318
                                    lfdirstate.normal(lfile)
15794
0d91211dd12f largefiles: fix inappropriate locking (issue3182)
Levi Bard <levi@unity3d.com>
parents: 15793
diff changeset
   319
0d91211dd12f largefiles: fix inappropriate locking (issue3182)
Levi Bard <levi@unity3d.com>
parents: 15793
diff changeset
   320
                    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
   321
                                    force=force, editor=editor, extra=extra)
17230
fc4c155658b7 largefiles: defer lfdirstate.drop() until after commit (issue3364)
Matt Harbison <matt_harbison@yahoo.com>
parents: 16731
diff changeset
   322
fc4c155658b7 largefiles: defer lfdirstate.drop() until after commit (issue3364)
Matt Harbison <matt_harbison@yahoo.com>
parents: 16731
diff changeset
   323
                    if result is not None:
fc4c155658b7 largefiles: defer lfdirstate.drop() until after commit (issue3364)
Matt Harbison <matt_harbison@yahoo.com>
parents: 16731
diff changeset
   324
                        for lfile in lfdirstate:
fc4c155658b7 largefiles: defer lfdirstate.drop() until after commit (issue3364)
Matt Harbison <matt_harbison@yahoo.com>
parents: 16731
diff changeset
   325
                            if lfile in modifiedfiles:
17803
1479572db256 largefile: use `self` in repo method instead of `repo`
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 17424
diff changeset
   326
                                if (not os.path.exists(self.wjoin(
17230
fc4c155658b7 largefiles: defer lfdirstate.drop() until after commit (issue3364)
Matt Harbison <matt_harbison@yahoo.com>
parents: 16731
diff changeset
   327
                                   lfutil.standin(lfile)))) or \
17803
1479572db256 largefile: use `self` in repo method instead of `repo`
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 17424
diff changeset
   328
                                   (not os.path.exists(self.wjoin(lfile))):
17230
fc4c155658b7 largefiles: defer lfdirstate.drop() until after commit (issue3364)
Matt Harbison <matt_harbison@yahoo.com>
parents: 16731
diff changeset
   329
                                    lfdirstate.drop(lfile)
fc4c155658b7 largefiles: defer lfdirstate.drop() until after commit (issue3364)
Matt Harbison <matt_harbison@yahoo.com>
parents: 16731
diff changeset
   330
15794
0d91211dd12f largefiles: fix inappropriate locking (issue3182)
Levi Bard <levi@unity3d.com>
parents: 15793
diff changeset
   331
                    # This needs to be after commit; otherwise precommit hooks
0d91211dd12f largefiles: fix inappropriate locking (issue3182)
Levi Bard <levi@unity3d.com>
parents: 15793
diff changeset
   332
                    # get the wrong status
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   333
                    lfdirstate.write()
15794
0d91211dd12f largefiles: fix inappropriate locking (issue3182)
Levi Bard <levi@unity3d.com>
parents: 15793
diff changeset
   334
                    return result
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   335
18064
7e2b9f6a2cd0 largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents: 17803
diff changeset
   336
                lfiles = lfutil.listlfiles(self)
7e2b9f6a2cd0 largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents: 17803
diff changeset
   337
                match._files = self._subdirlfs(match.files(), lfiles)
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   338
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   339
                # Case 2: user calls commit with specified patterns: refresh
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   340
                # any matching big files.
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   341
                smatcher = lfutil.composestandinmatcher(self, match)
18154
93c697d9c158 largefiles: remove trivial portability wrappers
Mads Kiilerich <madski@unity3d.com>
parents: 18152
diff changeset
   342
                standins = self.dirstate.walk(smatcher, [], False, False)
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   343
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   344
                # No matching big files: get out of the way and pass control to
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   345
                # the usual commit() method.
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   346
                if not standins:
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   347
                    return orig(text=text, user=user, date=date, match=match,
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   348
                                    force=force, editor=editor, extra=extra)
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   349
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   350
                # Refresh all matching big files.  It's possible that the
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   351
                # commit will end up failing, in which case the big files will
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   352
                # stay refreshed.  No harm done: the user modified them and
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   353
                # asked to commit them, so sooner or later we're going to
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   354
                # refresh the standins.  Might as well leave them refreshed.
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   355
                lfdirstate = lfutil.openlfdirstate(ui, self)
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   356
                for standin in standins:
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   357
                    lfile = lfutil.splitstandin(standin)
18182
e6db64abfa87 largefiles: stop using <> operator in favor of !=
Augie Fackler <raf@durin42.com>
parents: 18154
diff changeset
   358
                    if lfdirstate[lfile] != 'r':
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   359
                        lfutil.updatestandin(self, standin)
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   360
                        lfdirstate.normal(lfile)
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   361
                    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
   362
                        lfdirstate.drop(lfile)
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   363
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   364
                # Cook up a new matcher that only matches regular files or
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   365
                # standins corresponding to the big files requested by the
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   366
                # user.  Have to modify _files to prevent commit() from
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   367
                # complaining "not tracked" for big files.
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   368
                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
   369
                origmatchfn = match.matchfn
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   370
15254
dd03d3a9f888 largefiles: more work on cleaning up comments
Greg Ward <greg@gerg.ca>
parents: 15253
diff changeset
   371
                # 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
   372
                # 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
   373
                # won't be in the list of largefiles at this point
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   374
                match._files += sorted(standins)
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   375
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   376
                actualfiles = []
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   377
                for f in match._files:
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   378
                    fstandin = lfutil.standin(f)
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   379
15252
6e809bb4f969 largefiles: improve comments, internal docstrings
Greg Ward <greg@gerg.ca>
parents: 15250
diff changeset
   380
                    # ignore known largefiles and standins
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   381
                    if f in lfiles or fstandin in standins:
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   382
                        continue
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   383
15252
6e809bb4f969 largefiles: improve comments, internal docstrings
Greg Ward <greg@gerg.ca>
parents: 15250
diff changeset
   384
                    # append directory separator to avoid collisions
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   385
                    if not fstandin.endswith(os.sep):
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   386
                        fstandin += os.sep
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   387
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   388
                    actualfiles.append(f)
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   389
                match._files = actualfiles
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   390
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   391
                def matchfn(f):
16247
d87d9d8a8e03 largefiles: remove use of underscores that breaks coding convention
Na'Tosha Bard <natosha@unity3d.com>
parents: 16141
diff changeset
   392
                    if origmatchfn(f):
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   393
                        return f not in lfiles
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   394
                    else:
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   395
                        return f in standins
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   396
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   397
                match.matchfn = matchfn
15794
0d91211dd12f largefiles: fix inappropriate locking (issue3182)
Levi Bard <levi@unity3d.com>
parents: 15793
diff changeset
   398
                result = orig(text=text, user=user, date=date, match=match,
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   399
                                force=force, editor=editor, extra=extra)
15794
0d91211dd12f largefiles: fix inappropriate locking (issue3182)
Levi Bard <levi@unity3d.com>
parents: 15793
diff changeset
   400
                # This needs to be after commit; otherwise precommit hooks
0d91211dd12f largefiles: fix inappropriate locking (issue3182)
Levi Bard <levi@unity3d.com>
parents: 15793
diff changeset
   401
                # get the wrong status
0d91211dd12f largefiles: fix inappropriate locking (issue3182)
Levi Bard <levi@unity3d.com>
parents: 15793
diff changeset
   402
                lfdirstate.write()
0d91211dd12f largefiles: fix inappropriate locking (issue3182)
Levi Bard <levi@unity3d.com>
parents: 15793
diff changeset
   403
                return result
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   404
            finally:
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   405
                wlock.release()
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   406
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   407
        def push(self, remote, force=False, revs=None, newbranch=False):
18152
4454607b5d25 largefiles: remove findoutgoing portability wrapper
Mads Kiilerich <madski@unity3d.com>
parents: 18149
diff changeset
   408
            outgoing = discovery.findcommonoutgoing(repo, remote.peer(),
4454607b5d25 largefiles: remove findoutgoing portability wrapper
Mads Kiilerich <madski@unity3d.com>
parents: 18149
diff changeset
   409
                                                    force=force)
4454607b5d25 largefiles: remove findoutgoing portability wrapper
Mads Kiilerich <madski@unity3d.com>
parents: 18149
diff changeset
   410
            if outgoing.missing:
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   411
                toupload = set()
18152
4454607b5d25 largefiles: remove findoutgoing portability wrapper
Mads Kiilerich <madski@unity3d.com>
parents: 18149
diff changeset
   412
                o = self.changelog.nodesbetween(outgoing.missing, revs)[0]
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   413
                for n in o:
17803
1479572db256 largefile: use `self` in repo method instead of `repo`
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 17424
diff changeset
   414
                    parents = [p for p in self.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
   415
                               if p != node_.nullid]
17803
1479572db256 largefile: use `self` in repo method instead of `repo`
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 17424
diff changeset
   416
                    ctx = self[n]
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   417
                    files = set(ctx.files())
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   418
                    if len(parents) == 2:
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   419
                        mc = ctx.manifest()
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   420
                        mp1 = ctx.parents()[0].manifest()
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   421
                        mp2 = ctx.parents()[1].manifest()
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   422
                        for f in mp1:
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   423
                            if f not in mc:
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   424
                                files.add(f)
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   425
                        for f in mp2:
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   426
                            if f not in mc:
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   427
                                files.add(f)
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   428
                        for f in mc:
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   429
                            if mc[f] != mp1.get(f, None) or mc[f] != mp2.get(f,
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   430
                                    None):
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   431
                                files.add(f)
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   432
15255
7ab05d752405 largefiles: cosmetics, whitespace, code style
Greg Ward <greg@gerg.ca>
parents: 15254
diff changeset
   433
                    toupload = toupload.union(
7ab05d752405 largefiles: cosmetics, whitespace, code style
Greg Ward <greg@gerg.ca>
parents: 15254
diff changeset
   434
                        set([ctx[f].data().strip()
7ab05d752405 largefiles: cosmetics, whitespace, code style
Greg Ward <greg@gerg.ca>
parents: 15254
diff changeset
   435
                             for f in files
7ab05d752405 largefiles: cosmetics, whitespace, code style
Greg Ward <greg@gerg.ca>
parents: 15254
diff changeset
   436
                             if lfutil.isstandin(f) and f in ctx]))
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   437
                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
   438
            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
   439
                newbranch)
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   440
18064
7e2b9f6a2cd0 largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents: 17803
diff changeset
   441
        def _subdirlfs(self, files, lfiles):
7e2b9f6a2cd0 largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents: 17803
diff changeset
   442
            '''
7e2b9f6a2cd0 largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents: 17803
diff changeset
   443
            Adjust matched file list
7e2b9f6a2cd0 largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents: 17803
diff changeset
   444
            If we pass a directory to commit whose only commitable files
7e2b9f6a2cd0 largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents: 17803
diff changeset
   445
            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
   446
            the largefiles.
7e2b9f6a2cd0 largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents: 17803
diff changeset
   447
            So we do the following:
7e2b9f6a2cd0 largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents: 17803
diff changeset
   448
            For directories that only have largefiles as matches,
7e2b9f6a2cd0 largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents: 17803
diff changeset
   449
            we explicitly add the largefiles to the matchlist and remove
7e2b9f6a2cd0 largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents: 17803
diff changeset
   450
            the directory.
7e2b9f6a2cd0 largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents: 17803
diff changeset
   451
            In other cases, we leave the match list unmodified.
7e2b9f6a2cd0 largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents: 17803
diff changeset
   452
            '''
7e2b9f6a2cd0 largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents: 17803
diff changeset
   453
            actualfiles = []
7e2b9f6a2cd0 largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents: 17803
diff changeset
   454
            dirs = []
7e2b9f6a2cd0 largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents: 17803
diff changeset
   455
            regulars = []
7e2b9f6a2cd0 largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents: 17803
diff changeset
   456
7e2b9f6a2cd0 largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents: 17803
diff changeset
   457
            for f in files:
7e2b9f6a2cd0 largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents: 17803
diff changeset
   458
                if lfutil.isstandin(f + '/'):
7e2b9f6a2cd0 largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents: 17803
diff changeset
   459
                    raise util.Abort(
7e2b9f6a2cd0 largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents: 17803
diff changeset
   460
                        _('file "%s" is a largefile standin') % f,
7e2b9f6a2cd0 largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents: 17803
diff changeset
   461
                        hint=('commit the largefile itself instead'))
7e2b9f6a2cd0 largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents: 17803
diff changeset
   462
                # Scan directories
7e2b9f6a2cd0 largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents: 17803
diff changeset
   463
                if os.path.isdir(self.wjoin(f)):
7e2b9f6a2cd0 largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents: 17803
diff changeset
   464
                    dirs.append(f)
7e2b9f6a2cd0 largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents: 17803
diff changeset
   465
                else:
7e2b9f6a2cd0 largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents: 17803
diff changeset
   466
                    regulars.append(f)
7e2b9f6a2cd0 largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents: 17803
diff changeset
   467
7e2b9f6a2cd0 largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents: 17803
diff changeset
   468
            for f in dirs:
7e2b9f6a2cd0 largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents: 17803
diff changeset
   469
                matcheddir = False
7e2b9f6a2cd0 largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents: 17803
diff changeset
   470
                d = self.dirstate.normalize(f) + '/'
7e2b9f6a2cd0 largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents: 17803
diff changeset
   471
                # Check for matched normal files
7e2b9f6a2cd0 largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents: 17803
diff changeset
   472
                for mf in regulars:
7e2b9f6a2cd0 largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents: 17803
diff changeset
   473
                    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
   474
                        actualfiles.append(f)
7e2b9f6a2cd0 largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents: 17803
diff changeset
   475
                        matcheddir = True
7e2b9f6a2cd0 largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents: 17803
diff changeset
   476
                        break
7e2b9f6a2cd0 largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents: 17803
diff changeset
   477
                if not matcheddir:
7e2b9f6a2cd0 largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents: 17803
diff changeset
   478
                    # If no normal match, manually append
7e2b9f6a2cd0 largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents: 17803
diff changeset
   479
                    # any matching largefiles
7e2b9f6a2cd0 largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents: 17803
diff changeset
   480
                    for lf in lfiles:
7e2b9f6a2cd0 largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents: 17803
diff changeset
   481
                        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
   482
                            actualfiles.append(lf)
7e2b9f6a2cd0 largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents: 17803
diff changeset
   483
                            if not matcheddir:
7e2b9f6a2cd0 largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents: 17803
diff changeset
   484
                                actualfiles.append(lfutil.standin(f))
7e2b9f6a2cd0 largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents: 17803
diff changeset
   485
                                matcheddir = True
7e2b9f6a2cd0 largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents: 17803
diff changeset
   486
                # Nothing in dir, so readd it
7e2b9f6a2cd0 largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents: 17803
diff changeset
   487
                # and let commit reject it
7e2b9f6a2cd0 largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents: 17803
diff changeset
   488
                if not matcheddir:
7e2b9f6a2cd0 largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents: 17803
diff changeset
   489
                    actualfiles.append(f)
7e2b9f6a2cd0 largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents: 17803
diff changeset
   490
7e2b9f6a2cd0 largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents: 17803
diff changeset
   491
            # Always add normal files
7e2b9f6a2cd0 largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents: 17803
diff changeset
   492
            actualfiles += regulars
7e2b9f6a2cd0 largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents: 17803
diff changeset
   493
            return actualfiles
7e2b9f6a2cd0 largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents: 17803
diff changeset
   494
16247
d87d9d8a8e03 largefiles: remove use of underscores that breaks coding convention
Na'Tosha Bard <natosha@unity3d.com>
parents: 16141
diff changeset
   495
    repo.__class__ = lfilesrepo
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   496
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   497
    def checkrequireslfiles(ui, repo, **kwargs):
15319
9da7e96cd5c2 largefiles: remove redundant any_ function
Benjamin Pollack <benjamin@bitquabit.com>
parents: 15316
diff changeset
   498
        if 'largefiles' not in repo.requirements and util.any(
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   499
                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
   500
            repo.requirements.add('largefiles')
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   501
            repo._writerequirements()
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   502
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   503
    ui.setconfig('hooks', 'changegroup.lfiles', checkrequireslfiles)
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   504
    ui.setconfig('hooks', 'commit.lfiles', checkrequireslfiles)