|
7 | 7 | pip puts these tools). |
8 | 8 | """ |
9 | 9 |
|
| 10 | +import json |
10 | 11 | import os |
11 | 12 | import sys |
12 | 13 | import traceback |
|
15 | 16 | from mergin import ( |
16 | 17 | ClientError, |
17 | 18 | MerginClient, |
| 19 | + MerginProject, |
18 | 20 | InvalidProject, |
19 | 21 | LoginError, |
20 | 22 | ) |
@@ -292,6 +294,69 @@ def pull(): |
292 | 294 | _print_unhandled_exception() |
293 | 295 |
|
294 | 296 |
|
| 297 | +@cli.command() |
| 298 | +@click.argument('version') |
| 299 | +def show_version(version): |
| 300 | + """ Displays information about a single version of a project """ |
| 301 | + |
| 302 | + c = _init_client() |
| 303 | + if c is None: |
| 304 | + return |
| 305 | + directory = os.getcwd() |
| 306 | + |
| 307 | + mp = MerginProject(directory) |
| 308 | + project_path = mp.metadata["name"] |
| 309 | + |
| 310 | + version_info_dict = c.project_version_info(project_path, version)[0] |
| 311 | + print("Project: " + version_info_dict['project']['namespace'] + "/" + version_info_dict['project']['name']) |
| 312 | + print("Version: " + version_info_dict['name'] + " by " + version_info_dict['author']) |
| 313 | + print("Time: " + version_info_dict['created']) |
| 314 | + pretty_diff(version_info_dict['changes']) |
| 315 | + |
| 316 | + |
| 317 | +@cli.command() |
| 318 | +@click.argument('path') |
| 319 | +def show_file_history(path): |
| 320 | + """ Displays information about a single version of a project """ |
| 321 | + |
| 322 | + c = _init_client() |
| 323 | + if c is None: |
| 324 | + return |
| 325 | + directory = os.getcwd() |
| 326 | + |
| 327 | + mp = MerginProject(directory) |
| 328 | + project_path = mp.metadata["name"] |
| 329 | + |
| 330 | + info_dict = c.project_file_history_info(project_path, path) |
| 331 | + history_dict = info_dict['history'] |
| 332 | + |
| 333 | + print("File history: " + info_dict['path']) |
| 334 | + print("-----") |
| 335 | + for version, version_data in history_dict.items(): |
| 336 | + diff_info = '' |
| 337 | + if 'diff' in version_data: |
| 338 | + diff_info = "diff ({} bytes)".format(version_data['diff']['size']) |
| 339 | + print(" {:5} {:10} {}".format(version, version_data['change'], diff_info)) |
| 340 | + |
| 341 | + |
| 342 | +@cli.command() |
| 343 | +@click.argument('path') |
| 344 | +@click.argument('version') |
| 345 | +def show_file_changeset(path, version): |
| 346 | + """ Displays information about a single version of a project """ |
| 347 | + |
| 348 | + c = _init_client() |
| 349 | + if c is None: |
| 350 | + return |
| 351 | + directory = os.getcwd() |
| 352 | + |
| 353 | + mp = MerginProject(directory) |
| 354 | + project_path = mp.metadata["name"] |
| 355 | + |
| 356 | + info_dict = c.project_file_changeset_info(project_path, path, version) |
| 357 | + print(json.dumps(info_dict, indent=2)) |
| 358 | + |
| 359 | + |
295 | 360 | @cli.command() |
296 | 361 | @click.argument('directory', required=False) |
297 | 362 | def modtime(directory): |
|
0 commit comments