sapling/tests/test-commitcloud-backup-share.t
Mark Thomas 81d738646f commitcloud: incorporate infinitepush backups into commitcloud
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
2019-05-20 06:19:47 -07:00

55 lines
1.8 KiB
Perl

$ enable share
$ . "$TESTDIR/library.sh"
$ . "$TESTDIR/infinitepush/library.sh"
$ setupcommon
$ mkcommit() {
> echo "$1" > "$1"
> hg add "$1"
> hg ci -m "$1"
> }
$ hg init repo
$ cd repo
$ setupserver
$ cd ..
Clone client
$ hg clone ssh://user@dummy/repo client -q
$ hg share --bookmarks client client2
updating working directory
0 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ cd client2
$ mkcommit first
$ hg paths
default = ssh://user@dummy/repo
Write smth to backup state file in the shared working copy to check that
it's not read by infinitepush backup client
$ mkdir .hg/infinitepushbackups
$ echo 'rubbish' > .hg/infinitepushbackups/infinitepushbackupstate_f6bce706
$ hg cloud backup
backing up stack rooted at b75a450e74d5
remote: pushing 1 commit:
remote: b75a450e74d5 first
commitcloud: backed up 1 commit
$ scratchbookmarks
infinitepush/backups/test/*$TESTTMP/client/heads/b75a450e74d5a7708da8c3144fbeb4ac88694044 b75a450e74d5a7708da8c3144fbeb4ac88694044 (glob)
Make sure that backup state is saved only on the "main" repo
$ cat .hg/infinitepushbackups/infinitepushbackupstate_f6bce706
rubbish
$ [ -f ../client/.hg/infinitepushbackups/infinitepushbackupstate_f6bce706 ]
Make sure that cloud check references the main repo
$ hg cloud check -r :
b75a450e74d5a7708da8c3144fbeb4ac88694044 backed up
$ hg log -T '{rev}:{node} "{desc}"\n' -r 'notbackedup()'
Make another commit that is not backed up and check that too
$ mkcommit second
$ hg cloud check -r :
b75a450e74d5a7708da8c3144fbeb4ac88694044 backed up
bc64f6a267a06b03e9e0f96a6deae37ae89a832e not backed up
$ hg log -T '{rev}:{node} "{desc}"\n' -r 'notbackedup()'
1:bc64f6a267a06b03e9e0f96a6deae37ae89a832e "second"