diff options
-rw-r--r-- | project.py | 6 | ||||
-rw-r--r-- | subcmds/sync.py | 18 |
2 files changed, 21 insertions, 3 deletions
@@ -1535,6 +1535,7 @@ class Project: | |||
1535 | syncbuf, | 1535 | syncbuf, |
1536 | force_sync=False, | 1536 | force_sync=False, |
1537 | force_checkout=False, | 1537 | force_checkout=False, |
1538 | force_rebase=False, | ||
1538 | submodules=False, | 1539 | submodules=False, |
1539 | errors=None, | 1540 | errors=None, |
1540 | verbose=False, | 1541 | verbose=False, |
@@ -1680,14 +1681,15 @@ class Project: | |||
1680 | if pub: | 1681 | if pub: |
1681 | not_merged = self._revlist(not_rev(revid), pub) | 1682 | not_merged = self._revlist(not_rev(revid), pub) |
1682 | if not_merged: | 1683 | if not_merged: |
1683 | if upstream_gain: | 1684 | if upstream_gain and not force_rebase: |
1684 | # The user has published this branch and some of those | 1685 | # The user has published this branch and some of those |
1685 | # commits are not yet merged upstream. We do not want | 1686 | # commits are not yet merged upstream. We do not want |
1686 | # to rewrite the published commits so we punt. | 1687 | # to rewrite the published commits so we punt. |
1687 | fail( | 1688 | fail( |
1688 | LocalSyncFail( | 1689 | LocalSyncFail( |
1689 | "branch %s is published (but not merged) and is " | 1690 | "branch %s is published (but not merged) and is " |
1690 | "now %d commits behind" | 1691 | "now %d commits behind. Fix this manually or rerun " |
1692 | "with the --rebase option to force a rebase." | ||
1691 | % (branch.name, len(upstream_gain)), | 1693 | % (branch.name, len(upstream_gain)), |
1692 | project=self.name, | 1694 | project=self.name, |
1693 | ) | 1695 | ) |
diff --git a/subcmds/sync.py b/subcmds/sync.py index 113e7a67..019ce3e0 100644 --- a/subcmds/sync.py +++ b/subcmds/sync.py | |||
@@ -401,6 +401,13 @@ later is required to fix a server side protocol bug. | |||
401 | "WARNING: this may cause loss of data", | 401 | "WARNING: this may cause loss of data", |
402 | ) | 402 | ) |
403 | p.add_option( | 403 | p.add_option( |
404 | "--rebase", | ||
405 | dest="rebase", | ||
406 | action="store_true", | ||
407 | help="rebase local commits regardless of whether they are " | ||
408 | "published", | ||
409 | ) | ||
410 | p.add_option( | ||
404 | "-l", | 411 | "-l", |
405 | "--local-only", | 412 | "--local-only", |
406 | dest="local_only", | 413 | dest="local_only", |
@@ -1009,7 +1016,13 @@ later is required to fix a server side protocol bug. | |||
1009 | return _FetchMainResult(all_projects) | 1016 | return _FetchMainResult(all_projects) |
1010 | 1017 | ||
1011 | def _CheckoutOne( | 1018 | def _CheckoutOne( |
1012 | self, detach_head, force_sync, force_checkout, verbose, project | 1019 | self, |
1020 | detach_head, | ||
1021 | force_sync, | ||
1022 | force_checkout, | ||
1023 | force_rebase, | ||
1024 | verbose, | ||
1025 | project, | ||
1013 | ): | 1026 | ): |
1014 | """Checkout work tree for one project | 1027 | """Checkout work tree for one project |
1015 | 1028 | ||
@@ -1019,6 +1032,7 @@ later is required to fix a server side protocol bug. | |||
1019 | existing git directory that was previously linked to a different | 1032 | existing git directory that was previously linked to a different |
1020 | object directory). | 1033 | object directory). |
1021 | force_checkout: Force checking out of the repo content. | 1034 | force_checkout: Force checking out of the repo content. |
1035 | force_rebase: Force rebase. | ||
1022 | verbose: Whether to show verbose messages. | 1036 | verbose: Whether to show verbose messages. |
1023 | project: Project object for the project to checkout. | 1037 | project: Project object for the project to checkout. |
1024 | 1038 | ||
@@ -1036,6 +1050,7 @@ later is required to fix a server side protocol bug. | |||
1036 | syncbuf, | 1050 | syncbuf, |
1037 | force_sync=force_sync, | 1051 | force_sync=force_sync, |
1038 | force_checkout=force_checkout, | 1052 | force_checkout=force_checkout, |
1053 | force_rebase=force_rebase, | ||
1039 | errors=errors, | 1054 | errors=errors, |
1040 | verbose=verbose, | 1055 | verbose=verbose, |
1041 | ) | 1056 | ) |
@@ -1109,6 +1124,7 @@ later is required to fix a server side protocol bug. | |||
1109 | opt.detach_head, | 1124 | opt.detach_head, |
1110 | opt.force_sync, | 1125 | opt.force_sync, |
1111 | opt.force_checkout, | 1126 | opt.force_checkout, |
1127 | opt.rebase, | ||
1112 | opt.verbose, | 1128 | opt.verbose, |
1113 | ), | 1129 | ), |
1114 | projects, | 1130 | projects, |