Details
Details
- Reviewers
- None
- Group Reviewers
Restricted Project - Commits
- rFBHGX338a1e76c3a9: remotefilelog: drop support for hg < 3.6
Diff Detail
Diff Detail
- Repository
- rFBHGX Facebook Mercurial Extensions
- Lint
Lint Skipped - Unit
Unit Tests Skipped
Restricted Project |
Lint Skipped |
Unit Tests Skipped |
Path | Packages | |||
---|---|---|---|---|
M | remotefilelog/remotefilelogserver.py (18 lines) |
Status | Author | Revision | |
---|---|---|---|
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz |
# remotefilelogserver.py - server logic for a remotefilelog server | # remotefilelogserver.py - server logic for a remotefilelog server | ||||
# | # | ||||
# Copyright 2013 Facebook, Inc. | # Copyright 2013 Facebook, Inc. | ||||
# | # | ||||
# This software may be used and distributed according to the terms of the | # This software may be used and distributed according to the terms of the | ||||
# GNU General Public License version 2 or any later version. | # GNU General Public License version 2 or any later version. | ||||
from __future__ import absolute_import | from __future__ import absolute_import | ||||
from mercurial import wireproto, changegroup, match, util, changelog, context | from mercurial import wireproto, changegroup, match, util, changelog, context | ||||
from mercurial import exchange, store, error | from mercurial import store, error | ||||
from mercurial import streamclone | |||||
from mercurial.extensions import wrapfunction | from mercurial.extensions import wrapfunction | ||||
from mercurial.node import bin, hex, nullid, nullrev | from mercurial.node import bin, hex, nullid, nullrev | ||||
from mercurial.i18n import _ | from mercurial.i18n import _ | ||||
from . import ( | from . import ( | ||||
constants, | constants, | ||||
lz4wrapper, | lz4wrapper, | ||||
shallowrepo, | shallowrepo, | ||||
shallowutil, | shallowutil, | ||||
wirepack, | wirepack, | ||||
) | ) | ||||
import errno, stat, os, time | import errno, stat, os, time | ||||
try: | try: | ||||
from mercurial import sshserver | from mercurial import sshserver | ||||
_sshv1server = sshserver.sshserver | _sshv1server = sshserver.sshserver | ||||
except ImportError: | except ImportError: | ||||
from mercurial import wireprotoserver | from mercurial import wireprotoserver | ||||
_sshv1server = wireprotoserver.sshv1protocolhandler | _sshv1server = wireprotoserver.sshv1protocolhandler | ||||
try: | try: | ||||
from mercurial import streamclone | |||||
streamclone._walkstreamfiles | |||||
hasstreamclone = True | |||||
except Exception: | |||||
hasstreamclone = False | |||||
try: | |||||
# hg 4.6 and later | # hg 4.6 and later | ||||
from mercurial import wireprotoserver as httpprotocol | from mercurial import wireprotoserver as httpprotocol | ||||
httpprotocol.HTTP_OK # force demandimport | httpprotocol.HTTP_OK # force demandimport | ||||
except ImportError: | except ImportError: | ||||
# hg 4.5 and earlier | # hg 4.5 and earlier | ||||
from mercurial.hgweb import protocol as httpprotocol | from mercurial.hgweb import protocol as httpprotocol | ||||
httpprotocol.decodevaluefromheaders | httpprotocol.decodevaluefromheaders | ||||
# since it would require fetching every version of every | # since it would require fetching every version of every | ||||
# file in order to create the revlogs. | # file in order to create the revlogs. | ||||
raise error.Abort(_("Cannot clone from a shallow repo " | raise error.Abort(_("Cannot clone from a shallow repo " | ||||
"to a full repo.")) | "to a full repo.")) | ||||
else: | else: | ||||
for x in orig(repo): | for x in orig(repo): | ||||
yield x | yield x | ||||
# This function moved in Mercurial 3.5 and 3.6 | |||||
if hasstreamclone: | |||||
wrapfunction(streamclone, '_walkstreamfiles', _walkstreamfiles) | wrapfunction(streamclone, '_walkstreamfiles', _walkstreamfiles) | ||||
elif util.safehasattr(wireproto, '_walkstreamfiles'): | |||||
wrapfunction(wireproto, '_walkstreamfiles', _walkstreamfiles) | |||||
else: | |||||
wrapfunction(exchange, '_walkstreamfiles', _walkstreamfiles) | |||||
# We no longer use getbundle_shallow commands, but we must still | # We no longer use getbundle_shallow commands, but we must still | ||||
# support it for migration purposes | # support it for migration purposes | ||||
def getbundleshallow(repo, proto, others): | def getbundleshallow(repo, proto, others): | ||||
bundlecaps = others.get('bundlecaps', '') | bundlecaps = others.get('bundlecaps', '') | ||||
bundlecaps = set(bundlecaps.split(',')) | bundlecaps = set(bundlecaps.split(',')) | ||||
bundlecaps.add('remotefilelog') | bundlecaps.add('remotefilelog') | ||||
others['bundlecaps'] = ','.join(bundlecaps) | others['bundlecaps'] = ','.join(bundlecaps) |