hgext/largefiles/reposetup.py
author Martin von Zweigbergk <martinvonz@gmail.com>
Fri, 03 Oct 2014 21:44:10 -0700
changeset 22911 509e2cbee679
parent 22525 764127f58903
child 22914 c95db3208a33
permissions -rw-r--r--
dirstate: separate 'lookup' status field from others The status tuple returned from dirstate.status() has an additional field compared to the other status tuples: lookup/unsure. This field is just an optimization and not something most callers care about (they want the resolved value of 'modified' or 'clean'). To prepare for a single future status type, let's separate out the 'lookup' field from the rest by having dirstate.status() return a pair: (lookup, status).
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 os
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    12
21044
52a5eabf1f2f largefiles: reuse "findcommonoutgoing()" result at "hg push"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 21042
diff changeset
    13
from mercurial import error, manifest, match as match_, util
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    14
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
    15
from mercurial import localrepo
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    16
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    17
import lfcommands
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    18
import lfutil
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    19
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    20
def reposetup(ui, repo):
20858
bc56ec9e64df hg: introduce "wirepeersetupfuncs" to setup wire peer by extensions (issue4109)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20177
diff changeset
    21
    # wire repositories should be given new wireproto functions
bc56ec9e64df hg: introduce "wirepeersetupfuncs" to setup wire peer by extensions (issue4109)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20177
diff changeset
    22
    # by "proto.wirereposetup()" via "hg.wirepeersetupfuncs"
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    23
    if not repo.local():
20858
bc56ec9e64df hg: introduce "wirepeersetupfuncs" to setup wire peer by extensions (issue4109)
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 20177
diff changeset
    24
        return
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    25
16247
d87d9d8a8e03 largefiles: remove use of underscores that breaks coding convention
Na'Tosha Bard <natosha@unity3d.com>
parents: 16141
diff changeset
    26
    class lfilesrepo(repo.__class__):
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    27
        lfstatus = False
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    28
        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
    29
            return super(lfilesrepo, self).status(*args, **kwargs)
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    30
15252
6e809bb4f969 largefiles: improve comments, internal docstrings
Greg Ward <greg@gerg.ca>
parents: 15250
diff changeset
    31
        # 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
    32
        # of largefiles instead of their corresponding standins and
6e809bb4f969 largefiles: improve comments, internal docstrings
Greg Ward <greg@gerg.ca>
parents: 15250
diff changeset
    33
        # identifies the largefiles as always binary, regardless of
6e809bb4f969 largefiles: improve comments, internal docstrings
Greg Ward <greg@gerg.ca>
parents: 15250
diff changeset
    34
        # their actual contents.
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    35
        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
    36
            ctx = super(lfilesrepo, self).__getitem__(changeid)
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    37
            if self.lfstatus:
16247
d87d9d8a8e03 largefiles: remove use of underscores that breaks coding convention
Na'Tosha Bard <natosha@unity3d.com>
parents: 16141
diff changeset
    38
                class lfilesmanifestdict(manifest.manifestdict):
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    39
                    def __contains__(self, filename):
22516
5e27eccbc0a4 largefiles: extract 'orig' method in lfilesmanifestdict.__contains__
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22515
diff changeset
    40
                        orig = super(lfilesmanifestdict, self).__contains__
5e27eccbc0a4 largefiles: extract 'orig' method in lfilesmanifestdict.__contains__
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22515
diff changeset
    41
                        return orig(filename) or orig(lfutil.standin(filename))
16247
d87d9d8a8e03 largefiles: remove use of underscores that breaks coding convention
Na'Tosha Bard <natosha@unity3d.com>
parents: 16141
diff changeset
    42
                class lfilesctx(ctx.__class__):
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    43
                    def files(self):
16247
d87d9d8a8e03 largefiles: remove use of underscores that breaks coding convention
Na'Tosha Bard <natosha@unity3d.com>
parents: 16141
diff changeset
    44
                        filenames = super(lfilesctx, self).files()
15628
2b40513384ca largefiles: use lfutil functions
Martin Geisler <mg@aragost.com>
parents: 15626
diff changeset
    45
                        return [lfutil.splitstandin(f) or f for f in filenames]
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    46
                    def manifest(self):
16247
d87d9d8a8e03 largefiles: remove use of underscores that breaks coding convention
Na'Tosha Bard <natosha@unity3d.com>
parents: 16141
diff changeset
    47
                        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
    48
                        man1.__class__ = lfilesmanifestdict
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    49
                        return man1
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    50
                    def filectx(self, path, fileid=None, filelog=None):
22517
e54a001ace06 largefiles: extract 'orig' method in lfilesctx.filectx
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22516
diff changeset
    51
                        orig = super(lfilesctx, self).filectx
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    52
                        try:
16141
f346de4dff57 largefiles: don't break filesets
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 16110
diff changeset
    53
                            if filelog is not None:
22517
e54a001ace06 largefiles: extract 'orig' method in lfilesctx.filectx
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22516
diff changeset
    54
                                result = orig(path, fileid, filelog)
16141
f346de4dff57 largefiles: don't break filesets
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 16110
diff changeset
    55
                            else:
