##// END OF EJS Templates
tests: replace "cp -r" with "cp -R"...
tests: replace "cp -r" with "cp -R" The POSIX documentation about "cp" [1] says: .... RATIONALE .... Earlier versions of this standard included support for the -r option to copy file hierarchies. The -r option is historical practice on BSD and BSD-derived systems. This option is no longer specified by POSIX.1-2008 but may be present in some implementations. The -R option was added as a close synonym to the -r option, selected for consistency with all other options in this volume of POSIX.1-2008 that do recursive directory descent. The difference between -R and the removed -r option is in the treatment by cp of file types other than regular and directory. It was implementation-defined how the - option treated special files to allow both historical implementations and those that chose to support -r with the same abilities as -R defined by this volume of POSIX.1-2008. The original -r flag, for historic reasons, did not handle special files any differently from regular files, but always read the file and copied its contents. This had obvious problems in the presence of special file types; for example, character devices, FIFOs, and sockets. .... .... Issue 6 The -r option is marked obsolescent. .... Issue 7 .... The obsolescent -r option is removed. .... (No "Issue 8" yet) Therefore it's clear that "cp -R" is strictly better than "cp -r". The issue was discovered when running tests on OS X after 0d87b1caed92. [1]: pubs.opengroup.org/onlinepubs/9699919799/utilities/cp.html

File last commit:

