##// END OF EJS Templates
bundle2: make server.bundle2.stream default to True...
bundle2: make server.bundle2.stream default to True Support for bundle2 streaming clones has been shipped in Mercurial 4.5 (7eedbd5d4880), but was never activated by default. It's time to have more people use it. The new format allows streaming clones to transport cache (hooray for speed) and phaseroots (fixes phase-related issues). Changes in tests: bundle2 capabilities now have "stream=v2" (plus a '\n' as a separator) and therefore take 14 bytes more: "%0Astream%3Dv2". Tip for tests that have data encoded with CBOR: 0xd3 - 0xc5 = 14. $USUAL_BUNDLE2_CAPS$ replaces $USUAL_BUNDLE2_CAPS_SERVER$, which is the same thing, but without "stream=v2". Since streaming clones now also transfer caches, the reported byte and file counts are higher (e.g. 816 bytes in 9 files instead of 613 bytes in 4 files, a bit of --debug and manual math confirms that the caches take these extra 203 bytes in 5 files). Differential Revision: https://phab.mercurial-scm.org/D4680

File last commit:

r34648:dacfcdd8 default
r39758:4bd6e444 default
Show More
scmposix.py
85 lines | 2.4 KiB | text/x-python | PythonLexer
Gregory Szorc
scmposix: use absolute_import
r27483 from __future__ import absolute_import
Yuya Nishihara
scmutil: narrow ImportError handling in termwidth()...
r30311 import array
Yuya Nishihara
scmutil: move util.termwidth()...
r30309 import errno
import fcntl
Gregory Szorc
scmposix: use absolute_import
r27483 import os
import sys
from . import (
Pulkit Goyal
py3: make scmposix.userrcpath() return bytes...
r30276 encoding,
Pulkit Goyal
py3: use pycompat.sysargv in scmposix.systemrcpath()...
r30467 pycompat,
Yuya Nishihara
osutil: proxy through util (and platform) modules (API)...
r32203 util,
Gregory Szorc
scmposix: use absolute_import
r27483 )
Kevin Bullock
scmutil: split platform-specific bits into their own modules...
r18690
Yuya Nishihara
pager: use less as a fallback on Unix...
r32078 # BSD 'more' escapes ANSI color sequences by default. This can be disabled by
# $MORE variable, but there's no compatible option with Linux 'more'. Given
# OS X is widely used and most modern Unix systems would have 'less', setting
# 'less' as the default seems reasonable.
fallbackpager = 'less'
Kevin Bullock
scmutil: split platform-specific bits into their own modules...
r18690 def _rcfiles(path):
rcs = [os.path.join(path, 'hgrc')]
rcdir = os.path.join(path, 'hgrc.d')
try:
rcs.extend([os.path.join(rcdir, f)
Yuya Nishihara
osutil: proxy through util (and platform) modules (API)...
r32203 for f, kind in util.listdir(rcdir)
Kevin Bullock
scmutil: split platform-specific bits into their own modules...
r18690 if f.endswith(".rc")])
except OSError:
pass
return rcs
def systemrcpath():
path = []
Pulkit Goyal
py3: replace sys.platform with pycompat.sysplatform (part 1 of 2)...
r30641 if pycompat.sysplatform == 'plan9':
Kevin Bullock
scmutil: split platform-specific bits into their own modules...
r18690 root = 'lib/mercurial'
else:
root = 'etc/mercurial'
# old mod_python does not set sys.argv
if len(getattr(sys, 'argv', [])) > 0:
Pulkit Goyal
py3: use pycompat.sysargv in scmposix.systemrcpath()...
r30467 p = os.path.dirname(os.path.dirname(pycompat.sysargv[0]))
Mads Kiilerich
config: don't read the same config file twice...
r22583 if p != '/':
path.extend(_rcfiles(os.path.join(p, root)))
Kevin Bullock
scmutil: split platform-specific bits into their own modules...
r18690 path.extend(_rcfiles('/' + root))
return path
def userrcpath():
Pulkit Goyal
py3: replace sys.platform with pycompat.sysplatform (part 1 of 2)...
r30641 if pycompat.sysplatform == 'plan9':
Pulkit Goyal
py3: make scmposix.userrcpath() return bytes...
r30276 return [encoding.environ['home'] + '/lib/hgrc']
Jun Wu
codemod: use pycompat.isdarwin...
r34648 elif pycompat.isdarwin:
David Demelier
hg: allow usage of XDG_CONFIG_HOME/hg/hgrc...
r30941 return [os.path.expanduser('~/.hgrc')]
Kevin Bullock
scmutil: split platform-specific bits into their own modules...
r18690 else:
David Demelier
hg: allow usage of XDG_CONFIG_HOME/hg/hgrc...
r30941 confighome = encoding.environ.get('XDG_CONFIG_HOME')
if confighome is None or not os.path.isabs(confighome):
confighome = os.path.expanduser('~/.config')
return [os.path.expanduser('~/.hgrc'),
os.path.join(confighome, 'hg', 'hgrc')]
Yuya Nishihara
scmutil: move util.termwidth()...
r30309
Yuya Nishihara
scmutil: extend termwidth() to return terminal height, renamed to termsize()...
r30314 def termsize(ui):
Yuya Nishihara
scmutil: move util.termwidth()...
r30309 try:
import termios
Yuya Nishihara
scmutil: narrow ImportError handling in termwidth()...
r30311 TIOCGWINSZ = termios.TIOCGWINSZ # unavailable on IRIX (issue3449)
except (AttributeError, ImportError):
Yuya Nishihara
scmutil: extend termwidth() to return terminal height, renamed to termsize()...
r30314 return 80, 24
Yuya Nishihara
scmutil: remove superfluous indent from termwidth()
r30312
for dev in (ui.ferr, ui.fout, ui.fin):
try:
Yuya Nishihara
scmutil: move util.termwidth()...
r30309 try:
Yuya Nishihara
scmutil: remove superfluous indent from termwidth()
r30312 fd = dev.fileno()
except AttributeError:
continue
if not os.isatty(fd):
continue
arri = fcntl.ioctl(fd, TIOCGWINSZ, '\0' * 8)
Pulkit Goyal
smcposix: pass unicode as first argument to array.array...
r31339 height, width = array.array(r'h', arri)[:2]
Yuya Nishihara
scmutil: extend termwidth() to return terminal height, renamed to termsize()...
r30314 if width > 0 and height > 0:
return width, height
Yuya Nishihara
scmutil: remove superfluous indent from termwidth()
r30312 except ValueError:
pass
except IOError as e:
if e[0] == errno.EINVAL:
Yuya Nishihara
scmutil: move util.termwidth()...
r30309 pass
Yuya Nishihara
scmutil: remove superfluous indent from termwidth()
r30312 else:
raise
Yuya Nishihara
scmutil: extend termwidth() to return terminal height, renamed to termsize()...
r30314 return 80, 24