hgext/remotefilelog/__init__.py
author Martin von Zweigbergk <martinvonz@google.com>
Fri, 14 Jun 2019 13:50:06 -0700
changeset 42488 d768ca427249
parent 42472 87a34c767384
child 42514 f93762f251d2
permissions -rw-r--r--
remotefilelog: remove obsolete filtering of treemanifest directories I think this has been obsolete since 2cf18f46a1ce (narrow: only walk files within narrowspec also for committed revisions, 2018-09-28). Differential Revision: https://phab.mercurial-scm.org/D6531
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
     1
# __init__.py - remotefilelog extension
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
     2
#
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
     3
# Copyright 2013 Facebook, Inc.
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
     4
#
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
     5
# This software may be used and distributed according to the terms of the
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
     6
# GNU General Public License version 2 or any later version.
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
     7
"""remotefilelog causes Mercurial to lazilly fetch file contents (EXPERIMENTAL)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
     8
40562
b35a096b9bff remotefilelog: add some docstring
Augie Fackler <augie@google.com>
parents: 40560
diff changeset
     9
This extension is HIGHLY EXPERIMENTAL. There are NO BACKWARDS COMPATIBILITY
b35a096b9bff remotefilelog: add some docstring
Augie Fackler <augie@google.com>
parents: 40560
diff changeset
    10
GUARANTEES. This means that repositories created with this extension may
b35a096b9bff remotefilelog: add some docstring
Augie Fackler <augie@google.com>
parents: 40560
diff changeset
    11
only be usable with the exact version of this extension/Mercurial that was
b35a096b9bff remotefilelog: add some docstring
Augie Fackler <augie@google.com>
parents: 40560
diff changeset
    12
used. The extension attempts to enforce this in order to prevent repository
b35a096b9bff remotefilelog: add some docstring
Augie Fackler <augie@google.com>
parents: 40560
diff changeset
    13
corruption.
b35a096b9bff remotefilelog: add some docstring
Augie Fackler <augie@google.com>
parents: 40560
diff changeset
    14
b35a096b9bff remotefilelog: add some docstring
Augie Fackler <augie@google.com>
parents: 40560
diff changeset
    15
remotefilelog works by fetching file contents lazily and storing them
b35a096b9bff remotefilelog: add some docstring
Augie Fackler <augie@google.com>
parents: 40560
diff changeset
    16
in a cache on the client rather than in revlogs. This allows enormous
b35a096b9bff remotefilelog: add some docstring
Augie Fackler <augie@google.com>
parents: 40560
diff changeset
    17
histories to be transferred only partially, making them easier to
b35a096b9bff remotefilelog: add some docstring
Augie Fackler <augie@google.com>
parents: 40560
diff changeset
    18
operate on.
b35a096b9bff remotefilelog: add some docstring
Augie Fackler <augie@google.com>
parents: 40560
diff changeset
    19
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
    20
Configs:
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
    21
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
    22
    ``packs.maxchainlen`` specifies the maximum delta chain length in pack files
40595
040447dc3c62 remotefilelog: fix various whitespace issues in docstring
Augie Fackler <augie@google.com>
parents: 40564
diff changeset
    23
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
    24
    ``packs.maxpacksize`` specifies the maximum pack file size
40595
040447dc3c62 remotefilelog: fix various whitespace issues in docstring
Augie Fackler <augie@google.com>
parents: 40564
diff changeset
    25
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
    26
    ``packs.maxpackfilecount`` specifies the maximum number of packs in the
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
    27
      shared cache (trees only for now)
40595
040447dc3c62 remotefilelog: fix various whitespace issues in docstring
Augie Fackler <augie@google.com>
parents: 40564
diff changeset
    28
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
    29
    ``remotefilelog.backgroundprefetch`` runs prefetch in background when True
40595
040447dc3c62 remotefilelog: fix various whitespace issues in docstring
Augie Fackler <augie@google.com>
parents: 40564
diff changeset
    30
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
    31
    ``remotefilelog.bgprefetchrevs`` specifies revisions to fetch on commit and
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
    32
      update, and on other commands that use them. Different from pullprefetch.
40595
040447dc3c62 remotefilelog: fix various whitespace issues in docstring
Augie Fackler <augie@google.com>
parents: 40564
diff changeset
    33
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
    34
    ``remotefilelog.gcrepack`` does garbage collection during repack when True
40595
040447dc3c62 remotefilelog: fix various whitespace issues in docstring
Augie Fackler <augie@google.com>
parents: 40564
diff changeset
    35
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
    36
    ``remotefilelog.nodettl`` specifies maximum TTL of a node in seconds before
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
    37
      it is garbage collected
40595
040447dc3c62 remotefilelog: fix various whitespace issues in docstring
Augie Fackler <augie@google.com>
parents: 40564
diff changeset
    38
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
    39
    ``remotefilelog.repackonhggc`` runs repack on hg gc when True
40595
040447dc3c62 remotefilelog: fix various whitespace issues in docstring
Augie Fackler <augie@google.com>
parents: 40564
diff changeset
    40
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
    41
    ``remotefilelog.prefetchdays`` specifies the maximum age of a commit in
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
    42
      days after which it is no longer prefetched.
40595
040447dc3c62 remotefilelog: fix various whitespace issues in docstring
Augie Fackler <augie@google.com>
parents: 40564
diff changeset
    43
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
    44
    ``remotefilelog.prefetchdelay`` specifies delay between background
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
    45
      prefetches in seconds after operations that change the working copy parent
40595
040447dc3c62 remotefilelog: fix various whitespace issues in docstring
Augie Fackler <augie@google.com>
parents: 40564
diff changeset
    46
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
    47
    ``remotefilelog.data.gencountlimit`` constraints the minimum number of data
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
    48
      pack files required to be considered part of a generation. In particular,
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
    49
      minimum number of packs files > gencountlimit.
40595
040447dc3c62 remotefilelog: fix various whitespace issues in docstring
Augie Fackler <augie@google.com>
parents: 40564
diff changeset
    50
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
    51
    ``remotefilelog.data.generations`` list for specifying the lower bound of
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
    52
      each generation of the data pack files. For example, list ['100MB','1MB']
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
    53
      or ['1MB', '100MB'] will lead to three generations: [0, 1MB), [
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
    54
      1MB, 100MB) and [100MB, infinity).
40595
040447dc3c62 remotefilelog: fix various whitespace issues in docstring
Augie Fackler <augie@google.com>
parents: 40564
diff changeset
    55
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
    56
    ``remotefilelog.data.maxrepackpacks`` the maximum number of pack files to
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
    57
      include in an incremental data repack.
40595
040447dc3c62 remotefilelog: fix various whitespace issues in docstring
Augie Fackler <augie@google.com>
parents: 40564
diff changeset
    58
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
    59
    ``remotefilelog.data.repackmaxpacksize`` the maximum size of a pack file for
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
    60
      it to be considered for an incremental data repack.
40595
040447dc3c62 remotefilelog: fix various whitespace issues in docstring
Augie Fackler <augie@google.com>
parents: 40564
diff changeset
    61
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
    62
    ``remotefilelog.data.repacksizelimit`` the maximum total size of pack files
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
    63
      to include in an incremental data repack.
40595
040447dc3c62 remotefilelog: fix various whitespace issues in docstring
Augie Fackler <augie@google.com>
parents: 40564
diff changeset
    64
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
    65
    ``remotefilelog.history.gencountlimit`` constraints the minimum number of
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
    66
      history pack files required to be considered part of a generation. In
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
    67
      particular, minimum number of packs files > gencountlimit.
40595
040447dc3c62 remotefilelog: fix various whitespace issues in docstring
Augie Fackler <augie@google.com>
parents: 40564
diff changeset
    68
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
    69
    ``remotefilelog.history.generations`` list for specifying the lower bound of
40771
32a23c3f56d4 remotefilelog: fix typo in docstring
Augie Fackler <augie@google.com>
parents: 40657
diff changeset
    70
      each generation of the history pack files. For example, list [
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
    71
      '100MB', '1MB'] or ['1MB', '100MB'] will lead to three generations: [
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
    72
      0, 1MB), [1MB, 100MB) and [100MB, infinity).
40595
040447dc3c62 remotefilelog: fix various whitespace issues in docstring
Augie Fackler <augie@google.com>
parents: 40564
diff changeset
    73
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
    74
    ``remotefilelog.history.maxrepackpacks`` the maximum number of pack files to
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
    75
      include in an incremental history repack.
40595
040447dc3c62 remotefilelog: fix various whitespace issues in docstring
Augie Fackler <augie@google.com>
parents: 40564
diff changeset
    76
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
    77
    ``remotefilelog.history.repackmaxpacksize`` the maximum size of a pack file
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
    78
      for it to be considered for an incremental history repack.
40595
040447dc3c62 remotefilelog: fix various whitespace issues in docstring
Augie Fackler <augie@google.com>
parents: 40564
diff changeset
    79
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
    80
    ``remotefilelog.history.repacksizelimit`` the maximum total size of pack
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
    81
      files to include in an incremental history repack.
40595
040447dc3c62 remotefilelog: fix various whitespace issues in docstring
Augie Fackler <augie@google.com>
parents: 40564
diff changeset
    82
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
    83
    ``remotefilelog.backgroundrepack`` automatically consolidate packs in the
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
    84
      background
40595
040447dc3c62 remotefilelog: fix various whitespace issues in docstring
Augie Fackler <augie@google.com>
parents: 40564
diff changeset
    85
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
    86
    ``remotefilelog.cachepath`` path to cache
40595
040447dc3c62 remotefilelog: fix various whitespace issues in docstring
Augie Fackler <augie@google.com>
parents: 40564
diff changeset
    87
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
    88
    ``remotefilelog.cachegroup`` if set, make cache directory sgid to this
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
    89
      group
40595
040447dc3c62 remotefilelog: fix various whitespace issues in docstring
Augie Fackler <augie@google.com>
parents: 40564
diff changeset
    90
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
    91
    ``remotefilelog.cacheprocess`` binary to invoke for fetching file data
40595
040447dc3c62 remotefilelog: fix various whitespace issues in docstring
Augie Fackler <augie@google.com>
parents: 40564
diff changeset
    92
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
    93
    ``remotefilelog.debug`` turn on remotefilelog-specific debug output
40595
040447dc3c62 remotefilelog: fix various whitespace issues in docstring
Augie Fackler <augie@google.com>
parents: 40564
diff changeset
    94
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
    95
    ``remotefilelog.excludepattern`` pattern of files to exclude from pulls
40595
040447dc3c62 remotefilelog: fix various whitespace issues in docstring
Augie Fackler <augie@google.com>
parents: 40564
diff changeset
    96
040447dc3c62 remotefilelog: fix various whitespace issues in docstring
Augie Fackler <augie@google.com>
parents: 40564
diff changeset
    97
    ``remotefilelog.includepattern`` pattern of files to include in pulls
040447dc3c62 remotefilelog: fix various whitespace issues in docstring
Augie Fackler <augie@google.com>
parents: 40564
diff changeset
    98
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
    99
    ``remotefilelog.fetchwarning``: message to print when too many
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   100
      single-file fetches occur
40595
040447dc3c62 remotefilelog: fix various whitespace issues in docstring
Augie Fackler <augie@google.com>
parents: 40564
diff changeset
   101
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   102
    ``remotefilelog.getfilesstep`` number of files to request in a single RPC
40595
040447dc3c62 remotefilelog: fix various whitespace issues in docstring
Augie Fackler <augie@google.com>
parents: 40564
diff changeset
   103
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   104
    ``remotefilelog.getfilestype`` if set to 'threaded' use threads to fetch
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   105
      files, otherwise use optimistic fetching
40595
040447dc3c62 remotefilelog: fix various whitespace issues in docstring
Augie Fackler <augie@google.com>
parents: 40564
diff changeset
   106
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   107
    ``remotefilelog.pullprefetch`` revset for selecting files that should be
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   108
      eagerly downloaded rather than lazily
40595
040447dc3c62 remotefilelog: fix various whitespace issues in docstring
Augie Fackler <augie@google.com>
parents: 40564
diff changeset
   109
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   110
    ``remotefilelog.reponame`` name of the repo. If set, used to partition
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   111
      data from other repos in a shared store.
40595
040447dc3c62 remotefilelog: fix various whitespace issues in docstring
Augie Fackler <augie@google.com>
parents: 40564
diff changeset
   112
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   113
    ``remotefilelog.server`` if true, enable server-side functionality
40595
040447dc3c62 remotefilelog: fix various whitespace issues in docstring
Augie Fackler <augie@google.com>
parents: 40564
diff changeset
   114
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   115
    ``remotefilelog.servercachepath`` path for caching blobs on the server
40595
040447dc3c62 remotefilelog: fix various whitespace issues in docstring
Augie Fackler <augie@google.com>
parents: 40564
diff changeset
   116
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   117
    ``remotefilelog.serverexpiration`` number of days to keep cached server
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   118
      blobs
40595
040447dc3c62 remotefilelog: fix various whitespace issues in docstring
Augie Fackler <augie@google.com>
parents: 40564
diff changeset
   119
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   120
    ``remotefilelog.validatecache`` if set, check cache entries for corruption
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   121
      before returning blobs
40595
040447dc3c62 remotefilelog: fix various whitespace issues in docstring
Augie Fackler <augie@google.com>
parents: 40564
diff changeset
   122
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   123
    ``remotefilelog.validatecachelog`` if set, check cache entries for
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   124
      corruption before returning metadata
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   125
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   126
"""
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   127
from __future__ import absolute_import
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   128
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   129
import os
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   130
import time
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   131
import traceback
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   132
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   133
from mercurial.node import hex
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   134
from mercurial.i18n import _
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   135
from mercurial import (
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   136
    changegroup,
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   137
    changelog,
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   138
    cmdutil,
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   139
    commands,
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   140
    configitems,
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   141
    context,
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   142
    copies,
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   143
    debugcommands as hgdebugcommands,
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   144
    dispatch,
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   145
    error,
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   146
    exchange,
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   147
    extensions,
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   148
    hg,
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   149
    localrepo,
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   150
    match,
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   151
    merge,
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   152
    node as nodemod,
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   153
    patch,
40657
13d4ad8d7801 py3: fix keyword arguments handling in hgext/remotefilelog/
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 40624
diff changeset
   154
    pycompat,
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   155
    registrar,
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   156
    repair,
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   157
    repoview,
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   158
    revset,
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   159
    scmutil,
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   160
    smartset,
40563
525dcf5c1d41 remotefilelog: remove some BC code related to streamclone
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 40562
diff changeset
   161
    streamclone,
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   162
    util,
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   163
)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   164
from . import (
40558
354acd0dc637 remotefilelog: rename capability for legacy ssh file fetching method
Augie Fackler <augie@google.com>
parents: 40552
diff changeset
   165
    constants,
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   166
    debugcommands,
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   167
    fileserverclient,
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   168
    remotefilectx,
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   169
    remotefilelog,
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   170
    remotefilelogserver,
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   171
    repack as repackmod,
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   172
    shallowbundle,
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   173
    shallowrepo,
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   174
    shallowstore,
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   175
    shallowutil,
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   176
    shallowverifier,
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   177
)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   178
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   179
# ensures debug commands are registered
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   180
hgdebugcommands.command
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   181
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   182
cmdtable = {}
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   183
command = registrar.command(cmdtable)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   184
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   185
configtable = {}
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   186
configitem = registrar.configitem(configtable)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   187
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   188
configitem('remotefilelog', 'debug', default=False)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   189
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   190
configitem('remotefilelog', 'reponame', default='')
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   191
configitem('remotefilelog', 'cachepath', default=None)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   192
configitem('remotefilelog', 'cachegroup', default=None)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   193
configitem('remotefilelog', 'cacheprocess', default=None)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   194
configitem('remotefilelog', 'cacheprocess.includepath', default=None)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   195
configitem("remotefilelog", "cachelimit", default="1000 GB")
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   196
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   197
configitem('remotefilelog', 'fallbackpath', default=configitems.dynamicdefault,
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   198
           alias=[('remotefilelog', 'fallbackrepo')])
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   199
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   200
configitem('remotefilelog', 'validatecachelog', default=None)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   201
configitem('remotefilelog', 'validatecache', default='on')
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   202
configitem('remotefilelog', 'server', default=None)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   203
configitem('remotefilelog', 'servercachepath', default=None)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   204
configitem("remotefilelog", "serverexpiration", default=30)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   205
configitem('remotefilelog', 'backgroundrepack', default=False)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   206
configitem('remotefilelog', 'bgprefetchrevs', default=None)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   207
configitem('remotefilelog', 'pullprefetch', default=None)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   208
configitem('remotefilelog', 'backgroundprefetch', default=False)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   209
configitem('remotefilelog', 'prefetchdelay', default=120)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   210
configitem('remotefilelog', 'prefetchdays', default=14)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   211
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   212
configitem('remotefilelog', 'getfilesstep', default=10000)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   213
configitem('remotefilelog', 'getfilestype', default='optimistic')
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   214
configitem('remotefilelog', 'batchsize', configitems.dynamicdefault)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   215
configitem('remotefilelog', 'fetchwarning', default='')
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   216
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   217
configitem('remotefilelog', 'includepattern', default=None)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   218
configitem('remotefilelog', 'excludepattern', default=None)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   219
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   220
configitem('remotefilelog', 'gcrepack', default=False)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   221
configitem('remotefilelog', 'repackonhggc', default=False)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   222
configitem('repack', 'chainorphansbysize', default=True)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   223
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   224
configitem('packs', 'maxpacksize', default=0)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   225
configitem('packs', 'maxchainlen', default=1000)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   226
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   227
#  default TTL limit is 30 days
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   228
_defaultlimit = 60 * 60 * 24 * 30
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   229
configitem('remotefilelog', 'nodettl', default=_defaultlimit)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   230
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   231
configitem('remotefilelog', 'data.gencountlimit', default=2),
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   232
configitem('remotefilelog', 'data.generations',
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   233
           default=['1GB', '100MB', '1MB'])
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   234
configitem('remotefilelog', 'data.maxrepackpacks', default=50)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   235
configitem('remotefilelog', 'data.repackmaxpacksize', default='4GB')
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   236
configitem('remotefilelog', 'data.repacksizelimit', default='100MB')
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   237
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   238
configitem('remotefilelog', 'history.gencountlimit', default=2),
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   239
configitem('remotefilelog', 'history.generations', default=['100MB'])
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   240
configitem('remotefilelog', 'history.maxrepackpacks', default=50)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   241
configitem('remotefilelog', 'history.repackmaxpacksize', default='400MB')
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   242
configitem('remotefilelog', 'history.repacksizelimit', default='100MB')
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   243
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   244
# Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   245
# extensions which SHIP WITH MERCURIAL. Non-mainline extensions should
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   246
# be specifying the version(s) of Mercurial they are tested with, or
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   247
# leave the attribute unspecified.
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   248
testedwith = 'ships-with-hg-core'
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   249
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   250
repoclass = localrepo.localrepository
40560
fc2766860796 remotefilelog: consolidate and rename on-disk store requirement
Augie Fackler <augie@google.com>
parents: 40559
diff changeset
   251
