mirror of
https://github.com/facebook/sapling.git
synced 2024-10-07 15:27:13 +03:00
allow eden mount
and eden unmount
to take multiple paths
Summary: A minor convenience for mass mounting and unmounting. Reviewed By: simpkins Differential Revision: D6803003 fbshipit-source-id: 16c0d6982ba0ce2dba9900ee15013fcec8bc5ad5
This commit is contained in:
parent
7673f16536
commit
00d6bcc115
@ -35,7 +35,7 @@ def find_default_config_dir(home_dir):
|
||||
return os.path.join(home_dir, DEFAULT_CONFIG_DIR)
|
||||
|
||||
|
||||
def create_config(args):
|
||||
def create_config(args) -> config_mod.Config:
|
||||
home_dir = args.home_dir or util.get_home_dir()
|
||||
config = args.config_dir or find_default_config_dir(home_dir)
|
||||
return config_mod.Config(config, args.etc_eden_dir, home_dir)
|
||||
|
@ -424,7 +424,7 @@ Do you want to run `eden mount %s` instead?''' % (path, path))
|
||||
with open(config_path, 'w') as f:
|
||||
toml.dump(config_data, f)
|
||||
|
||||
def mount(self, path):
|
||||
def mount(self, path) -> int:
|
||||
# Load the config info for this client, to make sure we
|
||||
# know about the client.
|
||||
path = os.path.realpath(path)
|
||||
@ -467,7 +467,9 @@ Do you want to run `eden mount %s` instead?''' % (path, path))
|
||||
with self.get_thrift_client() as client:
|
||||
client.mount(mount_info)
|
||||
|
||||
def unmount(self, path, delete_config):
|
||||
return 0
|
||||
|
||||
def unmount(self, path, delete_config) -> None:
|
||||
path = os.path.realpath(path)
|
||||
with self.get_thrift_client() as client:
|
||||
client.unmount(path)
|
||||
|
@ -170,8 +170,7 @@ def do_uptime(args: argparse.Namespace, out: IO[bytes] = None):
|
||||
days = uptime.days
|
||||
hours, remainder = divmod(uptime.seconds, 3600)
|
||||
minutes, seconds = divmod(remainder, 60)
|
||||
uptime = b'%dd:%02dh:%02dm:%02ds\n' % (days, hours, minutes, seconds)
|
||||
out.write(uptime)
|
||||
out.write(b'%dd:%02dh:%02dm:%02ds\n' % (days, hours, minutes, seconds))
|
||||
|
||||
|
||||
def do_hg_copy_map_get_all(args: argparse.Namespace):
|
||||
|
@ -261,24 +261,29 @@ def do_doctor(args) -> int:
|
||||
mount_table=mtab.LinuxMountTable())
|
||||
|
||||
|
||||
def do_mount(args):
|
||||
def do_mount(args) -> int:
|
||||
config = create_config(args)
|
||||
try:
|
||||
return config.mount(args.path)
|
||||
except EdenNotRunningError as ex:
|
||||
print_stderr('error: {}', ex)
|
||||
return 1
|
||||
for path in args.paths:
|
||||
try:
|
||||
exitcode = config.mount(path)
|
||||
if exitcode:
|
||||
return exitcode
|
||||
except EdenNotRunningError as ex:
|
||||
print_stderr('error: {}', ex)
|
||||
return 1
|
||||
return 0
|
||||
|
||||
|
||||
def do_unmount(args):
|
||||
args.path = normalize_path_arg(args.path)
|
||||
def do_unmount(args) -> int:
|
||||
config = create_config(args)
|
||||
try:
|
||||
return config.unmount(args.path, delete_config=args.destroy)
|
||||
except EdenService.EdenError as ex:
|
||||
print_stderr('error: {}', ex)
|
||||
return 1
|
||||
|
||||
for path in args.paths:
|
||||
path = normalize_path_arg(path)
|
||||
try:
|
||||
config.unmount(path, delete_config=args.destroy)
|
||||
except EdenService.EdenError as ex:
|
||||
print_stderr('error: {}', ex)
|
||||
return 1
|
||||
return 0
|
||||
|
||||
def do_checkout(args):
|
||||
config = create_config(args)
|
||||
@ -610,7 +615,7 @@ def create_parser():
|
||||
'mount', help='Remount an existing client (for instance, after it was '
|
||||
'unmounted with "unmount")')
|
||||
mount_parser.add_argument(
|
||||
'path', help='The client mount path')
|
||||
'paths', nargs='+', metavar='path', help='The client mount path')
|
||||
mount_parser.set_defaults(func=do_mount)
|
||||
|
||||
unmount_parser = subparsers.add_parser(
|
||||
@ -620,7 +625,8 @@ def create_parser():
|
||||
action='store_true',
|
||||
help='Permanently delete all state associated with the client.')
|
||||
unmount_parser.add_argument(
|
||||
'path', help='Path where client should be unmounted from')
|
||||
'paths', nargs='+', metavar='path',
|
||||
help='Path where client should be unmounted from')
|
||||
unmount_parser.set_defaults(func=do_unmount)
|
||||
|
||||
# We intentionally do not specify a help option for debug, so it
|
||||
|
Loading…
Reference in New Issue
Block a user