mirror of
https://github.com/facebook/sapling.git
synced 2024-10-09 08:18:15 +03:00
Add remoteid extension (prints FQDN of remote host during remote session)
Summary: Wrap the capabilities wire protocol command to print the hostname to stderr. This commit contains the implementation of the extension but not code to register it on a particular repo. Test Plan: `rt` Reviewers: #sourcecontrol, rmcelroy Reviewed By: rmcelroy Subscribers: durham, wez, stash, simonfar, mjpieters Differential Revision: https://phabricator.intern.facebook.com/D5087634 Tasks: 16758829 Signature: t1:5087634:1495498748:213a32c5c474145371bbbc43b0463dee31868a9a
This commit is contained in:
parent
f1be725a71
commit
668afbd5d2
16
remoteid.py
Normal file
16
remoteid.py
Normal file
@ -0,0 +1,16 @@
|
||||
# Copyright 2016-present Facebook. All Rights Reserved.
|
||||
#
|
||||
# print server fqdn during a remote session
|
||||
|
||||
import socket
|
||||
|
||||
from mercurial import wireproto
|
||||
from mercurial.extensions import wrapfunction
|
||||
from mercurial.i18n import _
|
||||
|
||||
def extsetup(ui):
|
||||
def printhostname(orig, *args, **kwargs):
|
||||
ui.warn(_('hostname') + ': ' + socket.getfqdn())
|
||||
return orig(*args, **kwargs)
|
||||
|
||||
wrapfunction(wireproto, '_capabilities', printhostname)
|
37
tests/test-remoteid-print.t
Normal file
37
tests/test-remoteid-print.t
Normal file
@ -0,0 +1,37 @@
|
||||
$ PYTHONPATH=$TESTDIR/..:$PYTHONPATH
|
||||
$ export PYTHONPATH
|
||||
|
||||
$ . "$TESTDIR/library.sh"
|
||||
|
||||
# create a repo to behave as the server
|
||||
|
||||
$ hginit server
|
||||
$ cd server
|
||||
$ echo x > x
|
||||
$ hg commit -qAm x
|
||||
|
||||
# enable the remoteid extension
|
||||
|
||||
$ fb_hgext_dir=`realpath $TESTDIR/..`
|
||||
$ cat >> .hg/hgrc <<EOF
|
||||
> [extensions]
|
||||
> remoteid=$fb_hgext_dir/remoteid.py
|
||||
>
|
||||
> [remotefilelog]
|
||||
> server=True
|
||||
> EOF
|
||||
|
||||
# clone the server repo - should display "hostname: ..."
|
||||
|
||||
$ cd ..
|
||||
$ hgcloneshallow ssh://user@dummy/server client
|
||||
remote: hostname: * (glob)
|
||||
streaming all changes
|
||||
2 files to transfer, 227 bytes of data
|
||||
transferred 227 bytes in * seconds (*/sec) (glob)
|
||||
searching for changes
|
||||
no changes found
|
||||
updating to branch default
|
||||
remote: hostname: * (glob)
|
||||
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
|
||||
1 files fetched over 1 fetches - (1 misses, 0.00% hit ratio) over *s (glob)
|
Loading…
Reference in New Issue
Block a user