diff options
Diffstat (limited to 'subcmds/sync.py')
-rw-r--r-- | subcmds/sync.py | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/subcmds/sync.py b/subcmds/sync.py index c6682a5b..7acb6e5b 100644 --- a/subcmds/sync.py +++ b/subcmds/sync.py | |||
@@ -278,6 +278,11 @@ directories if they have previously been linked to a different | |||
278 | object directory. WARNING: This may cause data to be lost since | 278 | object directory. WARNING: This may cause data to be lost since |
279 | refs may be removed when overwriting. | 279 | refs may be removed when overwriting. |
280 | 280 | ||
281 | The --force-checkout option can be used to force git to switch revs even if the | ||
282 | index or the working tree differs from HEAD, and if there are untracked files. | ||
283 | WARNING: This may cause data to be lost since uncommitted changes may be | ||
284 | removed. | ||
285 | |||
281 | The --force-remove-dirty option can be used to remove previously used | 286 | The --force-remove-dirty option can be used to remove previously used |
282 | projects with uncommitted changes. WARNING: This may cause data to be | 287 | projects with uncommitted changes. WARNING: This may cause data to be |
283 | lost since uncommitted changes may be removed with projects that no longer | 288 | lost since uncommitted changes may be removed with projects that no longer |
@@ -376,6 +381,14 @@ later is required to fix a server side protocol bug. | |||
376 | "may cause loss of data", | 381 | "may cause loss of data", |
377 | ) | 382 | ) |
378 | p.add_option( | 383 | p.add_option( |
384 | "--force-checkout", | ||
385 | dest="force_checkout", | ||
386 | action="store_true", | ||
387 | help="force checkout even if it results in throwing away " | ||
388 | "uncommitted modifications. " | ||
389 | "WARNING: this may cause loss of data", | ||
390 | ) | ||
391 | p.add_option( | ||
379 | "--force-remove-dirty", | 392 | "--force-remove-dirty", |
380 | dest="force_remove_dirty", | 393 | dest="force_remove_dirty", |
381 | action="store_true", | 394 | action="store_true", |
@@ -991,12 +1004,17 @@ later is required to fix a server side protocol bug. | |||
991 | 1004 | ||
992 | return _FetchMainResult(all_projects) | 1005 | return _FetchMainResult(all_projects) |
993 | 1006 | ||
994 | def _CheckoutOne(self, detach_head, force_sync, verbose, project): | 1007 | def _CheckoutOne( |
1008 | self, detach_head, force_sync, force_checkout, verbose, project | ||
1009 | ): | ||
995 | """Checkout work tree for one project | 1010 | """Checkout work tree for one project |
996 | 1011 | ||
997 | Args: | 1012 | Args: |
998 | detach_head: Whether to leave a detached HEAD. | 1013 | detach_head: Whether to leave a detached HEAD. |
999 | force_sync: Force checking out of the repo. | 1014 | force_sync: Force checking out of .git directory (e.g. overwrite |
1015 | existing git directory that was previously linked to a different | ||
1016 | object directory). | ||
1017 | force_checkout: Force checking out of the repo content. | ||
1000 | verbose: Whether to show verbose messages. | 1018 | verbose: Whether to show verbose messages. |
1001 | project: Project object for the project to checkout. | 1019 | project: Project object for the project to checkout. |
1002 | 1020 | ||
@@ -1011,7 +1029,11 @@ later is required to fix a server side protocol bug. | |||
1011 | errors = [] | 1029 | errors = [] |
1012 | try: | 1030 | try: |
1013 | project.Sync_LocalHalf( | 1031 | project.Sync_LocalHalf( |
1014 | syncbuf, force_sync=force_sync, errors=errors, verbose=verbose | 1032 | syncbuf, |
1033 | force_sync=force_sync, | ||
1034 | force_checkout=force_checkout, | ||
1035 | errors=errors, | ||
1036 | verbose=verbose, | ||
1015 | ) | 1037 | ) |
1016 | success = syncbuf.Finish() | 1038 | success = syncbuf.Finish() |
1017 | except GitError as e: | 1039 | except GitError as e: |
@@ -1082,6 +1104,7 @@ later is required to fix a server side protocol bug. | |||
1082 | self._CheckoutOne, | 1104 | self._CheckoutOne, |
1083 | opt.detach_head, | 1105 | opt.detach_head, |
1084 | opt.force_sync, | 1106 | opt.force_sync, |
1107 | opt.force_checkout, | ||
1085 | opt.verbose, | 1108 | opt.verbose, |
1086 | ), | 1109 | ), |
1087 | projects, | 1110 | projects, |