22517
e54a001ace06 largefiles: extract 'orig' method in lfilesctx.filectx
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22516
diff changeset
    56
                                result = orig(path, fileid)
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    57
                        except error.LookupError:
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    58
                            # Adding a null character will cause Mercurial to
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    59
                            # identify this as a binary file.
16141
f346de4dff57 largefiles: don't break filesets
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 16110
diff changeset
    60
                            if filelog is not None:
22517
e54a001ace06 largefiles: extract 'orig' method in lfilesctx.filectx
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22516
diff changeset
    61
                                result = orig(lfutil.standin(path), fileid,
e54a001ace06 largefiles: extract 'orig' method in lfilesctx.filectx
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22516
diff changeset
    62
                                              filelog)
16141
f346de4dff57 largefiles: don't break filesets
Dan Villiom Podlaski Christiansen <danchr@gmail.com>
parents: 16110
diff changeset
    63
                            else:
22517
e54a001ace06 largefiles: extract 'orig' method in lfilesctx.filectx
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22516
diff changeset
    64
                                result = orig(lfutil.standin(path), fileid)
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    65
                            olddata = result.data
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    66
                            result.data = lambda: olddata() + '\0'
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    67
                        return result
16247
d87d9d8a8e03 largefiles: remove use of underscores that breaks coding convention
Na'Tosha Bard <natosha@unity3d.com>
parents: 16141
diff changeset
    68
                ctx.__class__ = lfilesctx
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    69
            return ctx
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    70
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    71
        # 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
    72
        # appropriate list in the result. Also removes standin files
6e809bb4f969 largefiles: improve comments, internal docstrings
Greg Ward <greg@gerg.ca>
parents: 15250
diff changeset
    73
        # from the listing. Revert to the original status if
6e809bb4f969 largefiles: improve comments, internal docstrings
Greg Ward <greg@gerg.ca>
parents: 15250
diff changeset
    74
        # 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
    75
        # 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
    76
        # 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
    77
        @localrepo.unfilteredmethod
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    78
        def status(self, node1='.', node2=None, match=None, ignored=False,
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    79
                clean=False, unknown=False, listsubrepos=False):
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    80
            listignored, listclean, listunknown = ignored, clean, unknown
22518
52dd6e25121f largefiles: extract 'orig' method in reposetup.status
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22517
diff changeset
    81
            orig = super(lfilesrepo, self).status
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    82
            if not self.lfstatus:
22518
52dd6e25121f largefiles: extract 'orig' method in reposetup.status
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22517
diff changeset
    83
                return orig(node1, node2, match, listignored, listclean,
52dd6e25121f largefiles: extract 'orig' method in reposetup.status
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22517
diff changeset
    84
                            listunknown, listsubrepos)
22515
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
    85
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
    86
            # some calls in this function rely on the old version of status
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
    87
            self.lfstatus = False
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
    88
            ctx1 = self[node1]
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
    89
            ctx2 = self[node2]
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
    90
            working = ctx2.rev() is None
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
    91
            parentworking = working and ctx1 == self['.']
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
    92
22515
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
    93
            def inctx(file, ctx):
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
    94
                try:
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
    95
                    if ctx.rev() is None:
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
    96
                        return file in ctx.manifest()
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
    97
                    ctx[file]
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
    98
                    return True
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
    99
                except KeyError:
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   100
                    return False
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   101
22515
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   102
            if match is None:
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   103
                match = match_.always(self.root, self.getcwd())
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   104
22515
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   105
            wlock = None
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   106
            try:
19056
ac41bb76c737 largefiles: wlock in status before lfdirstate.write()
Mads Kiilerich <madski@unity3d.com>
parents: 18969
diff changeset
   107
                try:
22515
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   108
                    # updating the dirstate is optional
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   109
                    # so we don't wait on the lock
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   110
                    wlock = self.wlock(False)
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   111
                except error.LockError:
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   112
                    pass
15653
93c77d5b9752 largefiles: optimize status when files are specified (issue3144)
Na'Tosha Bard <natosha@unity3d.com>
parents: 15630
diff changeset
   113
22515
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   114
                # First check if there were files specified on the
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   115
                # command line.  If there were, and none of them were
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   116
                # largefiles, we should just bail here and let super
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   117
                # handle it -- thus gaining a big performance boost.
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   118
                lfdirstate = lfutil.openlfdirstate(ui, self)
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   119
                if match.files() and not match.anypats():
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   120
                    for f in lfdirstate:
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   121
                        if match(f):
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   122
                            break
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   123
                    else:
22518
52dd6e25121f largefiles: extract 'orig' method in reposetup.status
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22517
diff changeset
   124
                        return orig(node1, node2, match, listignored, listclean,
52dd6e25121f largefiles: extract 'orig' method in reposetup.status
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22517
diff changeset
   125
                                    listunknown, listsubrepos)
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   126
22515
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   127
                # Create a copy of match that matches standins instead
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   128
                # of largefiles.
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   129
                def tostandins(files):
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   130
                    if not working:
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   131
                        return files
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   132
                    newfiles = []
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   133
                    dirstate = self.dirstate
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   134
                    for f in files:
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   135
                        sf = lfutil.standin(f)
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   136
                        if sf in dirstate:
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   137
                            newfiles.append(sf)
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   138
                        elif sf in dirstate.dirs():
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   139
                            # Directory entries could be regular or
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   140
                            # standin, check both
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   141
                            newfiles.extend((f, sf))
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   142
                        else:
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   143
                            newfiles.append(f)
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   144
                    return newfiles
