mirror of
https://github.com/facebook/sapling.git
synced 2024-10-11 17:27:53 +03:00
81d738646f
Summary: Merge the functionality of the infinitepushbackup extension (backing up commits to commit cloud) into the commitcloud extension. These two extensions are highly coupled, and the commitcloud extension monkey-patches the infinitepushbackup extension for a lot of its functionality. There is also a lot of code duplication between the two extensions which we can remove if they are part of the same extension. The infinitepushbackup commands (`hg pushbackup`, ...) are moved to subcommands of the `hg cloud` command, e.g. `hg cloud backup`. Each feature of the infinitepushbackup extension is moved to a new module in the commit cloud extension: The `background` module controls background execution of `hg cloud backup` and `hg cloud sync`. The `backupbookmarks` module tracks and updates scratch bookmarks for backups. This will be deprecated in the future. The `backupstate` module tracks whether or not a commit has been backed up. This is now tracked separately from backup bookmarks in a new file: `.hg/commitcloud/backedupheads.<remote-identifier>`. This also covers hidden commits, preventing a re-backup of previously backed up commits when they are unhidden. Previously the commitcloud extension customized the smartlog annotations: `Backing up` became `Syncing`, etc. This is now removed for consistency. Previously the infinitepushbackup extension disabled background backup by injecting an `infinitepushbackup.disableduntil` config entry into the user's config. This is now replaced with a state file at `.hg/commitcloud/autobackup`. Either option can be set to disable auto backup. Commit cloud will wait until both have expired before starting to run background backups again. Reviewed By: DurhamG Differential Revision: D15276939 fbshipit-source-id: 1d28989a157286e47d3dd97ca9c70b27f692dda1
217 lines
6.0 KiB
Perl
217 lines
6.0 KiB
Perl
$ cat >> $HGRCPATH << EOF
|
|
> [extensions]
|
|
> amend =
|
|
> arcconfig=$TESTDIR/../edenscm/hgext/extlib/phabricator/arcconfig.py
|
|
> arcdiff=
|
|
> commitcloud =
|
|
> infinitepush =
|
|
> rebase =
|
|
> remotenames =
|
|
> share =
|
|
> [ui]
|
|
> ssh = python "$TESTDIR/dummyssh"
|
|
> [infinitepush]
|
|
> branchpattern = re:scratch/.*
|
|
> [commitcloud]
|
|
> hostname = testhost
|
|
> [alias]
|
|
> trglog = log -G --template "{node|short} '{desc}' {bookmarks} {remotenames}\n"
|
|
> descr = log -r '.' --template "{desc}"
|
|
> [experimental]
|
|
> evolution = createmarkers, allowunstable
|
|
> EOF
|
|
|
|
$ setconfig remotefilelog.reponame=server
|
|
|
|
$ mkcommit() {
|
|
> echo "$1" > "$1"
|
|
> hg commit -Aqm "$1"
|
|
> }
|
|
|
|
$ hg init server
|
|
$ cd server
|
|
$ cat >> .hg/hgrc << EOF
|
|
> [infinitepush]
|
|
> server = yes
|
|
> indextype = disk
|
|
> storetype = disk
|
|
> reponame = testrepo
|
|
> EOF
|
|
|
|
$ mkcommit "base"
|
|
$ cd ..
|
|
|
|
Make shared part of config
|
|
$ cat >> shared.rc << EOF
|
|
> [commitcloud]
|
|
> servicetype = local
|
|
> servicelocation = $TESTTMP
|
|
> user_token_path = $TESTTMP
|
|
> owner_team = The Test Team @ FB
|
|
> EOF
|
|
|
|
Make the first clone of the server
|
|
$ hg clone ssh://user@dummy/server client1 -q
|
|
$ cd client1
|
|
$ cat ../shared.rc >> .hg/hgrc
|
|
$ hg cloud auth -t xxxxxx -q
|
|
$ hg cloud join -q
|
|
|
|
$ cd ..
|
|
|
|
Make the second clone of the server
|
|
$ hg clone ssh://user@dummy/server client2 -q
|
|
$ cd client2
|
|
$ cat ../shared.rc >> .hg/hgrc
|
|
$ hg cloud auth -q
|
|
$ hg cloud join -q
|
|
|
|
$ cd ..
|
|
|
|
Make the third clone of the server
|
|
$ hg clone ssh://user@dummy/server client3 -q
|
|
$ cd client3
|
|
$ cat ../shared.rc >> .hg/hgrc
|
|
$ hg cloud auth -q
|
|
$ hg cloud join -q
|
|
|
|
$ cd ..
|
|
|
|
Test for `hg diff --since-last-submit`
|
|
|
|
$ cd client1
|
|
$ echo '{}' > .arcrc
|
|
$ echo '{"config" : {"default" : "https://a.com/api"}, "hosts" : {"https://a.com/api/" : { "user" : "testuser", "cert" : "garbage_cert"}}}' > .arcconfig
|
|
|
|
$ cd ..
|
|
|
|
$ cd client2
|
|
$ echo '{}' > .arcrc
|
|
$ echo '{"config" : {"default" : "https://a.com/api"}, "hosts" : {"https://a.com/api/" : { "user" : "testuser", "cert" : "garbage_cert"}}}' > .arcconfig
|
|
|
|
$ cd ..
|
|
|
|
$ cd client3
|
|
$ echo '{}' > .arcrc
|
|
$ echo '{"config" : {"default" : "https://a.com/api"}, "hosts" : {"https://a.com/api/" : { "user" : "testuser", "cert" : "garbage_cert"}}}' > .arcconfig
|
|
|
|
$ cd ..
|
|
|
|
$ cd client1
|
|
|
|
$ echo "Hello feature2" > feature2.body.txt
|
|
$ hg add feature2.body.txt
|
|
|
|
$ hg ci -Aqm 'Differential Revision: https://phabricator.fb.com/D1'
|
|
$ hg log -r '.' -T '{node}'
|
|
a8080066a666ffa51c0a171e87d5a0396ecb559a (no-eol)
|
|
$ hg cloud sync
|
|
commitcloud: synchronizing 'server' with 'user/test/default'
|
|
backing up stack rooted at a8080066a666
|
|
remote: pushing 1 commit:
|
|
remote: a8080066a666 Differential Revision: https://phabricator.fb.com/
|
|
commitcloud: commits synchronized
|
|
finished in * (glob)
|
|
|
|
$ cat > $TESTTMP/mockduit << EOF
|
|
> [{"data": {"query": [{"results": {"nodes": [{
|
|
> "number": 1,
|
|
> "diff_status_name": "Needs Review",
|
|
> "latest_active_diff": {
|
|
> "local_commit_info": {
|
|
> "nodes": [
|
|
> {"property_value": "{\"lolwut\": {\"time\": 0, \"commit\": \"a8080066a666ffa51c0a171e87d5a0396ecb559a\"}}"}
|
|
> ]
|
|
> }
|
|
> },
|
|
> "differential_diffs": {"count": 1},
|
|
> "is_landing": false,
|
|
> "created_time": 123,
|
|
> "updated_time": 222
|
|
> }]}}]}}]
|
|
> EOF
|
|
|
|
$ echo "Hello feature2 update" > feature2.body.txt
|
|
$ hg amend
|
|
|
|
$ hg cloud sync
|
|
commitcloud: synchronizing 'server' with 'user/test/default'
|
|
backing up stack rooted at 95847be64d6a
|
|
remote: pushing 1 commit:
|
|
remote: 95847be64d6a Differential Revision: https://phabricator.fb.com/
|
|
commitcloud: commits synchronized
|
|
finished in * (glob)
|
|
|
|
$ cd ..
|
|
|
|
$ cd client2
|
|
|
|
$ hg cloud sync
|
|
commitcloud: synchronizing 'server' with 'user/test/default'
|
|
pulling from ssh://user@dummy/server
|
|
searching for changes
|
|
adding changesets
|
|
adding manifests
|
|
adding file changes
|
|
added 1 changesets with 3 changes to 3 files
|
|
new changesets 95847be64d6a
|
|
(run 'hg update' to get a working copy)
|
|
commitcloud: commits synchronized
|
|
finished in * (glob)
|
|
|
|
$ hg up 95847be64d6a
|
|
3 files updated, 0 files merged, 0 files removed, 0 files unresolved
|
|
|
|
$ HG_ARC_CONDUIT_MOCK=$TESTTMP/mockduit hg diff --since-last-submit --config extensions.commitcloud=!
|
|
abort: unknown revision 'a8080066a666ffa51c0a171e87d5a0396ecb559a'!
|
|
[255]
|
|
|
|
$ HG_ARC_CONDUIT_MOCK=$TESTTMP/mockduit hg diff --since-last-submit
|
|
pulling from ssh://user@dummy/server
|
|
searching for changes
|
|
adding changesets
|
|
adding manifests
|
|
adding file changes
|
|
added 1 changesets with 1 changes to 3 files (+1 heads)
|
|
(run 'hg heads' to see heads, 'hg merge' to merge)
|
|
diff -r a8080066a666 -r 95847be64d6a feature2.body.txt
|
|
--- a/feature2.body.txt Thu Jan 01 00:00:00 1970 +0000
|
|
+++ b/feature2.body.txt Thu Jan 01 00:00:00 1970 +0000
|
|
@@ -1,1 +1,1 @@
|
|
-Hello feature2
|
|
+Hello feature2 update
|
|
|
|
$ cd ..
|
|
|
|
$ cd client3
|
|
|
|
$ hg cloud sync
|
|
commitcloud: synchronizing 'server' with 'user/test/default'
|
|
pulling from ssh://user@dummy/server
|
|
searching for changes
|
|
adding changesets
|
|
adding manifests
|
|
adding file changes
|
|
added 1 changesets with 3 changes to 3 files
|
|
new changesets 95847be64d6a
|
|
(run 'hg update' to get a working copy)
|
|
commitcloud: commits synchronized
|
|
finished in * (glob)
|
|
|
|
$ hg up 95847be64d6a
|
|
3 files updated, 0 files merged, 0 files removed, 0 files unresolved
|
|
|
|
$ HG_ARC_CONDUIT_MOCK=$TESTTMP/mockduit hg log -r 'lastsubmitted(.)' -T '{node} {desc}' --config extensions.commitcloud=!
|
|
abort: unknown revision 'a8080066a666ffa51c0a171e87d5a0396ecb559a'!
|
|
[255]
|
|
|
|
$ HG_ARC_CONDUIT_MOCK=$TESTTMP/mockduit hg log -r 'lastsubmitted(.)' -T '{node} {desc}'
|
|
pulling from ssh://user@dummy/server
|
|
searching for changes
|
|
adding changesets
|
|
adding manifests
|
|
adding file changes
|
|
added 1 changesets with 1 changes to 3 files (+1 heads)
|
|
(run 'hg heads' to see heads, 'hg merge' to merge)
|
|
a8080066a666ffa51c0a171e87d5a0396ecb559a Differential Revision: https://phabricator.fb.com/D1 (no-eol)
|