|
4 | 4 | # GNU General Public License version 2.
|
5 | 5 |
|
6 | 6 |
|
7 |
| -from sapling import edenapi_upload, node as nodemod |
| 7 | +from sapling import edenapi_upload, git, node as nodemod |
8 | 8 | from sapling.i18n import _, _n
|
9 | 9 |
|
10 | 10 |
|
@@ -78,14 +78,26 @@ def upload(repo, revs, force=False, localbackupstate=None):
|
78 | 78 | component="commitcloud",
|
79 | 79 | )
|
80 | 80 |
|
81 |
| - draftnodes = list(repo.dageval(lambda: draft() & ancestors(missingheads))) |
| 81 | + if git.isgitformat(repo): |
| 82 | + # Use `git push` to upload the commits. |
| 83 | + pairs = [ |
| 84 | + (h, f"refs/commitcloud/upload{i}") |
| 85 | + for i, h in enumerate(sorted(missingheads)) |
| 86 | + ] |
| 87 | + ret = git.push(repo, "default", pairs) |
| 88 | + if ret == 0: |
| 89 | + newuploaded, failednodes = missingheads, [] |
| 90 | + else: |
| 91 | + newuploaded, failednodes = [], missingheads |
| 92 | + else: |
| 93 | + draftnodes = list(repo.dageval(lambda: draft() & ancestors(missingheads))) |
82 | 94 |
|
83 |
| - # If the only draft nodes are the missing heads then we can skip the |
84 |
| - # known checks, as we know they are all missing. |
85 |
| - skipknowncheck = len(draftnodes) == len(missingheads) |
86 |
| - newuploaded, failednodes = edenapi_upload.uploadhgchangesets( |
87 |
| - repo, draftnodes, force, skipknowncheck |
88 |
| - ) |
| 95 | + # If the only draft nodes are the missing heads then we can skip the |
| 96 | + # known checks, as we know they are all missing. |
| 97 | + skipknowncheck = len(draftnodes) == len(missingheads) |
| 98 | + newuploaded, failednodes = edenapi_upload.uploadhgchangesets( |
| 99 | + repo, draftnodes, force, skipknowncheck |
| 100 | + ) |
89 | 101 |
|
90 | 102 | # Uploaded heads are all heads that have been filtered or uploaded and also heads of the 'newuploaded' nodes.
|
91 | 103 |
|
|
0 commit comments