18149
2dcc3653b361 largefiles: unindent code
Mads Kiilerich <madski@unity3d.com>
parents: 18148
diff changeset
   145
22515
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   146
                m = copy.copy(match)
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   147
                m._files = tostandins(m._files)
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   148
22518
52dd6e25121f largefiles: extract 'orig' method in reposetup.status
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22517
diff changeset
   149
                result = orig(node1, node2, m, ignored, clean, unknown,
52dd6e25121f largefiles: extract 'orig' method in reposetup.status
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22517
diff changeset
   150
                              listsubrepos)
22515
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   151
                if working:
15617
74e691b141c4 largefiles: optimize performance of status on largefiles repos (issue3136)
Na'Tosha Bard <natosha@unity3d.com>
parents: 15385
diff changeset
   152
22515
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   153
                    def sfindirstate(f):
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   154
                        sf = lfutil.standin(f)
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   155
                        dirstate = self.dirstate
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   156
                        return sf in dirstate or sf in dirstate.dirs()
18149
2dcc3653b361 largefiles: unindent code
Mads Kiilerich <madski@unity3d.com>
parents: 18148
diff changeset
   157
22515
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   158
                    match._files = [f for f in match._files
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   159
                                    if sfindirstate(f)]
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   160
                    # Don't waste time getting the ignored and unknown
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   161
                    # files from lfdirstate
22911
509e2cbee679 dirstate: separate 'lookup' status field from others
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22525
diff changeset
   162
                    unsure, s = lfdirstate.status(match, [], False, listclean,
509e2cbee679 dirstate: separate 'lookup' status field from others
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22525
diff changeset
   163
                                                  False)
509e2cbee679 dirstate: separate 'lookup' status field from others
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22525
diff changeset
   164
                    (modified, added, removed, missing, _unknown, _ignored,
509e2cbee679 dirstate: separate 'lookup' status field from others
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22525
diff changeset
   165
                     clean) = s
22515
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   166
                    if parentworking:
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   167
                        for lfile in unsure:
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   168
                            standin = lfutil.standin(lfile)
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   169
                            if standin not in ctx1:
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   170
                                # from second parent
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   171
                                modified.append(lfile)
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   172
                            elif ctx1[standin].data().strip() \
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   173
                                    != lfutil.hashfile(self.wjoin(lfile)):
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   174
                                modified.append(lfile)
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   175
                            else:
22523
8cd91f481ffd largefiles: remove unnecessary clearing of status fields
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22518
diff changeset
   176
                                if listclean:
8cd91f481ffd largefiles: remove unnecessary clearing of status fields
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22518
diff changeset
   177
                                    clean.append(lfile)
22515
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   178
                                lfdirstate.normal(lfile)
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   179
                    else:
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   180
                        tocheck = unsure + modified + added + clean
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   181
                        modified, added, clean = [], [], []
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   182
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   183
                        for lfile in tocheck:
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   184
                            standin = lfutil.standin(lfile)
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   185
                            if inctx(standin, ctx1):
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   186
                                if ctx1[standin].data().strip() != \
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   187
                                        lfutil.hashfile(self.wjoin(lfile)):
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   188
                                    modified.append(lfile)
22523
8cd91f481ffd largefiles: remove unnecessary clearing of status fields
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22518
diff changeset
   189
                                elif listclean:
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   190
                                    clean.append(lfile)
22515
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   191
                            else:
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   192
                                added.append(lfile)
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   193
22515
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   194
                    # Standins no longer found in lfdirstate has been
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   195
                    # removed
22525
764127f58903 largefiles: simplify iteration over standins
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22524
diff changeset
   196
                    for standin in ctx1.walk(lfutil.getstandinmatcher(self)):
22515
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   197
                        lfile = lfutil.splitstandin(standin)
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   198
                        if not match(lfile):
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   199
                            continue
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   200
                        if lfile not in lfdirstate:
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   201
                            removed.append(lfile)
15663
9036c7d106bf largefiles: handle merges between normal files and largefiles (issue3084)
Martin Geisler <mg@aragost.com>
parents: 15629
diff changeset
   202
22515
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   203
                    # Filter result lists
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   204
                    result = list(result)
19056
ac41bb76c737 largefiles: wlock in status before lfdirstate.write()
Mads Kiilerich <madski@unity3d.com>
parents: 18969
diff changeset
   205
22515
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   206
                    # Largefiles are not really removed when they're
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   207
                    # still in the normal dirstate. Likewise, normal
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   208
                    # files are not really removed if they are still in
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   209
                    # lfdirstate. This happens in merges where files
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   210
                    # change type.
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   211
                    removed = [f for f in removed
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   212
                               if f not in self.dirstate]
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   213
                    result[2] = [f for f in result[2]
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   214
                                 if f not in lfdirstate]
