Details
Details
- Reviewers
quark - Group Reviewers
Restricted Project - Commits
- rFBHGX8282e266a9e6: compat: add support for hg >= a81d02ea
Diff Detail
Diff Detail
- Repository
- rFBHGX Facebook Mercurial Extensions
- Lint
Lint Skipped - Unit
Unit Tests Skipped
quark |
Restricted Project |
Lint Skipped |
Unit Tests Skipped |
Path | Packages | |||
---|---|---|---|---|
M | remotefilelog/fileserverclient.py (9 lines) |
Status | Author | Revision | |
---|---|---|---|
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz | ||
Closed | martinvonz |
try: | try: | ||||
# hg 4.6 and later | # hg 4.6 and later | ||||
_sshv1peer = sshpeer.sshpeer | _sshv1peer = sshpeer.sshpeer | ||||
except AttributeError: | except AttributeError: | ||||
# hg 4.5 and earlier | # hg 4.5 and earlier | ||||
_sshv1peer = sshpeer.sshv1peer | _sshv1peer = sshpeer.sshv1peer | ||||
try: | |||||
from mercurial.wireprotov1peer import batchable | |||||
except (ImportError, AttributeError): | |||||
from mercurial.wireproto import batchable | |||||
# Statistics for debugging | # Statistics for debugging | ||||
fetchcost = 0 | fetchcost = 0 | ||||
fetches = 0 | fetches = 0 | ||||
fetched = 0 | fetched = 0 | ||||
fetchmisses = 0 | fetchmisses = 0 | ||||
_lfsmod = None | _lfsmod = None | ||||
_downloading = _('downloading') | _downloading = _('downloading') | ||||
def getcachekey(reponame, file, id): | def getcachekey(reponame, file, id): | ||||
pathhash = hashlib.sha1(file).hexdigest() | pathhash = hashlib.sha1(file).hexdigest() | ||||
return os.path.join(reponame, pathhash[:2], pathhash[2:], id) | return os.path.join(reponame, pathhash[:2], pathhash[2:], id) | ||||
def getlocalkey(file, id): | def getlocalkey(file, id): | ||||
pathhash = hashlib.sha1(file).hexdigest() | pathhash = hashlib.sha1(file).hexdigest() | ||||
return os.path.join(pathhash, id) | return os.path.join(pathhash, id) | ||||
def peersetup(ui, peer): | def peersetup(ui, peer): | ||||
class remotefilepeer(peer.__class__): | class remotefilepeer(peer.__class__): | ||||
@wireproto.batchable | @batchable | ||||
def getfile(self, file, node): | def getfile(self, file, node): | ||||
if not self.capable('getfile'): | if not self.capable('getfile'): | ||||
raise error.Abort( | raise error.Abort( | ||||
'configured remotefile server does not support getfile') | 'configured remotefile server does not support getfile') | ||||
f = wireproto.future() | f = wireproto.future() | ||||
yield {'file': file, 'node': node}, f | yield {'file': file, 'node': node}, f | ||||
code, data = f.value.split('\0', 1) | code, data = f.value.split('\0', 1) | ||||
if int(code): | if int(code): | ||||
raise error.LookupError(file, node, data) | raise error.LookupError(file, node, data) | ||||
yield data | yield data | ||||
@wireproto.batchable | @batchable | ||||
def getflogheads(self, path): | def getflogheads(self, path): | ||||
if not self.capable('getflogheads'): | if not self.capable('getflogheads'): | ||||
raise error.Abort('configured remotefile server does not ' | raise error.Abort('configured remotefile server does not ' | ||||
'support getflogheads') | 'support getflogheads') | ||||
f = wireproto.future() | f = wireproto.future() | ||||
yield {'path': path}, f | yield {'path': path}, f | ||||
heads = f.value.split('\n') if f.value else [] | heads = f.value.split('\n') if f.value else [] | ||||
yield heads | yield heads |