repoclass._basesupported.add(constants.SHALLOWREPO_REQUIREMENT)
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   252
40564
6f0b6905ef6f shallowutil: introduce a helper function isenabled()
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 40563
diff changeset
   253
isenabled = shallowutil.isenabled
6f0b6905ef6f shallowutil: introduce a helper function isenabled()
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 40563
diff changeset
   254
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   255
def uisetup(ui):
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   256
    """Wraps user facing Mercurial commands to swap them out with shallow
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   257
    versions.
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   258
    """
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   259
    hg.wirepeersetupfuncs.append(fileserverclient.peersetup)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   260
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   261
    entry = extensions.wrapcommand(commands.table, 'clone', cloneshallow)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   262
    entry[1].append(('', 'shallow', None,
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   263
                     _("create a shallow clone which uses remote file "
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   264
                       "history")))
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   265
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   266
    extensions.wrapcommand(commands.table, 'debugindex',
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   267
        debugcommands.debugindex)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   268
    extensions.wrapcommand(commands.table, 'debugindexdot',
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   269
        debugcommands.debugindexdot)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   270
    extensions.wrapcommand(commands.table, 'log', log)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   271
    extensions.wrapcommand(commands.table, 'pull', pull)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   272
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   273
    # Prevent 'hg manifest --all'
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   274
    def _manifest(orig, ui, repo, *args, **opts):