15663
9036c7d106bf largefiles: handle merges between normal files and largefiles (issue3084)
Martin Geisler <mg@aragost.com>
parents: 15629
diff changeset
   215
22515
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   216
                    lfiles = set(lfdirstate._map)
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   217
                    # Unknown files
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   218
                    result[4] = set(result[4]).difference(lfiles)
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   219
                    # Ignored files
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   220
                    result[5] = set(result[5]).difference(lfiles)
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   221
                    # combine normal files and largefiles
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   222
                    normals = [[fn for fn in filelist
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   223
                                if not lfutil.isstandin(fn)]
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   224
                               for filelist in result]
22524
8c8fe120670f largefiles: avoid using 'lfiles' variable for two purposes
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22523
diff changeset
   225
                    lfstatus = (modified, added, removed, missing, [], [],
8c8fe120670f largefiles: avoid using 'lfiles' variable for two purposes
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22523
diff changeset
   226
                                clean)
22515
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   227
                    result = [sorted(list1 + list2)
22524
8c8fe120670f largefiles: avoid using 'lfiles' variable for two purposes
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22523
diff changeset
   228
                              for (list1, list2) in zip(normals, lfstatus)]
22515
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   229
                else:
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   230
                    def toname(f):
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   231
                        if lfutil.isstandin(f):
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   232
                            return lfutil.splitstandin(f)
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   233
                        return f
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   234
                    result = [[toname(f) for f in items]
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   235
                              for items in result]
15663
9036c7d106bf largefiles: handle merges between normal files and largefiles (issue3084)
Martin Geisler <mg@aragost.com>
parents: 15629
diff changeset
   236
22515
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   237
                if wlock:
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   238
                    lfdirstate.write()
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   239
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   240
            finally:
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   241
                if wlock:
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   242
                    wlock.release()
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   243
22515
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   244
            self.lfstatus = True
b4e251b7e9a8 largefiles: reduce indentation by dropping 'else' block after 'return'
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22514
diff changeset
   245
            return result
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   246
15254
dd03d3a9f888 largefiles: more work on cleaning up comments
Greg Ward <greg@gerg.ca>
parents: 15253
diff changeset
   247
        # 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
   248
        # cache.
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   249
        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
   250
            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
   251
            lfutil.copyalltostore(self, node)
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   252
            return node
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   253
15254
dd03d3a9f888 largefiles: more work on cleaning up comments
Greg Ward <greg@gerg.ca>
parents: 15253
diff changeset
   254
        # 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
   255
        # 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
   256
        # Do that here.
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   257
        def commit(self, text="", user=None, date=None, match=None,
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   258
                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
   259
            orig = super(lfilesrepo, self).commit
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   260
17803
1479572db256 largefile: use `self` in repo method instead of `repo`
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 17424
diff changeset
   261
            wlock = self.wlock()
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   262
            try:
22290
dcb95aadf850 largefiles: remove redundant "updatelfiles" invocation in "lfilesrepo.commit"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 22098
diff changeset
   263
                # Case 0: Automated committing
dcb95aadf850 largefiles: remove redundant "updatelfiles" invocation in "lfilesrepo.commit"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 22098
diff changeset
   264
                #
dcb95aadf850 largefiles: remove redundant "updatelfiles" invocation in "lfilesrepo.commit"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 22098
diff changeset
   265
                # While automated committing (like rebase, transplant
dcb95aadf850 largefiles: remove redundant "updatelfiles" invocation in "lfilesrepo.commit"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 22098
diff changeset
   266
                # and so on), this code path is used to avoid:
dcb95aadf850 largefiles: remove redundant "updatelfiles" invocation in "lfilesrepo.commit"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 22098
diff changeset
   267
                # (1) updating standins, because standins should
dcb95aadf850 largefiles: remove redundant "updatelfiles" invocation in "lfilesrepo.commit"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 22098
diff changeset
   268
                #     be already updated at this point
dcb95aadf850 largefiles: remove redundant "updatelfiles" invocation in "lfilesrepo.commit"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 22098
diff changeset
   269
                # (2) aborting when stadnins are matched by "match",
dcb95aadf850 largefiles: remove redundant "updatelfiles" invocation in "lfilesrepo.commit"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 22098
diff changeset
   270
                #     because automated committing may specify them directly
dcb95aadf850 largefiles: remove redundant "updatelfiles" invocation in "lfilesrepo.commit"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 22098
diff changeset
   271
                #
17803
1479572db256 largefile: use `self` in repo method instead of `repo`
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 17424
diff changeset
   272
                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
   273
                        getattr(self, "_istransplanting", False):
15793
3ef07ecdb0d5 largefiles: correctly handle dirstate status when rebasing
Na'Tosha Bard <natosha@unity3d.com>
parents: 15789
diff changeset
   274
                    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
   275
                                    force=force, editor=editor, extra=extra)
22098
2fb3c1c0b4ef largefiles: synchronize lfdirstate with dirstate after automated committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 21044
diff changeset
   276
