infinitepush: log pushes to Scuba

Summary:
This will allow us to efficiently identify scratch pushes that are not properly being pushed to both Mercurial and Mononoke.

When we roll out `infinitepush-other`, this will be helpful to make sure all repositories are properly configured to push to both destinations.

Reviewed By: farnz

Differential Revision: D15577201

fbshipit-source-id: 17912b90a934f65ed21851170402ae498b127c14
This commit is contained in:
Thomas Orozco 2019-06-03 05:23:36 -07:00 committed by Facebook Github Bot
parent d6c8fef226
commit 4a77a90d3c

View File

@ -210,39 +210,50 @@ def _push(orig, ui, repo, dest=None, *args, **opts):
_("default repository not configured!"),
hint=_("see 'hg help config.paths'"),
)
dest = path.pushloc or path.loc
if dest.startswith("svn+") and scratchpush:
realdest = path.pushloc or path.loc
if realdest.startswith("svn+") and scratchpush:
raise error.Abort(
"infinite push does not work with svn repo",
hint="did you forget to `hg push default`?",
)
otherdest = otherpath and (otherpath.pushloc or otherpath.loc)
if scratchpush:
ui.log(
"infinitepush_destinations",
dest=dest,
real_dest=realdest,
other_dest=otherdest,
bookmark=bookmark,
)
# Remote scratch bookmarks will be deleted because remotenames doesn't
# know about them. Let's save it before push and restore after
remotescratchbookmarks = bookmarks.readremotebookmarks(ui, repo, dest)
result = orig(ui, repo, dest, *args, **opts)
remotescratchbookmarks = bookmarks.readremotebookmarks(ui, repo, realdest)
result = orig(ui, repo, realdest, *args, **opts)
# If an alternate Infinitepush destination is specified, replicate the
# push there. This ensures scratch bookmarks (and their commits) can
# properly be replicated to Mononoke.
if otherpath is not None:
otherdest = otherpath.pushloc or otherpath.loc
if otherdest != dest:
m = _(
"please wait while we replicate this push to an alternate repository\n"
)
ui.warn(m)
# NOTE: We ignore the result here (which only represents whether
# there were changes to land).
orig(ui, repo, otherdest, *args, **opts)
if otherdest is not None and otherdest != realdest:
m = _(
"please wait while we replicate this push to an alternate repository\n"
)
ui.warn(m)
# NOTE: We ignore the result here (which only represents whether
# there were changes to land).
orig(ui, repo, otherdest, *args, **opts)
if bookmarks.remotebookmarksenabled(ui):
if bookmark and scratchpush:
other = hg.peer(repo, opts, dest)
other = hg.peer(repo, opts, realdest)
fetchedbookmarks = other.listkeyspatterns(
"bookmarks", patterns=[bookmark]
)
remotescratchbookmarks.update(fetchedbookmarks)
bookmarks.saveremotebookmarks(repo, remotescratchbookmarks, dest)
bookmarks.saveremotebookmarks(repo, remotescratchbookmarks, realdest)
if oldphasemove:
exchange._localphasemove = oldphasemove
return result