40657
13d4ad8d7801 py3: fix keyword arguments handling in hgext/remotefilelog/
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 40624
diff changeset
   275
        if (isenabled(repo) and opts.get(r'all')):
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   276
            raise error.Abort(_("--all is not supported in a shallow repo"))
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   277
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   278
        return orig(ui, repo, *args, **opts)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   279
    extensions.wrapcommand(commands.table, "manifest", _manifest)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   280
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   281
    # Wrap remotefilelog with lfs code
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   282
    def _lfsloaded(loaded=False):
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   283
        lfsmod = None
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   284
        try:
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   285
            lfsmod = extensions.find('lfs')
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   286
        except KeyError:
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   287
            pass
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   288
        if lfsmod:
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   289
            lfsmod.wrapfilelog(remotefilelog.remotefilelog)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   290
            fileserverclient._lfsmod = lfsmod
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   291
    extensions.afterloaded('lfs', _lfsloaded)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   292
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   293
    # debugdata needs remotefilelog.len to work
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   294
    extensions.wrapcommand(commands.table, 'debugdata', debugdatashallow)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   295
42301
8a0e03f7baf4 remotefilelog: move most setup from onetimesetup() to uisetup()
Martin von Zweigbergk <martinvonz@google.com>
parents: 42300
diff changeset
   296
    changegroup.cgpacker = shallowbundle.shallowcg1packer
8a0e03f7baf4 remotefilelog: move most setup from onetimesetup() to uisetup()
Martin von Zweigbergk <martinvonz@google.com>
parents: 42300
diff changeset
   297
8a0e03f7baf4 remotefilelog: move most setup from onetimesetup() to uisetup()
Martin von Zweigbergk <martinvonz@google.com>
parents: 42300
diff changeset
   298
    extensions.wrapfunction(changegroup, '_addchangegroupfiles',
8a0e03f7baf4 remotefilelog: move most setup from onetimesetup() to uisetup()
Martin von Zweigbergk <martinvonz@google.com>
parents: 42300
diff changeset
   299
                            shallowbundle.addchangegroupfiles)
8a0e03f7baf4 remotefilelog: move most setup from onetimesetup() to uisetup()
Martin von Zweigbergk <martinvonz@google.com>
parents: 42300
diff changeset
   300
    extensions.wrapfunction(
8a0e03f7baf4 remotefilelog: move most setup from onetimesetup() to uisetup()
Martin von Zweigbergk <martinvonz@google.com>
parents: 42300
diff changeset
   301
        changegroup, 'makechangegroup', shallowbundle.makechangegroup)
8a0e03f7baf4 remotefilelog: move most setup from onetimesetup() to uisetup()
Martin von Zweigbergk <martinvonz@google.com>
parents: 42300
diff changeset
   302
    extensions.wrapfunction(localrepo, 'makestore', storewrapper)
8a0e03f7baf4 remotefilelog: move most setup from onetimesetup() to uisetup()
Martin von Zweigbergk <martinvonz@google.com>
parents: 42300
diff changeset
   303
    extensions.wrapfunction(exchange, 'pull', exchangepull)
8a0e03f7baf4 remotefilelog: move most setup from onetimesetup() to uisetup()
Martin von Zweigbergk <martinvonz@google.com>
parents: 42300
diff changeset
   304
    extensions.wrapfunction(merge, 'applyupdates', applyupdates)
8a0e03f7baf4 remotefilelog: move most setup from onetimesetup() to uisetup()
Martin von Zweigbergk <martinvonz@google.com>
parents: 42300
diff changeset
   305
    extensions.wrapfunction(merge, '_checkunknownfiles', checkunknownfiles)
8a0e03f7baf4 remotefilelog: move most setup from onetimesetup() to uisetup()
Martin von Zweigbergk <martinvonz@google.com>
parents: 42300
diff changeset
   306
    extensions.wrapfunction(context.workingctx, '_checklookup', checklookup)
8a0e03f7baf4 remotefilelog: move most setup from onetimesetup() to uisetup()
Martin von Zweigbergk <martinvonz@google.com>
parents: 42300
diff changeset
   307
    extensions.wrapfunction(scmutil, '_findrenames', findrenames)
8a0e03f7baf4 remotefilelog: move most setup from onetimesetup() to uisetup()
Martin von Zweigbergk <martinvonz@google.com>
parents: 42300
diff changeset
   308
    extensions.wrapfunction(copies, '_computeforwardmissing',
8a0e03f7baf4 remotefilelog: move most setup from onetimesetup() to uisetup()
Martin von Zweigbergk <martinvonz@google.com>
parents: 42300
diff changeset
   309
                            computeforwardmissing)
8a0e03f7baf4 remotefilelog: move most setup from onetimesetup() to uisetup()
Martin von Zweigbergk <martinvonz@google.com>
parents: 42300
diff changeset
   310
    extensions.wrapfunction(dispatch, 'runcommand', runcommand)
8a0e03f7baf4 remotefilelog: move most setup from onetimesetup() to uisetup()
Martin von Zweigbergk <martinvonz@google.com>
parents: 42300
diff changeset
   311
    extensions.wrapfunction(repair, '_collectbrokencsets', _collectbrokencsets)
8a0e03f7baf4 remotefilelog: move most setup from onetimesetup() to uisetup()
Martin von Zweigbergk <martinvonz@google.com>
parents: 42300
diff changeset
   312
    extensions.wrapfunction(context.changectx, 'filectx', filectx)
8a0e03f7baf4 remotefilelog: move most setup from onetimesetup() to uisetup()
Martin von Zweigbergk <martinvonz@google.com>
parents: 42300
diff changeset
   313
    extensions.wrapfunction(context.workingctx, 'filectx', workingfilectx)
8a0e03f7baf4 remotefilelog: move most setup from onetimesetup() to uisetup()
Martin von Zweigbergk <martinvonz@google.com>
parents: 42300
diff changeset
   314
    extensions.wrapfunction(patch, 'trydiff', trydiff)
8a0e03f7baf4 remotefilelog: move most setup from onetimesetup() to uisetup()
Martin von Zweigbergk <martinvonz@google.com>
parents: 42300
diff changeset
   315
    extensions.wrapfunction(hg, 'verify', _verify)
8a0e03f7baf4 remotefilelog: move most setup from onetimesetup() to uisetup()
Martin von Zweigbergk <martinvonz@google.com>
parents: 42300
diff changeset
   316
    scmutil.fileprefetchhooks.add('remotefilelog', _fileprefetchhook)