2fb3c1c0b4ef largefiles: synchronize lfdirstate with dirstate after automated committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 21044
diff changeset
   277
                    if result:
2fb3c1c0b4ef largefiles: synchronize lfdirstate with dirstate after automated committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 21044
diff changeset
   278
                        lfdirstate = lfutil.openlfdirstate(ui, self)
2fb3c1c0b4ef largefiles: synchronize lfdirstate with dirstate after automated committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 21044
diff changeset
   279
                        for f in self[result].files():
2fb3c1c0b4ef largefiles: synchronize lfdirstate with dirstate after automated committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 21044
diff changeset
   280
                            if lfutil.isstandin(f):
2fb3c1c0b4ef largefiles: synchronize lfdirstate with dirstate after automated committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 21044
diff changeset
   281
                                lfile = lfutil.splitstandin(f)
2fb3c1c0b4ef largefiles: synchronize lfdirstate with dirstate after automated committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 21044
diff changeset
   282
                                lfutil.synclfdirstate(self, lfdirstate, lfile,
2fb3c1c0b4ef largefiles: synchronize lfdirstate with dirstate after automated committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 21044
diff changeset
   283
                                                      False)
2fb3c1c0b4ef largefiles: synchronize lfdirstate with dirstate after automated committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 21044
diff changeset
   284
                        lfdirstate.write()
2fb3c1c0b4ef largefiles: synchronize lfdirstate with dirstate after automated committing
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 21044
diff changeset
   285
15793
3ef07ecdb0d5 largefiles: correctly handle dirstate status when rebasing
Na'Tosha Bard <natosha@unity3d.com>
parents: 15789
diff changeset
   286
                    return result
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   287
                # 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
   288
                # 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
   289
                # are "dirty".
