mirror of
https://github.com/facebook/sapling.git
synced 2024-10-07 07:17:55 +03:00
infinitepush: don't push empty backups in new clones
Summary: If the infinitepush backup state is empty (indicating this is probably a new clone of a repository), and there are no commits or bookmarks to be backed up, don't push a backupbundle that clears all the heads and bookmarks of any backups that have the same servername and path. This might be a reclone of the repository, and the user might want to restore the backup. When the first commit or bookmark is made in the new repository, the old backup will be cleared at that point. Differential Revision: D7669728 fbshipit-source-id: bec859bbbbee6b631efb4483a8fedbad8f3bcbac
This commit is contained in:
parent
9e4122b90d
commit
1a9ca888a8
@ -600,9 +600,14 @@ def _dobackup(ui, repo, dest, **opts):
|
||||
repo, newbookmarks, removedbookmarks,
|
||||
newheads, removedheads, namingmgr)
|
||||
|
||||
# Special case if backup state is empty. Clean all backup bookmarks from the
|
||||
# server.
|
||||
# Special cases if backup state is empty.
|
||||
if bkpstate.empty():
|
||||
# If there is nothing to backup, exit now to prevent accidentally
|
||||
# clearing a previous backup.
|
||||
if not afterbackuplocalbooks and not afterbackupheads:
|
||||
ui.status(_('nothing to backup\n'))
|
||||
return
|
||||
# Otherwise, clean all backup bookmarks from the server.
|
||||
bookmarkstobackup[namingmgr.getbackupheadprefix()] = ''
|
||||
bookmarkstobackup[namingmgr.getbackupbookmarkprefix()] = ''
|
||||
|
||||
|
@ -26,7 +26,7 @@ Backup empty repo
|
||||
$ setup
|
||||
$ hg pushbackup
|
||||
starting backup .* (re)
|
||||
finished in \d+\.(\d+)? seconds (re)
|
||||
nothing to backup
|
||||
$ mkcommit commit
|
||||
$ hg prune .
|
||||
0 files updated, 0 files merged, 1 files removed, 0 files unresolved
|
||||
@ -51,6 +51,13 @@ Re-clone the client
|
||||
Setup client
|
||||
$ setup
|
||||
|
||||
Pushing in this new, empty clone shouldn't clear the old backup
|
||||
$ hg pushbackup
|
||||
starting backup .* (re)
|
||||
nothing to backup
|
||||
$ scratchbookmarks
|
||||
infinitepush/backups/test/[0-9a-zA-Z.-]+\$TESTTMP/client/heads/606a357e69adb2e36d559ae3237626e82a955c9d 606a357e69adb2e36d559ae3237626e82a955c9d (re)
|
||||
|
||||
Make commit and backup it. Use lockfail.py to make sure lock is not taken during
|
||||
pushbackup
|
||||
$ mkcommit commit
|
||||
|
Loading…
Reference in New Issue
Block a user