8a0e03f7baf4 remotefilelog: move most setup from onetimesetup() to uisetup()
Martin von Zweigbergk <martinvonz@google.com>
parents: 42300
diff changeset
   317
8a0e03f7baf4 remotefilelog: move most setup from onetimesetup() to uisetup()
Martin von Zweigbergk <martinvonz@google.com>
parents: 42300
diff changeset
   318
    # disappointing hacks below
8a0e03f7baf4 remotefilelog: move most setup from onetimesetup() to uisetup()
Martin von Zweigbergk <martinvonz@google.com>
parents: 42300
diff changeset
   319
    scmutil.getrenamedfn = getrenamedfn
8a0e03f7baf4 remotefilelog: move most setup from onetimesetup() to uisetup()
Martin von Zweigbergk <martinvonz@google.com>
parents: 42300
diff changeset
   320
    extensions.wrapfunction(revset, 'filelog', filelogrevset)
8a0e03f7baf4 remotefilelog: move most setup from onetimesetup() to uisetup()
Martin von Zweigbergk <martinvonz@google.com>
parents: 42300
diff changeset
   321
    revset.symbols['filelog'] = revset.filelog
8a0e03f7baf4 remotefilelog: move most setup from onetimesetup() to uisetup()
Martin von Zweigbergk <martinvonz@google.com>
parents: 42300
diff changeset
   322
    extensions.wrapfunction(cmdutil, 'walkfilerevs', walkfilerevs)
8a0e03f7baf4 remotefilelog: move most setup from onetimesetup() to uisetup()
Martin von Zweigbergk <martinvonz@google.com>
parents: 42300
diff changeset
   323
8a0e03f7baf4 remotefilelog: move most setup from onetimesetup() to uisetup()
Martin von Zweigbergk <martinvonz@google.com>
parents: 42300
diff changeset
   324
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   325
def cloneshallow(orig, ui, repo, *args, **opts):
40657
13d4ad8d7801 py3: fix keyword arguments handling in hgext/remotefilelog/
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 40624
diff changeset
   326
    if opts.get(r'shallow'):
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   327
        repos = []
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   328
        def pull_shallow(orig, self, *args, **kwargs):
40564
6f0b6905ef6f shallowutil: introduce a helper function isenabled()
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 40563
diff changeset
   329
            if not isenabled(self):
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   330
                repos.append(self.unfiltered())
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   331
                # set up the client hooks so the post-clone update works
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   332
                setupclient(self.ui, self.unfiltered())
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   333
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   334
                # setupclient fixed the class on the repo itself
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   335
                # but we also need to fix it on the repoview
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   336
                if isinstance(self, repoview.repoview):
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   337
                    self.__class__.__bases__ = (self.__class__.__bases__[0],
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   338
                                                self.unfiltered().__class__)
40560
fc2766860796 remotefilelog: consolidate and rename on-disk store requirement
Augie Fackler <augie@google.com>
parents: 40559
diff changeset
   339
                self.requirements.add(constants.SHALLOWREPO_REQUIREMENT)
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   340
                self._writerequirements()
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   341
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   342
                # Since setupclient hadn't been called, exchange.pull was not
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   343
                # wrapped. So we need to manually invoke our version of it.
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   344
                return exchangepull(orig, self, *args, **kwargs)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   345
            else:
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   346
                return orig(self, *args, **kwargs)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   347
        extensions.wrapfunction(exchange, 'pull', pull_shallow)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   348
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   349
        # Wrap the stream logic to add requirements and to pass include/exclude
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   350
        # patterns around.
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   351
        def setup_streamout(repo, remote):
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   352
            # Replace remote.stream_out with a version that sends file
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   353
            # patterns.
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   354
            def stream_out_shallow(orig):
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   355
                caps = remote.capabilities()
40558
354acd0dc637 remotefilelog: rename capability for legacy ssh file fetching method
Augie Fackler <augie@google.com>
parents: 40552
diff changeset
   356
                if constants.NETWORK_CAP_LEGACY_SSH_GETFILES in caps:
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   357
                    opts = {}
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   358
                    if repo.includepattern:
40657
13d4ad8d7801 py3: fix keyword arguments handling in hgext/remotefilelog/
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 40624
diff changeset
   359
                        opts[r'includepattern'] = '\0'.join(repo.includepattern)
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   360
                    if repo.excludepattern:
40657
13d4ad8d7801 py3: fix keyword arguments handling in hgext/remotefilelog/
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 40624
diff changeset
   361
                        opts[r'excludepattern'] = '\0'.join(repo.excludepattern)
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   362
                    return remote._callstream('stream_out_shallow', **opts)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   363
                else:
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   364
                    return orig()
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   365
            extensions.wrapfunction(remote, 'stream_out', stream_out_shallow)
40563
525dcf5c1d41 remotefilelog: remove some BC code related to streamclone
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 40562
diff changeset
   366
        def stream_wrap(orig, op):
525dcf5c1d41 remotefilelog: remove some BC code related to streamclone
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 40562
diff changeset
   367
            setup_streamout(op.repo, op.remote)
525dcf5c1d41 remotefilelog: remove some BC code related to streamclone
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 40562
diff changeset
   368
            return orig(op)
525dcf5c1d41 remotefilelog: remove some BC code related to streamclone
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 40562
diff changeset
   369
        extensions.wrapfunction(
525dcf5c1d41 remotefilelog: remove some BC code related to streamclone
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 40562
diff changeset
   370
            streamclone, 'maybeperformlegacystreamclone', stream_wrap)
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   371
40563
525dcf5c1d41 remotefilelog: remove some BC code related to streamclone
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 40562
diff changeset
   372
        def canperformstreamclone(orig, pullop, bundle2=False):
525dcf5c1d41 remotefilelog: remove some BC code related to streamclone
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 40562
diff changeset
   373
            # remotefilelog is currently incompatible with the
525dcf5c1d41 remotefilelog: remove some BC code related to streamclone
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 40562
diff changeset
   374
            # bundle2 flavor of streamclones, so force us to use
525dcf5c1d41 remotefilelog: remove some BC code related to streamclone
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 40562
diff changeset
   375
            # v1 instead.
525dcf5c1d41 remotefilelog: remove some BC code related to streamclone
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 40562
diff changeset
   376
            if 'v2' in pullop.remotebundle2caps.get('stream', []):
525dcf5c1d41 remotefilelog: remove some BC code related to streamclone
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 40562
diff changeset
   377
                pullop.remotebundle2caps['stream'] = [
525dcf5c1d41 remotefilelog: remove some BC code related to streamclone
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 40562
diff changeset
   378
                    c for c in pullop.remotebundle2caps['stream']
525dcf5c1d41 remotefilelog: remove some BC code related to streamclone
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 40562
diff changeset
   379
                    if c != 'v2']
525dcf5c1d41 remotefilelog: remove some BC code related to streamclone
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 40562
diff changeset
   380
            if bundle2:
525dcf5c1d41 remotefilelog: remove some BC code related to streamclone
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 40562
diff changeset
   381
                return False, None
525dcf5c1d41 remotefilelog: remove some BC code related to streamclone
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 40562
diff changeset
   382
            supported, requirements = orig(pullop, bundle2=bundle2)
525dcf5c1d41 remotefilelog: remove some BC code related to streamclone
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 40562
diff changeset
   383
            if requirements is not None:
40560
fc2766860796 remotefilelog: consolidate and rename on-disk store requirement
Augie Fackler <augie@google.com>
parents: 40559
diff changeset
   384
                requirements.add(constants.SHALLOWREPO_REQUIREMENT)
40563
525dcf5c1d41 remotefilelog: remove some BC code related to streamclone
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 40562
diff changeset
   385
            return supported, requirements
525dcf5c1d41 remotefilelog: remove some BC code related to streamclone
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 40562
diff changeset
   386
        extensions.wrapfunction(
525dcf5c1d41 remotefilelog: remove some BC code related to streamclone
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 40562
diff changeset
   387
            streamclone, 'canperformstreamclone', canperformstreamclone)
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   388
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   389
    try:
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   390
        orig(ui, repo, *args, **opts)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   391
    finally:
40657
13d4ad8d7801 py3: fix keyword arguments handling in hgext/remotefilelog/
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 40624
diff changeset
   392
        if opts.get(r'shallow'):
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   393
            for r in repos:
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   394
                if util.safehasattr(r, 'fileservice'):
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   395
                    r.fileservice.close()
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   396
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   397
def debugdatashallow(orig, *args, **kwds):
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   398
    oldlen = remotefilelog.remotefilelog.__len__
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   399
    try:
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   400
        remotefilelog.remotefilelog.__len__ = lambda x: 1
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   401
        return orig(*args, **kwds)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   402
    finally:
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   403
        remotefilelog.remotefilelog.__len__ = oldlen
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   404
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   405
def reposetup(ui, repo):
41061
c61b8dfb07c8 remotefilelog: use repo.local() instead of isinstance()
Matt Harbison <matt_harbison@yahoo.com>
parents: 40858
diff changeset
   406
    if not repo.local():
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   407
        return
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   408
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   409
    # put here intentionally bc doesnt work in uisetup
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   410
    ui.setconfig('hooks', 'update.prefetch', wcpprefetch)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   411
    ui.setconfig('hooks', 'commit.prefetch', wcpprefetch)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   412
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   413
    isserverenabled = ui.configbool('remotefilelog', 'server')