15255
7ab05d752405 largefiles: cosmetics, whitespace, code style
Greg Ward <greg@gerg.ca>
parents: 15254
diff changeset
   290
                if ((match is None) or
7ab05d752405 largefiles: cosmetics, whitespace, code style
Greg Ward <greg@gerg.ca>
parents: 15254
diff changeset
   291
                    (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
   292
                    # 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
   293
                    # 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
   294
                    # 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
   295
                    # 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
   296
                    # large.
f172292cd416 largefiles: speed up commit by only rewriting standins for modified largefiles
Na'Tosha Bard <natosha@unity3d.com>
parents: 15224
diff changeset
   297
                    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
   298
                    dirtymatch = match_.always(self.root, self.getcwd())
22911
509e2cbee679 dirstate: separate 'lookup' status field from others
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22525
diff changeset
   299
                    unsure, s = lfdirstate.status(dirtymatch, [], False, False,
509e2cbee679 dirstate: separate 'lookup' status field from others
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22525
diff changeset
   300
                                                  False)
509e2cbee679 dirstate: separate 'lookup' status field from others
Martin von Zweigbergk <martinvonz@gmail.com>
parents: 22525
diff changeset
   301
                    modified, added, removed = s[:3]
18726
431b246cfb12 largefiles: missing largefiles should not be committed as removed
Mads Kiilerich <madski@unity3d.com>
parents: 18182
diff changeset
   302
                    modifiedfiles = unsure + modified + added + removed
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   303
                    lfiles = lfutil.listlfiles(self)
15254
dd03d3a9f888 largefiles: more work on cleaning up comments
Greg Ward <greg@gerg.ca>
parents: 15253
diff changeset
   304
                    # this only loops through largefiles that exist (not
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   305
                    # removed/renamed)
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   306
                    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
   307
                        if lfile in modifiedfiles:
16248
51e6f318bdf1 largefiles: fix check-code errors.
Na'Tosha Bard <natosha@unity3d.com>
parents: 16247
diff changeset
   308
                            if os.path.exists(
51e6f318bdf1 largefiles: fix check-code errors.
Na'Tosha Bard <natosha@unity3d.com>
parents: 16247
diff changeset
   309
                                    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
   310
                                # 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
   311
                                # 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
   312
                                # yet.
f172292cd416 largefiles: speed up commit by only rewriting standins for modified largefiles
Na'Tosha Bard <natosha@unity3d.com>
parents: 15224
diff changeset
   313
                                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
   314
                                    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
   315
                                        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
   316
                                    lfdirstate.normal(lfile)
15794
0d91211dd12f largefiles: fix inappropriate locking (issue3182)
Levi Bard <levi@unity3d.com>
parents: 15793
diff changeset
   317
0d91211dd12f largefiles: fix inappropriate locking (issue3182)
Levi Bard <levi@unity3d.com>
parents: 15793
diff changeset
   318
                    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
   319
                                    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
   320
fc4c155658b7 largefiles: defer lfdirstate.drop() until after commit (issue3364)
Matt Harbison <matt_harbison@yahoo.com>
parents: 16731
diff changeset
   321
                    if result is not None:
fc4c155658b7 largefiles: defer lfdirstate.drop() until after commit (issue3364)
Matt Harbison <matt_harbison@yahoo.com>
parents: 16731
diff changeset
   322
                        for lfile in lfdirstate:
fc4c155658b7 largefiles: defer lfdirstate.drop() until after commit (issue3364)
Matt Harbison <matt_harbison@yahoo.com>
parents: 16731
diff changeset
   323
                            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
   324
                                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
   325
                                   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
   326
                                   (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
   327
                                    lfdirstate.drop(lfile)
fc4c155658b7 largefiles: defer lfdirstate.drop() until after commit (issue3364)
Matt Harbison <matt_harbison@yahoo.com>
parents: 16731
diff changeset
   328
15794
0d91211dd12f largefiles: fix inappropriate locking (issue3182)
Levi Bard <levi@unity3d.com>
parents: 15793
diff changeset
   329
                    # This needs to be after commit; otherwise precommit hooks
0d91211dd12f largefiles: fix inappropriate locking (issue3182)
Levi Bard <levi@unity3d.com>
parents: 15793
diff changeset
   330
                    # get the wrong status
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   331
                    lfdirstate.write()
15794
0d91211dd12f largefiles: fix inappropriate locking (issue3182)
Levi Bard <levi@unity3d.com>
parents: 15793
diff changeset
   332
                    return result
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   333
18064
7e2b9f6a2cd0 largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents: 17803
diff changeset
   334
                lfiles = lfutil.listlfiles(self)
7e2b9f6a2cd0 largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents: 17803
diff changeset
   335
                match._files = self._subdirlfs(match.files(), lfiles)
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   336
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   337
                # Case 2: user calls commit with specified patterns: refresh
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   338
                # any matching big files.
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   339
                smatcher = lfutil.composestandinmatcher(self, match)
18154
93c697d9c158 largefiles: remove trivial portability wrappers
Mads Kiilerich <madski@unity3d.com>
parents: 18152
diff changeset
   340
                standins = self.dirstate.walk(smatcher, [], False, False)
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   341
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   342
                # No matching big files: get out of the way and pass control to
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   343
                # the usual commit() method.
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   344
                if not standins:
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   345
                    return orig(text=text, user=user, date=date, match=match,
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   346
                                    force=force, editor=editor, extra=extra)
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   347
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   348
                # Refresh all matching big files.  It's possible that the
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   349
                # commit will end up failing, in which case the big files will
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   350
                # stay refreshed.  No harm done: the user modified them and
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   351
                # asked to commit them, so sooner or later we're going to
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   352
                # refresh the standins.  Might as well leave them refreshed.
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   353
                lfdirstate = lfutil.openlfdirstate(ui, self)
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   354
                for standin in standins:
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   355
                    lfile = lfutil.splitstandin(standin)
18182
e6db64abfa87 largefiles: stop using <> operator in favor of !=
Augie Fackler <raf@durin42.com>
parents: 18154
diff changeset
   356
                    if lfdirstate[lfile] != 'r':
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   357
                        lfutil.updatestandin(self, standin)
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   358
                        lfdirstate.normal(lfile)
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   359
                    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
   360
                        lfdirstate.drop(lfile)
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   361
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   362
                # Cook up a new matcher that only matches regular files or
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   363
                # standins corresponding to the big files requested by the
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   364
                # user.  Have to modify _files to prevent commit() from
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   365
                # complaining "not tracked" for big files.
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   366
                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
   367
                origmatchfn = match.matchfn
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   368
15254
dd03d3a9f888 largefiles: more work on cleaning up comments
Greg Ward <greg@gerg.ca>
parents: 15253
diff changeset
   369
                # 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
   370
                # 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
   371
                # won't be in the list of largefiles at this point
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   372
                match._files += sorted(standins)
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   373
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   374
                actualfiles = []
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   375
                for f in match._files:
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   376
                    fstandin = lfutil.standin(f)
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   377
15252
6e809bb4f969 largefiles: improve comments, internal docstrings
Greg Ward <greg@gerg.ca>
parents: 15250
diff changeset
   378
                    # ignore known largefiles and standins
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   379
                    if f in lfiles or fstandin in standins:
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   380
                        continue
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   381
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   382
                    actualfiles.append(f)
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   383
                match._files = actualfiles
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   384
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   385
                def matchfn(f):
16247
d87d9d8a8e03 largefiles: remove use of underscores that breaks coding convention
Na'Tosha Bard <natosha@unity3d.com>
parents: 16141
diff changeset
   386
                    if origmatchfn(f):
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   387
                        return f not in lfiles
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   388
                    else:
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   389
                        return f in standins
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   390
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   391
                match.matchfn = matchfn
15794
0d91211dd12f largefiles: fix inappropriate locking (issue3182)
Levi Bard <levi@unity3d.com>
parents: 15793
diff changeset
   392
                result = orig(text=text, user=user, date=date, match=match,
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   393
                                force=force, editor=editor, extra=extra)
15794
0d91211dd12f largefiles: fix inappropriate locking (issue3182)
Levi Bard <levi@unity3d.com>
parents: 15793
diff changeset
   394
                # This needs to be after commit; otherwise precommit hooks
0d91211dd12f largefiles: fix inappropriate locking (issue3182)
Levi Bard <levi@unity3d.com>
parents: 15793
diff changeset
   395
                # get the wrong status
0d91211dd12f largefiles: fix inappropriate locking (issue3182)
Levi Bard <levi@unity3d.com>
parents: 15793
diff changeset
   396
                lfdirstate.write()
0d91211dd12f largefiles: fix inappropriate locking (issue3182)
Levi Bard <levi@unity3d.com>
parents: 15793
diff changeset
   397
                return result
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   398
            finally:
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   399
                wlock.release()
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   400
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   401
        def push(self, remote, force=False, revs=None, newbranch=False):
19779
fb6e87d93948 largefiles: setup "largefiles" feature in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 19570
diff changeset
   402
            if remote.local():
fb6e87d93948 largefiles: setup "largefiles" feature in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 19570
diff changeset
   403
                missing = set(self.requirements) - remote.local().supported
fb6e87d93948 largefiles: setup "largefiles" feature in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 19570
diff changeset
   404
                if missing:
fb6e87d93948 largefiles: setup "largefiles" feature in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 19570
diff changeset
   405
                    msg = _("required features are not"
fb6e87d93948 largefiles: setup "largefiles" feature in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 19570
diff changeset
   406
                            " supported in the destination:"
fb6e87d93948 largefiles: setup "largefiles" feature in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 19570
diff changeset
   407
                            " %s") % (', '.join(sorted(missing)))
fb6e87d93948 largefiles: setup "largefiles" feature in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 19570
diff changeset
   408
                    raise util.Abort(msg)
20177
c5f0574034ef largefiles: call super class method with proper kwargs to respect API
Long Vu <long@tlvu.ca>
parents: 19779
diff changeset
   409
            return super(lfilesrepo, self).push(remote, force=force, revs=revs,
c5f0574034ef largefiles: call super class method with proper kwargs to respect API
Long Vu <long@tlvu.ca>
parents: 19779
diff changeset
   410
                newbranch=newbranch)
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   411
18064
7e2b9f6a2cd0 largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents: 17803
diff changeset
   412
        def _subdirlfs(self, files, lfiles):
7e2b9f6a2cd0 largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents: 17803
diff changeset
   413
            '''
7e2b9f6a2cd0 largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents: 17803
diff changeset
   414
            Adjust matched file list
7e2b9f6a2cd0 largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents: 17803
diff changeset
   415
            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
   416
            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
   417
            the largefiles.
7e2b9f6a2cd0 largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents: 17803
diff changeset
   418
            So we do the following:
7e2b9f6a2cd0 largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents: 17803
diff changeset
   419
            For directories that only have largefiles as matches,
18644
3e92772d5383 spelling: fix some minor issues found by spell checker
Mads Kiilerich <mads@kiilerich.com>
parents: 18182
diff changeset
   420
            we explicitly add the largefiles to the match list and remove
18064
7e2b9f6a2cd0 largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents: 17803
diff changeset
   421
            the directory.
7e2b9f6a2cd0 largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents: 17803
diff changeset
   422
            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
   423
            '''
7e2b9f6a2cd0 largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents: 17803
diff changeset
   424
            actualfiles = []
7e2b9f6a2cd0 largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents: 17803
diff changeset
   425
            dirs = []
7e2b9f6a2cd0 largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents: 17803
diff changeset
   426
            regulars = []
7e2b9f6a2cd0 largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents: 17803
diff changeset
   427
7e2b9f6a2cd0 largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents: 17803
diff changeset
   428
            for f in files:
7e2b9f6a2cd0 largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents: 17803
diff changeset
   429
                if lfutil.isstandin(f + '/'):
7e2b9f6a2cd0 largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents: 17803
diff changeset
   430
                    raise util.Abort(
7e2b9f6a2cd0 largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents: 17803
diff changeset
   431
                        _('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
   432
                        hint=('commit the largefile itself instead'))
7e2b9f6a2cd0 largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents: 17803
diff changeset
   433
                # Scan directories
7e2b9f6a2cd0 largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents: 17803
diff changeset
   434
                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
   435
                    dirs.append(f)
7e2b9f6a2cd0 largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents: 17803
diff changeset
   436
                else:
7e2b9f6a2cd0 largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents: 17803
diff changeset
   437
                    regulars.append(f)
7e2b9f6a2cd0 largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents: 17803
diff changeset
   438
7e2b9f6a2cd0 largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents: 17803
diff changeset
   439
            for f in dirs:
7e2b9f6a2cd0 largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents: 17803
diff changeset
   440
                matcheddir = False
7e2b9f6a2cd0 largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents: 17803
diff changeset
   441
                d = self.dirstate.normalize(f) + '/'
7e2b9f6a2cd0 largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents: 17803
diff changeset
   442
                # Check for matched normal files
7e2b9f6a2cd0 largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents: 17803
diff changeset
   443
                for mf in regulars:
7e2b9f6a2cd0 largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents: 17803
diff changeset
   444
                    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
   445
                        actualfiles.append(f)
7e2b9f6a2cd0 largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents: 17803
diff changeset
   446
                        matcheddir = True
7e2b9f6a2cd0 largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents: 17803
diff changeset
   447
                        break
7e2b9f6a2cd0 largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents: 17803
diff changeset
   448
                if not matcheddir:
7e2b9f6a2cd0 largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents: 17803
diff changeset
   449
                    # If no normal match, manually append
7e2b9f6a2cd0 largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents: 17803
diff changeset
   450
                    # any matching largefiles
7e2b9f6a2cd0 largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents: 17803
diff changeset
   451
                    for lf in lfiles:
7e2b9f6a2cd0 largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents: 17803
diff changeset
   452
                        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
   453
                            actualfiles.append(lf)
7e2b9f6a2cd0 largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents: 17803
diff changeset
   454
                            if not matcheddir:
7e2b9f6a2cd0 largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents: 17803
diff changeset
   455
                                actualfiles.append(lfutil.standin(f))
7e2b9f6a2cd0 largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents: 17803
diff changeset
   456
                                matcheddir = True
7e2b9f6a2cd0 largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents: 17803
diff changeset
   457
                # Nothing in dir, so readd it
7e2b9f6a2cd0 largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents: 17803
diff changeset
   458
                # and let commit reject it
7e2b9f6a2cd0 largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents: 17803
diff changeset
   459
                if not matcheddir:
7e2b9f6a2cd0 largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents: 17803
diff changeset
   460
                    actualfiles.append(f)
7e2b9f6a2cd0 largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents: 17803
diff changeset
   461
7e2b9f6a2cd0 largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents: 17803
diff changeset
   462
            # Always add normal files
7e2b9f6a2cd0 largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents: 17803
diff changeset
   463
            actualfiles += regulars
7e2b9f6a2cd0 largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents: 17803
diff changeset
   464
            return actualfiles
7e2b9f6a2cd0 largefiles: commit directories that only contain largefiles (issue3548)
Levi Bard <levi@unity3d.com>
parents: 17803
diff changeset
   465
16247
d87d9d8a8e03 largefiles: remove use of underscores that breaks coding convention
Na'Tosha Bard <natosha@unity3d.com>
parents: 16141
diff changeset
   466
    repo.__class__ = lfilesrepo
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   467
21044
52a5eabf1f2f largefiles: reuse "findcommonoutgoing()" result at "hg push"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 21042
diff changeset
   468
    def prepushoutgoinghook(local, remote, outgoing):
52a5eabf1f2f largefiles: reuse "findcommonoutgoing()" result at "hg push"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 21042
diff changeset
   469
        if outgoing.missing:
52a5eabf1f2f largefiles: reuse "findcommonoutgoing()" result at "hg push"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 21042
diff changeset
   470
            toupload = set()
52a5eabf1f2f largefiles: reuse "findcommonoutgoing()" result at "hg push"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 21042
diff changeset
   471
            addfunc = lambda fn, lfhash: toupload.add(lfhash)
52a5eabf1f2f largefiles: reuse "findcommonoutgoing()" result at "hg push"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 21042
diff changeset
   472
            lfutil.getlfilestoupload(local, outgoing.missing, addfunc)
52a5eabf1f2f largefiles: reuse "findcommonoutgoing()" result at "hg push"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 21042
diff changeset
   473
            lfcommands.uploadlfiles(ui, local, remote, toupload)
52a5eabf1f2f largefiles: reuse "findcommonoutgoing()" result at "hg push"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 21042
diff changeset
   474
    repo.prepushoutgoinghooks.add("largefiles", prepushoutgoinghook)
52a5eabf1f2f largefiles: reuse "findcommonoutgoing()" result at "hg push"
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 21042
diff changeset
   475
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   476
    def checkrequireslfiles(ui, repo, **kwargs):
15319
9da7e96cd5c2 largefiles: remove redundant any_ function
Benjamin Pollack <benjamin@bitquabit.com>
parents: 15316
diff changeset
   477
        if 'largefiles' not in repo.requirements and util.any(
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   478
                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
   479
            repo.requirements.add('largefiles')
15168
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   480
            repo._writerequirements()
cfccd3bee7b3 hgext: add largefiles extension
various
parents:
diff changeset
   481
20790
49f2d5644f04 config: set a 'source' in most cases where config don't come from file but code
Mads Kiilerich <madski@unity3d.com>
parents: 20177
diff changeset
   482
    ui.setconfig('hooks', 'changegroup.lfiles', checkrequireslfiles,
49f2d5644f04 config: set a 'source' in most cases where config don't come from file but code
Mads Kiilerich <madski@unity3d.com>
parents: 20177
diff changeset
   483
                 'largefiles')
49f2d5644f04 config: set a 'source' in most cases where config don't come from file but code
Mads Kiilerich <madski@unity3d.com>
parents: 20177
diff changeset
   484
    ui.setconfig('hooks', 'commit.lfiles', checkrequireslfiles, 'largefiles')