r28047:863075fd default
r30556:c059286a default
Show More
hg-ssh
86 lines | 2.9 KiB | text/plain | TextLexer
Thomas Arendsen Hein
Added hg-ssh - a wrapper for ssh access to a limited set of mercurial repos...
r1537 #!/usr/bin/env python
#
Thomas Arendsen Hein
Adjust contrib/hg-ssh for moved dispatch() function.
r5191 # Copyright 2005-2007 by Intevation GmbH <intevation@intevation.de>
Martin Geisler
add blank line after copyright notices and after header
r8228 #
Thomas Arendsen Hein
Added hg-ssh - a wrapper for ssh access to a limited set of mercurial repos...
r1537 # Author(s):
# Thomas Arendsen Hein <thomas@intevation.de>
#
Martin Geisler
updated license to be explicit about GPL version 2
r8225 # This software may be used and distributed according to the terms of the
Matt Mackall
Update license to GPLv2+
r10263 # GNU General Public License version 2 or any later version.
Thomas Arendsen Hein
Added hg-ssh - a wrapper for ssh access to a limited set of mercurial repos...
r1537
"""
hg-ssh - a wrapper for ssh access to a limited set of mercurial repos
To be used in ~/.ssh/authorized_keys with the "command" option, see sshd(8):
command="hg-ssh path/to/repo1 /path/to/repo2 ~/repo3 ~user/repo4" ssh-dss ...
(probably together with these other useful options:
no-port-forwarding,no-X11-forwarding,no-agent-forwarding)
Andreas Freimuth
hg-ssh: fix duplicate word in docstring
r13996 This allows pull/push over ssh from/to the repositories given as arguments.
Thomas Arendsen Hein
Added hg-ssh - a wrapper for ssh access to a limited set of mercurial repos...
r1537
If all your repositories are subdirectories of a common directory, you can
allow shorter paths with:
command="cd path/to/my/repositories && hg-ssh repo1 subdir/repo2"
Thomas Arendsen Hein
Added hint to hg-ssh that you can use shell pattern matching.
r1640
You can use pattern matching of your normal shell, e.g.:
command="cd repos && hg-ssh user/thomas/* projects/{mercurial,foo}"
David Schleimer
hg-ssh: read-only flag...
r16836
You can also add a --read-only flag to allow read-only access to a key, e.g.:
command="hg-ssh --read-only repos/*"
Thomas Arendsen Hein
Added hg-ssh - a wrapper for ssh access to a limited set of mercurial repos...
r1537 """
Thomas Arendsen Hein
Enable demandimport only in scripts, not in importable modules (issue605)...
r5197 # enable importing on demand to reduce startup time
from mercurial import demandimport; demandimport.enable()
Thomas Arendsen Hein
Adjust contrib/hg-ssh for moved dispatch() function.
r5191 from mercurial import dispatch
Thomas Arendsen Hein
Added hg-ssh - a wrapper for ssh access to a limited set of mercurial repos...
r1537
Mads Kiilerich
hg-ssh: use shlex for shell-like parsing of SSH_ORIGINAL_COMMAND...
r15897 import sys, os, shlex
Thomas Arendsen Hein
Added hg-ssh - a wrapper for ssh access to a limited set of mercurial repos...
r1537
David Schleimer
hg-ssh: refactor to have main() method...
r16779 def main():
cwd = os.getcwd()
David Schleimer
hg-ssh: read-only flag...
r16836 readonly = False
args = sys.argv[1:]
while len(args):
if args[0] == '--read-only':
readonly = True
args.pop(0)
else:
break
David Schleimer
hg-ssh: refactor to have main() method...
r16779 allowed_paths = [os.path.normpath(os.path.join(cwd,
os.path.expanduser(path)))
David Schleimer
hg-ssh: read-only flag...
r16836 for path in args]
David Schleimer
hg-ssh: refactor to have main() method...
r16779 orig_cmd = os.getenv('SSH_ORIGINAL_COMMAND', '?')
try:
cmdargv = shlex.split(orig_cmd)
FUJIWARA Katsunori
misc: use modern exception syntax...
r28047 except ValueError as e:
David Schleimer
hg-ssh: refactor to have main() method...
r16779 sys.stderr.write('Illegal command "%s": %s\n' % (orig_cmd, e))
sys.exit(255)
Thomas Arendsen Hein
Added hg-ssh - a wrapper for ssh access to a limited set of mercurial repos...
r1537
David Schleimer
hg-ssh: refactor to have main() method...
r16779 if cmdargv[:2] == ['hg', '-R'] and cmdargv[3:] == ['serve', '--stdio']:
path = cmdargv[2]
repo = os.path.normpath(os.path.join(cwd, os.path.expanduser(path)))
if repo in allowed_paths:
David Schleimer
hg-ssh: read-only flag...
r16836 cmd = ['-R', repo, 'serve', '--stdio']
if readonly:
cmd += [
'--config',
Pierre-Yves David
hg-ssh: reject push earlier (on pretxnopen)...
r25127 'hooks.pretxnopen.hg-ssh=python:__main__.rejectpush',
David Schleimer
hg-ssh: read-only flag...
r16836 '--config',
'hooks.prepushkey.hg-ssh=python:__main__.rejectpush'
]
dispatch.dispatch(dispatch.request(cmd))
David Schleimer
hg-ssh: refactor to have main() method...
r16779 else:
sys.stderr.write('Illegal repository "%s"\n' % repo)
sys.exit(255)
Thomas Arendsen Hein
Added hg-ssh - a wrapper for ssh access to a limited set of mercurial repos...
r1537 else:
David Schleimer
hg-ssh: refactor to have main() method...
r16779 sys.stderr.write('Illegal command "%s"\n' % orig_cmd)
Mads Kiilerich
hg-ssh: exit with 255 instead of -1 on error...
r16607 sys.exit(255)
Thomas Arendsen Hein
Added hg-ssh - a wrapper for ssh access to a limited set of mercurial repos...
r1537
David Schleimer
hg-ssh: read-only flag...
r16836 def rejectpush(ui, **kwargs):
FUJIWARA Katsunori
hg-ssh: parenthesize non-translated message...
r28045 ui.warn(("Permission denied\n"))
David Schleimer
hg-ssh: read-only flag...
r16836 # mercurial hooks use unix process conventions for hook return values
# so a truthy return means failure
return True
David Schleimer
hg-ssh: refactor to have main() method...
r16779 if __name__ == '__main__':
main()