40564
6f0b6905ef6f shallowutil: introduce a helper function isenabled()
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 40563
diff changeset
   414
    isshallowclient = isenabled(repo)
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   415
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   416
    if isserverenabled and isshallowclient:
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   417
        raise RuntimeError("Cannot be both a server and shallow client.")
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   418
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   419
    if isshallowclient:
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   420
        setupclient(ui, repo)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   421
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   422
    if isserverenabled:
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   423
        remotefilelogserver.setupserver(ui, repo)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   424
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   425
def setupclient(ui, repo):
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   426
    if not isinstance(repo, localrepo.localrepository):
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   427
        return
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   428
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   429
    # Even clients get the server setup since they need to have the
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   430
    # wireprotocol endpoints registered.
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   431
    remotefilelogserver.onetimesetup(ui)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   432
    onetimeclientsetup(ui)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   433
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   434
    shallowrepo.wraprepo(repo)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   435
    repo.store = shallowstore.wrapstore(repo.store)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   436
42300
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   437
def storewrapper(orig, requirements, path, vfstype):
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   438
    s = orig(requirements, path, vfstype)
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   439
    if constants.SHALLOWREPO_REQUIREMENT in requirements:
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   440
        s = shallowstore.wrapstore(s)
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   441
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   442
    return s
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   443
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   444
# prefetch files before update
42472
87a34c767384 merge: fix race that could cause wrong size in dirstate
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents: 42301
diff changeset
   445
def applyupdates(orig, repo, actions, wctx, mctx, overwrite, wantfiledata,
87a34c767384 merge: fix race that could cause wrong size in dirstate
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents: 42301
diff changeset
   446
                 labels=None):
42300
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   447
    if isenabled(repo):
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   448
        manifest = mctx.manifest()
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   449
        files = []
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   450
        for f, args, msg in actions['g']:
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   451
            files.append((f, hex(manifest[f])))
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   452
        # batch fetch the needed files from the server
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   453
        repo.fileservice.prefetch(files)
42472
87a34c767384 merge: fix race that could cause wrong size in dirstate
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents: 42301
diff changeset
   454
    return orig(repo, actions, wctx, mctx, overwrite, wantfiledata,
87a34c767384 merge: fix race that could cause wrong size in dirstate
Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
parents: 42301
diff changeset
   455
                labels=labels)
42300
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   456
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   457
# Prefetch merge checkunknownfiles
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   458
def checkunknownfiles(orig, repo, wctx, mctx, force, actions,
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   459
    *args, **kwargs):
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   460
    if isenabled(repo):
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   461
        files = []
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   462
        sparsematch = repo.maybesparsematch(mctx.rev())
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   463
        for f, (m, actionargs, msg) in actions.iteritems():
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   464
            if sparsematch and not sparsematch(f):
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   465
                continue
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   466
            if m in ('c', 'dc', 'cm'):
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   467
                files.append((f, hex(mctx.filenode(f))))
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   468
            elif m == 'dg':
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   469
                f2 = actionargs[0]
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   470
                files.append((f2, hex(mctx.filenode(f2))))
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   471
        # batch fetch the needed files from the server
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   472
        repo.fileservice.prefetch(files)
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   473
    return orig(repo, wctx, mctx, force, actions, *args, **kwargs)
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   474
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   475
# Prefetch files before status attempts to look at their size and contents
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   476
def checklookup(orig, self, files):
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   477
    repo = self._repo
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   478
    if isenabled(repo):
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   479
        prefetchfiles = []
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   480
        for parent in self._parents:
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   481
            for f in files:
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   482
                if f in parent:
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   483
                    prefetchfiles.append((f, hex(parent.filenode(f))))
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   484
        # batch fetch the needed files from the server
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   485
        repo.fileservice.prefetch(prefetchfiles)
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   486
    return orig(self, files)
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   487
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   488
# Prefetch the logic that compares added and removed files for renames
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   489
def findrenames(orig, repo, matcher, added, removed, *args, **kwargs):
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   490
    if isenabled(repo):
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   491
        files = []
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   492
        pmf = repo['.'].manifest()
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   493
        for f in removed:
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   494
            if f in pmf:
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   495
                files.append((f, hex(pmf[f])))
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   496
        # batch fetch the needed files from the server
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   497
        repo.fileservice.prefetch(files)
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   498
    return orig(repo, matcher, added, removed, *args, **kwargs)
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   499
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   500
# prefetch files before pathcopies check
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   501
def computeforwardmissing(orig, a, b, match=None):
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   502
    missing = orig(a, b, match=match)
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   503
    repo = a._repo
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   504
    if isenabled(repo):
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   505
        mb = b.manifest()
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   506
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   507
        files = []
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   508
        sparsematch = repo.maybesparsematch(b.rev())
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   509
        if sparsematch:
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   510
            sparsemissing = set()
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   511
            for f in missing:
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   512
                if sparsematch(f):
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   513
                    files.append((f, hex(mb[f])))
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   514
                    sparsemissing.add(f)
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   515
            missing = sparsemissing
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   516
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   517
        # batch fetch the needed files from the server
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   518
        repo.fileservice.prefetch(files)
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   519
    return missing
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   520
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   521
# close cache miss server connection after the command has finished
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   522
def runcommand(orig, lui, repo, *args, **kwargs):
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   523
    fileservice = None
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   524
    # repo can be None when running in chg:
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   525
    # - at startup, reposetup was called because serve is not norepo
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   526
    # - a norepo command like "help" is called
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   527
    if repo and isenabled(repo):
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   528
        fileservice = repo.fileservice
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   529
    try:
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   530
        return orig(lui, repo, *args, **kwargs)
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   531
    finally:
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   532
        if fileservice:
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   533
            fileservice.close()
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   534
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   535
# prevent strip from stripping remotefilelogs
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   536
def _collectbrokencsets(orig, repo, files, striprev):
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   537
    if isenabled(repo):
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   538
        files = list([f for f in files if not repo.shallowmatch(f)])
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   539
    return orig(repo, files, striprev)
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   540
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   541
# changectx wrappers
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   542
def filectx(orig, self, path, fileid=None, filelog=None):
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   543
    if fileid is None:
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   544
        fileid = self.filenode(path)
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   545
    if (isenabled(self._repo) and self._repo.shallowmatch(path)):
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   546
        return remotefilectx.remotefilectx(self._repo, path, fileid=fileid,
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   547
                                           changectx=self, filelog=filelog)
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   548
    return orig(self, path, fileid=fileid, filelog=filelog)
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   549
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   550
def workingfilectx(orig, self, path, filelog=None):
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   551
    if (isenabled(self._repo) and self._repo.shallowmatch(path)):
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   552
        return remotefilectx.remoteworkingfilectx(self._repo, path,
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   553
                                                  workingctx=self,
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   554
                                                  filelog=filelog)
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   555
    return orig(self, path, filelog=filelog)
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   556
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   557
# prefetch required revisions before a diff
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   558
def trydiff(orig, repo, revs, ctx1, ctx2, modified, added, removed,
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   559
    copy, getfilectx, *args, **kwargs):
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   560
    if isenabled(repo):
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   561
        prefetch = []
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   562
        mf1 = ctx1.manifest()
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   563
        for fname in modified + added + removed:
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   564
            if fname in mf1:
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   565
                fnode = getfilectx(fname, ctx1).filenode()
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   566
                # fnode can be None if it's a edited working ctx file
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   567
                if fnode:
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   568
                    prefetch.append((fname, hex(fnode)))
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   569
            if fname not in removed:
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   570
                fnode = getfilectx(fname, ctx2).filenode()
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   571
                if fnode:
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   572
                    prefetch.append((fname, hex(fnode)))
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   573
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   574
        repo.fileservice.prefetch(prefetch)
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   575
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   576
    return orig(repo, revs, ctx1, ctx2, modified, added, removed, copy,
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   577
                getfilectx, *args, **kwargs)
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   578
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   579
# Prevent verify from processing files
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   580
# a stub for mercurial.hg.verify()
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   581
def _verify(orig, repo, level=None):
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   582
    lock = repo.lock()
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   583
    try:
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   584
        return shallowverifier.shallowverifier(repo).verify()
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   585
    finally:
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   586
        lock.release()
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   587
651f325e4fdd remotefilelog: move most functions in onetimeclientsetup() to top level
Martin von Zweigbergk <martinvonz@google.com>
parents: 42253
diff changeset
   588
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   589
clientonetime = False
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   590
def onetimeclientsetup(ui):
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   591
    global clientonetime
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   592
    if clientonetime:
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   593
        return
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   594
    clientonetime = True
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   595
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   596
    # Don't commit filelogs until we know the commit hash, since the hash
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   597
    # is present in the filelog blob.
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   598
    # This violates Mercurial's filelog->manifest->changelog write order,
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   599
    # but is generally fine for client repos.
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   600
    pendingfilecommits = []
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   601
    def addrawrevision(orig, self, rawtext, transaction, link, p1, p2, node,
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   602
                       flags, cachedelta=None, _metatuple=None):
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   603
        if isinstance(link, int):
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   604
            pendingfilecommits.append(
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   605
                (self, rawtext, transaction, link, p1, p2, node, flags,
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   606
                 cachedelta, _metatuple))
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   607
            return node
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   608
        else:
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   609
            return orig(self, rawtext, transaction, link, p1, p2, node, flags,
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   610
                        cachedelta, _metatuple=_metatuple)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   611
    extensions.wrapfunction(
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   612
        remotefilelog.remotefilelog, 'addrawrevision', addrawrevision)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   613
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   614
    def changelogadd(orig, self, *args):
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   615
        oldlen = len(self)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   616
        node = orig(self, *args)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   617
        newlen = len(self)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   618
        if oldlen != newlen:
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   619
            for oldargs in pendingfilecommits:
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   620
                log, rt, tr, link, p1, p2, n, fl, c, m = oldargs
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   621
                linknode = self.node(link)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   622
                if linknode == node:
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   623
                    log.addrawrevision(rt, tr, linknode, p1, p2, n, fl, c, m)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   624
                else:
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   625
                    raise error.ProgrammingError(
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   626
                        'pending multiple integer revisions are not supported')
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   627
        else:
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   628
            # "link" is actually wrong here (it is set to len(changelog))
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   629
            # if changelog remains unchanged, skip writing file revisions
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   630
            # but still do a sanity check about pending multiple revisions
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   631
            if len(set(x[3] for x in pendingfilecommits)) > 1:
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   632
                raise error.ProgrammingError(
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   633
                    'pending multiple integer revisions are not supported')
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   634
        del pendingfilecommits[:]
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   635
        return node
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   636
    extensions.wrapfunction(changelog.changelog, 'add', changelogadd)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   637
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   638
def getrenamedfn(repo, endrev=None):
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   639
    rcache = {}
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   640
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   641
    def getrenamed(fn, rev):
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   642
        '''looks up all renames for a file (up to endrev) the first
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   643
        time the file is given. It indexes on the changerev and only
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   644
        parses the manifest if linkrev != changerev.
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   645
        Returns rename info for fn at changerev rev.'''
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   646
        if rev in rcache.setdefault(fn, {}):
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   647
            return rcache[fn][rev]
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   648
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   649
        try:
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   650
            fctx = repo[rev].filectx(fn)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   651
            for ancestor in fctx.ancestors():
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   652
                if ancestor.path() == fn:
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   653
                    renamed = ancestor.renamed()
