Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Detect Schema for different type of Project to Sync #280

Merged
merged 16 commits into from
Feb 10, 2020
1 change: 1 addition & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Added
+++++

- Added Windows to platforms tested with continuous integration (#264, #266).
- Add command line option ``-m/--merge`` for ``signac sync`` (#280, #230).

Changed
+++++++
Expand Down
21 changes: 16 additions & 5 deletions signac/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ def _sig(st):
exclude=args.exclude,
doc_sync=doc_sync,
selection=selection,
check_schema=not args.force,
check_schema=not (args.merge or args.force),
dry_run=args.dry_run,
parallel=args.parallel,
deep=args.deep,
Expand All @@ -537,17 +537,24 @@ def _sig(st):
print(MSG_SYNC_STATS.format(stats=stats))
except SchemaSyncConflict as error:
_print_err(
"WARNING: The detected schemas of the two projects differ! "
"Use --force to ignore.")
only_in_src = error.schema_src.difference(error.schema_dst)
"Synchronizing two projects with different schema requires the -m/--merge option.")
diff_src = error.schema_src.difference(error.schema_dst)
diff_dst = error.schema_dst.difference(error.schema_src)
only_in_dst = diff_dst.difference(diff_src)
only_in_src = diff_src.difference(diff_src)
diff_value = diff_src.intersection(diff_dst)
if only_in_src:
keys_formatted = ('.'.join(k) for k in only_in_src)
_print_err("Keys found only in the source schema: {}".format(', '.join(keys_formatted)))
only_in_dst = error.schema_dst.difference(error.schema_src)
if only_in_dst:
keys_formatted = ('.'.join(k) for k in only_in_dst)
_print_err(
"Keys found only in the destination schema: {}".format(', '.join(keys_formatted)))
if diff_value:
keys_formatted = ('.'.join(k) for k in diff_value)
_print_err(
"Keys having different values in source and destination: {}"
.format(', '.join(keys_formatted)))
except DocumentSyncConflict as error:
_print_err(MSG_SYNC_SPECIFY_KEY.format(keys=', '.join(error.keys)))
except FileSyncConflict as error:
Expand Down Expand Up @@ -1581,6 +1588,10 @@ def main():
'--force',
action='store_true',
help="Ignore all warnings, just synchronize.")
parser_sync.add_argument(
'-m', '--merge',
action='store_true',
help="Clone all the jobs that are not present in destination from source.")
parser_sync.add_argument(
'--parallel',
type=int,
Expand Down