Add option to checkout all deps (even unused-indirect deps)

eg:
    bam checkout path/ --all-deps
This commit is contained in:
2014-12-16 11:17:13 +01:00
parent 1f7fb125b9
commit 441742a496
3 changed files with 35 additions and 12 deletions

View File

@@ -361,7 +361,12 @@ class bam_commands:
print("Session %r created" % session_name)
@staticmethod
def checkout(path, output_dir=None, session_rootdir_partial=None):
def checkout(
path,
output_dir=None,
session_rootdir_partial=None,
all_deps=False,
):
cfg = bam_config.load(abort=True)
@@ -386,6 +391,9 @@ class bam_commands:
payload = {
"filepath": path,
"command": "checkout",
"arguments": json.dumps({
"all_deps": all_deps,
}),
}
import requests
@@ -657,24 +665,23 @@ class bam_commands:
# --------------
# Commit Request
args = {
'message': message,
}
payload = {
'command': 'commit',
'arguments': json.dumps(args),
"command": "commit",
"arguments": json.dumps({
'message': message,
}),
}
files = {
'file': open(temp_zip, 'rb'),
"file": open(temp_zip, 'rb'),
}
r = requests.put(
bam_session.request_url("file"),
params=payload,
auth=(cfg['user'], cfg['password']),
auth=(cfg["user"], cfg["password"]),
files=files)
files['file'].close()
files["file"].close()
os.remove(temp_zip)
try:
@@ -944,9 +951,13 @@ def create_argparse_checkout(subparsers):
"-o", "--output", dest="output", type=str, metavar='DIRNAME',
help="Local name to checkout the session into (optional, falls back to path name)",
)
subparse.add_argument(
"-a", "--all-deps", dest="all_deps", action='store_true',
help="Checkout all dependencies (unused indirect dependencies too)",
)
subparse.set_defaults(
func=lambda args:
bam_commands.checkout(args.path, args.output),
bam_commands.checkout(args.path, args.output, args.all_deps),
)

View File

@@ -94,6 +94,8 @@ def pack(
blendfile_src, blendfile_dst, mode='FILE',
paths_remap_relbase=None,
deps_remap=None, paths_remap=None, paths_uuid=None,
# load every libs dep, not just used deps.
all_deps=False,
# yield reports
report=None,
@@ -190,6 +192,7 @@ def pack(
readonly=False,
temp_remap_cb=temp_remap_cb,
recursive=True,
recursive_all=all_deps,
lib_visit=lib_visit,
):

View File

@@ -170,6 +170,9 @@ class FileAPI(Resource):
def get(self, project_name):
filepath = request.args['filepath']
command = request.args['command']
command_args = request.args.get('arguments')
if command_args is not None:
command_args = json.loads(command_args)
project = Project.query.filter_by(name=project_name).first()
@@ -210,7 +213,12 @@ class FileAPI(Resource):
os.close(filepath_zip[0])
filepath_zip = filepath_zip[1]
yield from self.pack_fn(filepath, filepath_zip, project.repository_path, report)
yield from self.pack_fn(
filepath, filepath_zip,
project.repository_path,
command_args['all_deps'],
report,
)
# TODO, handle fail
if not os.path.exists(filepath_zip):
@@ -340,7 +348,7 @@ class FileAPI(Resource):
return jsonify(message='File not allowed')
@staticmethod
def pack_fn(filepath, filepath_zip, paths_remap_relbase, report):
def pack_fn(filepath, filepath_zip, paths_remap_relbase, all_deps, report):
"""
'paths_remap_relbase' is the project path,
we want all paths to be relative to this so we don't get server path included.
@@ -367,6 +375,7 @@ class FileAPI(Resource):
paths_remap_relbase=paths_remap_relbase.encode('utf-8'),
# TODO(cam) this just means the json is written in the zip
deps_remap=deps_remap, paths_remap=paths_remap, paths_uuid=paths_uuid,
all_deps=all_deps,
report=report,
blendfile_src_dir_fakeroot=blendfile_src_dir_fakeroot.encode('utf-8'),
)