41192
2338eab5f8b7 remotefilelog: fix {file_copies} template keyword
Martin von Zweigbergk <martinvonz@google.com>
parents: 41061
diff changeset
   654
                    rcache[fn][ancestor.rev()] = renamed and renamed[0]
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   655
41192
2338eab5f8b7 remotefilelog: fix {file_copies} template keyword
Martin von Zweigbergk <martinvonz@google.com>
parents: 41061
diff changeset
   656
            renamed = fctx.renamed()
2338eab5f8b7 remotefilelog: fix {file_copies} template keyword
Martin von Zweigbergk <martinvonz@google.com>
parents: 41061
diff changeset
   657
            return renamed and renamed[0]
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   658
        except error.LookupError:
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   659
            return None
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   660
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   661
    return getrenamed
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   662
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   663
def walkfilerevs(orig, repo, match, follow, revs, fncache):
40564
6f0b6905ef6f shallowutil: introduce a helper function isenabled()
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 40563
diff changeset
   664
    if not isenabled(repo):
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   665
        return orig(repo, match, follow, revs, fncache)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   666
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   667
    # remotefilelog's can't be walked in rev order, so throw.
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   668
    # The caller will see the exception and walk the commit tree instead.
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   669
    if not follow:
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   670
        raise cmdutil.FileWalkError("Cannot walk via filelog")
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   671
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   672
    wanted = set()
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   673
    minrev, maxrev = min(revs), max(revs)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   674
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   675
    pctx = repo['.']
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   676
    for filename in match.files():
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   677
        if filename not in pctx:
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   678
            raise error.Abort(_('cannot follow file not in parent '
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   679
                               'revision: "%s"') % filename)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   680
        fctx = pctx[filename]
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   681
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   682
        linkrev = fctx.linkrev()
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   683
        if linkrev >= minrev and linkrev <= maxrev:
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   684
            fncache.setdefault(linkrev, []).append(filename)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   685
            wanted.add(linkrev)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   686
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   687
        for ancestor in fctx.ancestors():
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   688
            linkrev = ancestor.linkrev()
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   689
            if linkrev >= minrev and linkrev <= maxrev:
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   690
                fncache.setdefault(linkrev, []).append(ancestor.path())
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   691
                wanted.add(linkrev)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   692
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   693
    return wanted
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   694
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   695
def filelogrevset(orig, repo, subset, x):
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   696
    """``filelog(pattern)``
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   697
    Changesets connected to the specified filelog.
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   698
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   699
    For performance reasons, ``filelog()`` does not show every changeset
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   700
    that affects the requested file(s). See :hg:`help log` for details. For
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   701
    a slower, more accurate result, use ``file()``.
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   702
    """
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   703
40564
6f0b6905ef6f shallowutil: introduce a helper function isenabled()
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 40563
diff changeset
   704
    if not isenabled(repo):
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   705
        return orig(repo, subset, x)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   706
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   707
    # i18n: "filelog" is a keyword
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   708
    pat = revset.getstring(x, _("filelog requires a pattern"))
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   709
    m = match.match(repo.root, repo.getcwd(), [pat], default='relpath',
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   710
                       ctx=repo[None])
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   711
    s = set()
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   712
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   713
    if not match.patkind(pat):
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   714
        # slow
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   715
        for r in subset:
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   716
            ctx = repo[r]
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   717
            cfiles = ctx.files()
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   718
            for f in m.files():
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   719
                if f in cfiles:
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   720
                    s.add(ctx.rev())
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   721
                    break
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   722
    else:
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   723
        # partial
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   724
        files = (f for f in repo[None] if m(f))
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   725
        for f in files:
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   726
            fctx = repo[None].filectx(f)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   727
            s.add(fctx.linkrev())
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   728
            for actx in fctx.ancestors():
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   729
                s.add(actx.linkrev())
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   730
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   731
    return smartset.baseset([r for r in subset if r in s])
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   732
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   733
@command('gc', [], _('hg gc [REPO...]'), norepo=True)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   734
def gc(ui, *args, **opts):
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   735
    '''garbage collect the client and server filelog caches
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   736
    '''
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   737
    cachepaths = set()
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   738
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   739
    # get the system client cache
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   740
    systemcache = shallowutil.getcachepath(ui, allowempty=True)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   741
    if systemcache:
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   742
        cachepaths.add(systemcache)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   743
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   744
    # get repo client and server cache
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   745
    repopaths = []
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   746
    pwd = ui.environ.get('PWD')
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   747
    if pwd:
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   748
        repopaths.append(pwd)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   749
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   750
    repopaths.extend(args)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   751
    repos = []
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   752
    for repopath in repopaths:
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   753
        try:
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   754
            repo = hg.peer(ui, {}, repopath)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   755
            repos.append(repo)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   756
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   757
            repocache = shallowutil.getcachepath(repo.ui, allowempty=True)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   758
            if repocache:
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   759
                cachepaths.add(repocache)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   760
        except error.RepoError:
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   761
            pass
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   762
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   763
    # gc client cache
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   764
    for cachepath in cachepaths:
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   765
        gcclient(ui, cachepath)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   766
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   767
    # gc server cache
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   768
    for repo in repos:
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   769
        remotefilelogserver.gcserver(ui, repo._repo)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   770
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   771
def gcclient(ui, cachepath):
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   772
    # get list of repos that use this cache
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   773
    repospath = os.path.join(cachepath, 'repos')
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   774
    if not os.path.exists(repospath):
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   775
        ui.warn(_("no known cache at %s\n") % cachepath)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   776
        return
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   777
41248
312afd164009 remotefilelog: do file IO in terms of bytes
Augie Fackler <augie@google.com>
parents: 41192
diff changeset
   778
    reposfile = open(repospath, 'rb')
42057
566daffc607d cleanup: use set literals where possible
Martin von Zweigbergk <martinvonz@google.com>
parents: 41790
diff changeset
   779
    repos = {r[:-1] for r in reposfile.readlines()}
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   780
    reposfile.close()
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   781
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   782
    # build list of useful files
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   783
    validrepos = []
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   784
    keepkeys = set()
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   785
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   786
    sharedcache = None
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   787
    filesrepacked = False
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   788
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   789
    count = 0
