Skip to content

Commit d68bcab

Browse files
quark-zjufacebook-github-bot
authored andcommitted
commitcloud: use git push to upload commits on git repos
Summary: Right now the git repos do not support slapi upload. Therefore use `git push` instead. Reviewed By: zzl0 Differential Revision: D74679479 fbshipit-source-id: 8eda3fa0624e7089ca79ae31d867da969392a2bf
1 parent c8bbfd9 commit d68bcab

File tree

1 file changed

+20
-8
lines changed

1 file changed

+20
-8
lines changed

eden/scm/sapling/ext/commitcloud/upload.py

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# GNU General Public License version 2.
55

66

7-
from sapling import edenapi_upload, node as nodemod
7+
from sapling import edenapi_upload, git, node as nodemod
88
from sapling.i18n import _, _n
99

1010

@@ -78,14 +78,26 @@ def upload(repo, revs, force=False, localbackupstate=None):
7878
component="commitcloud",
7979
)
8080

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)))
8294

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+
)
89101

90102
# Uploaded heads are all heads that have been filtered or uploaded and also heads of the 'newuploaded' nodes.
91103

0 commit comments

Comments
 (0)