40858
05afb32e9380 remotefilelog: use progress helper when analyzing repos
Martin von Zweigbergk <martinvonz@google.com>
parents: 40771
diff changeset
   790
    progress = ui.makeprogress(_("analyzing repositories"), unit="repos",
05afb32e9380 remotefilelog: use progress helper when analyzing repos
Martin von Zweigbergk <martinvonz@google.com>
parents: 40771
diff changeset
   791
                               total=len(repos))
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   792
    for path in repos:
40858
05afb32e9380 remotefilelog: use progress helper when analyzing repos
Martin von Zweigbergk <martinvonz@google.com>
parents: 40771
diff changeset
   793
        progress.update(count)
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   794
        count += 1
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   795
        try:
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   796
            path = ui.expandpath(os.path.normpath(path))
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   797
        except TypeError as e:
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   798
            ui.warn(_("warning: malformed path: %r:%s\n") % (path, e))
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   799
            traceback.print_exc()
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   800
            continue
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   801
        try:
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   802
            peer = hg.peer(ui, {}, path)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   803
            repo = peer._repo
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   804
        except error.RepoError:
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   805
            continue
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   806
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   807
        validrepos.append(path)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   808
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   809
        # Protect against any repo or config changes that have happened since
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   810
        # this repo was added to the repos file. We'd rather this loop succeed
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   811
        # and too much be deleted, than the loop fail and nothing gets deleted.
40564
6f0b6905ef6f shallowutil: introduce a helper function isenabled()
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 40563
diff changeset
   812
        if not isenabled(repo):
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   813
            continue
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   814
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   815
        if not util.safehasattr(repo, 'name'):
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   816
            ui.warn(_("repo %s is a misconfigured remotefilelog repo\n") % path)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   817
            continue
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   818
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   819
        # If garbage collection on repack and repack on hg gc are enabled
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   820
        # then loose files are repacked and garbage collected.
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   821
        # Otherwise regular garbage collection is performed.
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   822
        repackonhggc = repo.ui.configbool('remotefilelog', 'repackonhggc')
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   823
        gcrepack = repo.ui.configbool('remotefilelog', 'gcrepack')
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   824
        if repackonhggc and gcrepack:
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   825
            try:
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   826
                repackmod.incrementalrepack(repo)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   827
                filesrepacked = True
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   828
                continue
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   829
            except (IOError, repackmod.RepackAlreadyRunning):
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   830
                # If repack cannot be performed due to not enough disk space
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   831
                # continue doing garbage collection of loose files w/o repack
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   832
                pass
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   833
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   834
        reponame = repo.name
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   835
        if not sharedcache:
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   836
            sharedcache = repo.sharedstore
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   837
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   838
        # Compute a keepset which is not garbage collected
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   839
        def keyfn(fname, fnode):
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   840
            return fileserverclient.getcachekey(reponame, fname, hex(fnode))
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   841
        keepkeys = repackmod.keepset(repo, keyfn=keyfn, lastkeepkeys=keepkeys)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   842
40858
05afb32e9380 remotefilelog: use progress helper when analyzing repos
Martin von Zweigbergk <martinvonz@google.com>
parents: 40771
diff changeset
   843
    progress.complete()
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   844
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   845
    # write list of valid repos back
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   846
    oldumask = os.umask(0o002)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   847
    try:
41248
312afd164009 remotefilelog: do file IO in terms of bytes
Augie Fackler <augie@google.com>
parents: 41192
diff changeset
   848
        reposfile = open(repospath, 'wb')
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   849
        reposfile.writelines([("%s\n" % r) for r in validrepos])
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   850
        reposfile.close()
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   851
    finally:
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   852
        os.umask(oldumask)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   853
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   854
    # prune cache
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   855
    if sharedcache is not None:
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   856
        sharedcache.gc(keepkeys)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   857
    elif not filesrepacked:
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   858
        ui.warn(_("warning: no valid repos in repofile\n"))
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   859
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   860
def log(orig, ui, repo, *pats, **opts):
40564
6f0b6905ef6f shallowutil: introduce a helper function isenabled()
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 40563
diff changeset
   861
    if not isenabled(repo):
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   862
        return orig(ui, repo, *pats, **opts)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   863
40657
13d4ad8d7801 py3: fix keyword arguments handling in hgext/remotefilelog/
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 40624
diff changeset
   864
    follow = opts.get(r'follow')
13d4ad8d7801 py3: fix keyword arguments handling in hgext/remotefilelog/
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 40624
diff changeset
   865
    revs = opts.get(r'rev')
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   866
    if pats:
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   867
        # Force slowpath for non-follow patterns and follows that start from
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   868
        # non-working-copy-parent revs.
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   869
        if not follow or revs:
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   870
            # This forces the slowpath
40657
13d4ad8d7801 py3: fix keyword arguments handling in hgext/remotefilelog/
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 40624
diff changeset
   871
            opts[r'removed'] = True
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   872
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   873
        # If this is a non-follow log without any revs specified, recommend that
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   874
        # the user add -f to speed it up.
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   875
        if not follow and not revs:
41645
62bf34f70fe8 remotefilelog: replace matchandpats() by match()
Martin von Zweigbergk <martinvonz@google.com>
parents: 41248
diff changeset
   876
            match = scmutil.match(repo['.'], pats, pycompat.byteskwargs(opts))
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   877
            isfile = not match.anypats()
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   878
            if isfile:
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   879
                for file in match.files():
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   880
                    if not os.path.isfile(repo.wjoin(file)):
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   881
                        isfile = False
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   882
                        break
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   883
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   884
            if isfile:
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   885
                ui.warn(_("warning: file log can be slow on large repos - " +
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   886
                          "use -f to speed it up\n"))
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   887
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   888
    return orig(ui, repo, *pats, **opts)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   889
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   890
def revdatelimit(ui, revset):
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   891
    """Update revset so that only changesets no older than 'prefetchdays' days
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   892
    are included. The default value is set to 14 days. If 'prefetchdays' is set
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   893
    to zero or negative value then date restriction is not applied.
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   894
    """
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   895
    days = ui.configint('remotefilelog', 'prefetchdays')
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   896
    if days > 0:
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   897
        revset = '(%s) & date(-%s)' % (revset, days)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   898
    return revset
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   899
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   900
def readytofetch(repo):
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   901
    """Check that enough time has passed since the last background prefetch.
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   902
    This only relates to prefetches after operations that change the working
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   903
    copy parent. Default delay between background prefetches is 2 minutes.
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   904
    """
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   905
    timeout = repo.ui.configint('remotefilelog', 'prefetchdelay')
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   906
    fname = repo.vfs.join('lastprefetch')
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   907
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   908
    ready = False
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   909
    with open(fname, 'a'):
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   910
        # the with construct above is used to avoid race conditions
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   911
        modtime = os.path.getmtime(fname)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   912
        if (time.time() - modtime) > timeout:
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   913
            os.utime(fname, None)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   914
            ready = True
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   915
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   916
    return ready
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   917
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   918
def wcpprefetch(ui, repo, **kwargs):
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   919
    """Prefetches in background revisions specified by bgprefetchrevs revset.
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   920
    Does background repack if backgroundrepack flag is set in config.
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   921
    """
40564
6f0b6905ef6f shallowutil: introduce a helper function isenabled()
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 40563
diff changeset
   922
    shallow = isenabled(repo)
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   923
    bgprefetchrevs = ui.config('remotefilelog', 'bgprefetchrevs')
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   924
    isready = readytofetch(repo)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   925
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   926
    if not (shallow and bgprefetchrevs and isready):
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   927
        return
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   928
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   929
    bgrepack = repo.ui.configbool('remotefilelog', 'backgroundrepack')
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   930
    # update a revset with a date limit
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   931
    bgprefetchrevs = revdatelimit(ui, bgprefetchrevs)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   932
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   933
    def anon():
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   934
        if util.safehasattr(repo, 'ranprefetch') and repo.ranprefetch:
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   935
            return
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   936
        repo.ranprefetch = True
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   937
        repo.backgroundprefetch(bgprefetchrevs, repack=bgrepack)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   938
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   939
    repo._afterlock(anon)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   940
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   941
def pull(orig, ui, repo, *pats, **opts):
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   942
    result = orig(ui, repo, *pats, **opts)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   943
40564
6f0b6905ef6f shallowutil: introduce a helper function isenabled()
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 40563
diff changeset
   944
    if isenabled(repo):
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   945
        # prefetch if it's configured
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   946
        prefetchrevset = ui.config('remotefilelog', 'pullprefetch')
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   947
        bgrepack = repo.ui.configbool('remotefilelog', 'backgroundrepack')
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   948
        bgprefetch = repo.ui.configbool('remotefilelog', 'backgroundprefetch')
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   949
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   950
        if prefetchrevset:
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   951
            ui.status(_("prefetching file contents\n"))
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   952
            revs = scmutil.revrange(repo, [prefetchrevset])
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   953
            base = repo['.'].rev()
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   954
            if bgprefetch:
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   955
                repo.backgroundprefetch(prefetchrevset, repack=bgrepack)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   956
            else:
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   957
                repo.prefetch(revs, base=base)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   958
                if bgrepack:
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   959
                    repackmod.backgroundrepack(repo, incremental=True)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   960
        elif bgrepack:
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   961
            repackmod.backgroundrepack(repo, incremental=True)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   962
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   963
    return result
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   964
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   965
def exchangepull(orig, repo, remote, *args, **kwargs):
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   966
    # Hook into the callstream/getbundle to insert bundle capabilities
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   967
    # during a pull.
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   968
    def localgetbundle(orig, source, heads=None, common=None, bundlecaps=None,
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   969
                       **kwargs):
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   970
        if not bundlecaps:
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   971
            bundlecaps = set()
40559
ed19958dbf5d remotefilelog: consolidate and rename bundle2 capability
Augie Fackler <augie@google.com>
parents: 40558
diff changeset
   972
        bundlecaps.add(constants.BUNDLE2_CAPABLITY)
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   973
        return orig(source, heads=heads, common=common, bundlecaps=bundlecaps,
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   974
                    **kwargs)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   975
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   976
    if util.safehasattr(remote, '_callstream'):
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   977
        remote._localrepo = repo
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   978
    elif util.safehasattr(remote, 'getbundle'):
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   979
        extensions.wrapfunction(remote, 'getbundle', localgetbundle)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   980
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   981
    return orig(repo, remote, *args, **kwargs)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   982
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   983
def _fileprefetchhook(repo, revs, match):
40564
6f0b6905ef6f shallowutil: introduce a helper function isenabled()
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 40563
diff changeset
   984
    if isenabled(repo):
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   985
        allfiles = []
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   986
        for rev in revs:
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   987
            if rev == nodemod.wdirrev or rev is None:
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   988
                continue
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   989
            ctx = repo[rev]
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   990
            mf = ctx.manifest()
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   991
            sparsematch = repo.maybesparsematch(ctx.rev())
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   992
            for path in ctx.walk(match):
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   993
                if (not sparsematch or sparsematch(path)) and path in mf:
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   994
                    allfiles.append((path, hex(mf[path])))
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   995
        repo.fileservice.prefetch(allfiles)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   996
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   997
@command('debugremotefilelog', [
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   998
    ('d', 'decompress', None, _('decompress the filelog first')),
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
   999
    ], _('hg debugremotefilelog <path>'), norepo=True)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
  1000
def debugremotefilelog(ui, path, **opts):
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
  1001
    return debugcommands.debugremotefilelog(ui, path, **opts)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
  1002
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
  1003
@command('verifyremotefilelog', [
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
  1004
    ('d', 'decompress', None, _('decompress the filelogs first')),
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
  1005
    ], _('hg verifyremotefilelogs <directory>'), norepo=True)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
  1006
def verifyremotefilelog(ui, path, **opts):
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
  1007
    return debugcommands.verifyremotefilelog(ui, path, **opts)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
  1008
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
  1009
@command('debugdatapack', [
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
  1010
    ('', 'long', None, _('print the long hashes')),
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
  1011
    ('', 'node', '', _('dump the contents of node'), 'NODE'),
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
  1012
    ], _('hg debugdatapack <paths>'), norepo=True)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
  1013
def debugdatapack(ui, *paths, **opts):
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
  1014
    return debugcommands.debugdatapack(ui, *paths, **opts)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
  1015
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
  1016
@command('debughistorypack', [
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
  1017
    ], _('hg debughistorypack <path>'), norepo=True)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
  1018
def debughistorypack(ui, path, **opts):
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
  1019
    return debugcommands.debughistorypack(ui, path)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
  1020
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
  1021
@command('debugkeepset', [
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
  1022
    ], _('hg debugkeepset'))
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
  1023
def debugkeepset(ui, repo, **opts):
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
  1024
    # The command is used to measure keepset computation time
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
  1025
    def keyfn(fname, fnode):
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
  1026
        return fileserverclient.getcachekey(repo.name, fname, hex(fnode))
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
  1027
    repackmod.keepset(repo, keyfn)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
  1028
    return
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
  1029
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
  1030
@command('debugwaitonrepack', [
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
  1031
    ], _('hg debugwaitonrepack'))
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
  1032
def debugwaitonrepack(ui, repo, **opts):
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
  1033
    return debugcommands.debugwaitonrepack(repo)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
  1034
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
  1035
@command('debugwaitonprefetch', [
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
  1036
    ], _('hg debugwaitonprefetch'))
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
  1037
def debugwaitonprefetch(ui, repo, **opts):
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
  1038
    return debugcommands.debugwaitonprefetch(repo)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
  1039
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
  1040
def resolveprefetchopts(ui, opts):
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
  1041
    if not opts.get('rev'):
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
  1042
        revset = ['.', 'draft()']
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
  1043
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
  1044
        prefetchrevset = ui.config('remotefilelog', 'pullprefetch', None)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
  1045
        if prefetchrevset:
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
  1046
            revset.append('(%s)' % prefetchrevset)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
  1047
        bgprefetchrevs = ui.config('remotefilelog', 'bgprefetchrevs', None)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
  1048
        if bgprefetchrevs:
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
  1049
            revset.append('(%s)' % bgprefetchrevs)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
  1050
        revset = '+'.join(revset)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
  1051
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
  1052
        # update a revset with a date limit
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
  1053
        revset = revdatelimit(ui, revset)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
  1054
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
  1055
        opts['rev'] = [revset]
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
  1056
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
  1057
    if not opts.get('base'):
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
  1058
        opts['base'] = None
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
  1059
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
  1060
    return opts
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
  1061
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
  1062
@command('prefetch', [
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
  1063
    ('r', 'rev', [], _('prefetch the specified revisions'), _('REV')),
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
  1064
    ('', 'repack', False, _('run repack after prefetch')),
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
  1065
    ('b', 'base', '', _("rev that is assumed to already be local")),
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
  1066
    ] + commands.walkopts, _('hg prefetch [OPTIONS] [FILE...]'))
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
  1067
def prefetch(ui, repo, *pats, **opts):
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
  1068
    """prefetch file revisions from the server
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
  1069
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
  1070
    Prefetchs file revisions for the specified revs and stores them in the
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
  1071
    local remotefilelog cache.  If no rev is specified, the default rev is
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
  1072
    used which is the union of dot, draft, pullprefetch and bgprefetchrev.
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
  1073
    File names or patterns can be used to limit which files are downloaded.
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
  1074
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
  1075
    Return 0 on success.
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
  1076
    """
40657
13d4ad8d7801 py3: fix keyword arguments handling in hgext/remotefilelog/
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 40624
diff changeset
  1077
    opts = pycompat.byteskwargs(opts)
40564
6f0b6905ef6f shallowutil: introduce a helper function isenabled()
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 40563
diff changeset
  1078
    if not isenabled(repo):
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
  1079
        raise error.Abort(_("repo is not shallow"))
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
  1080
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
  1081
    opts = resolveprefetchopts(ui, opts)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
  1082
    revs = scmutil.revrange(repo, opts.get('rev'))
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
  1083
    repo.prefetch(revs, opts.get('base'), pats, opts)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
  1084
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
  1085
    # Run repack in background
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
  1086
    if opts.get('repack'):
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
  1087
        repackmod.backgroundrepack(repo, incremental=True)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
  1088
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
  1089
@command('repack', [
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
  1090
     ('', 'background', None, _('run in a background process'), None),
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
  1091
     ('', 'incremental', None, _('do an incremental repack'), None),
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
  1092
     ('', 'packsonly', None, _('only repack packs (skip loose objects)'), None),
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
  1093
    ], _('hg repack [OPTIONS]'))
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
  1094
def repack_(ui, repo, *pats, **opts):
40657
13d4ad8d7801 py3: fix keyword arguments handling in hgext/remotefilelog/
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 40624
diff changeset
  1095
    if opts.get(r'background'):
13d4ad8d7801 py3: fix keyword arguments handling in hgext/remotefilelog/
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 40624
diff changeset
  1096
        repackmod.backgroundrepack(repo, incremental=opts.get(r'incremental'),
13d4ad8d7801 py3: fix keyword arguments handling in hgext/remotefilelog/
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 40624
diff changeset
  1097
                                   packsonly=opts.get(r'packsonly', False))
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
  1098
        return
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
  1099
40657
13d4ad8d7801 py3: fix keyword arguments handling in hgext/remotefilelog/
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 40624
diff changeset
  1100
    options = {'packsonly': opts.get(r'packsonly')}
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
  1101
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
  1102
    try:
40657
13d4ad8d7801 py3: fix keyword arguments handling in hgext/remotefilelog/
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 40624
diff changeset
  1103
        if opts.get(r'incremental'):
40545
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
  1104
            repackmod.incrementalrepack(repo, options=options)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
  1105
        else:
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
  1106
            repackmod.fullrepack(repo, options=options)
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
  1107
    except repackmod.RepackAlreadyRunning as ex:
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
  1108
        # Don't propogate the exception if the repack is already in
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
  1109
        # progress, since we want the command to exit 0.
3a333a582d7b remotefilelog: import pruned-down remotefilelog extension from hg-experimental
Augie Fackler <augie@google.com>
parents:
diff changeset
  1110
        repo.ui.warn('%s\n' % ex)