mirror of
https://github.com/facebook/sapling.git
synced 2024-10-12 17:58:27 +03:00
a2131ea555
Summary: In the automigrate step at the start of pull, perform automigrations for mutation and visibility. If `mutation.automigrate` is set to true, then backfill obsmarkers into the mutation store. This step can take a couple of seconds for large obsstores, so print a message. If `visibility.automigrate` is set to `"start"`, switch to explicit visibility tracking. If it is set to `"stop"`, switch back to obsmarker-based tracking. Reviewed By: mitrandir77 Differential Revision: D15046139 fbshipit-source-id: 284268d42b52c6b296c5c1b73db7bc218ae29a0a
89 lines
2.9 KiB
Python
89 lines
2.9 KiB
Python
# debugmutation.py - command processing for debug commands for mutation and visbility
|
|
#
|
|
# Copyright 2019 Facebook, Inc.
|
|
#
|
|
# This software may be used and distributed according to the terms of the
|
|
# GNU General Public License version 2 or any later version.
|
|
|
|
from __future__ import absolute_import
|
|
|
|
from .. import mutation, node as nodemod, pycompat, registrar, scmutil, util, visibility
|
|
from ..i18n import _
|
|
|
|
|
|
command = registrar.command()
|
|
|
|
|
|
@command(b"debugmutation", [], _("[REV]"))
|
|
def debugmutation(ui, repo, *revs, **opts):
|
|
"""display the mutation history of a commit"""
|
|
repo = repo.unfiltered()
|
|
opts = pycompat.byteskwargs(opts)
|
|
for rev in scmutil.revrange(repo, revs):
|
|
ctx = repo[rev]
|
|
nodestack = [[ctx.node()]]
|
|
while nodestack:
|
|
node = nodestack[-1].pop()
|
|
ui.status(("%s%s") % (" " * len(nodestack), nodemod.hex(node)))
|
|
entry = mutation.lookup(repo, node)
|
|
if entry is not None:
|
|
preds = entry.preds()
|
|
mutop = entry.op()
|
|
mutuser = entry.user()
|
|
mutdate = util.shortdatetime((entry.time(), entry.tz()))
|
|
mutsplit = entry.split() or None
|
|
origin = entry.origin()
|
|
origin = {
|
|
None: "",
|
|
mutation.ORIGIN_LOCAL: "",
|
|
mutation.ORIGIN_COMMIT: " (from remote commit)",
|
|
mutation.ORIGIN_OBSMARKER: " (from obsmarker)",
|
|
mutation.ORIGIN_SYNTHETIC: " (synthetic)",
|
|
}.get(origin, " (unknown origin %s)" % origin)
|
|
extra = ""
|
|
if mutsplit is not None:
|
|
extra += " (split into this and: %s)" % ", ".join(
|
|
[nodemod.hex(n) for n in mutsplit]
|
|
)
|
|
ui.status(
|
|
(" %s by %s at %s%s%s from:")
|
|
% (mutop, mutuser, mutdate, extra, origin)
|
|
)
|
|
nodestack.append(list(reversed(preds)))
|
|
ui.status(("\n"))
|
|
while nodestack and not nodestack[-1]:
|
|
nodestack.pop()
|
|
return 0
|
|
|
|
|
|
@command(b"debugmutationfromobsmarkers", [])
|
|
def debugmutationfromobsmarkers(ui, repo, **opts):
|
|
"""convert obsolescence markers to mutation records"""
|
|
entries, commits, written = mutation.convertfromobsmarkers(repo)
|
|
repo.ui.write(
|
|
_("wrote %s of %s entries for %s commits\n") % (written, entries, commits)
|
|
)
|
|
return 0
|
|
|
|
|
|
@command("debugvisibility", [], subonly=True)
|
|
def debugvisibility(ui, repo):
|
|
"""control visibility tracking"""
|
|
|
|
|
|
subcmd = debugvisibility.subcommand()
|
|
|
|
|
|
@subcmd("start", [])
|
|
def debugvisibilitystart(ui, repo):
|
|
"""start tracking commit visibility explicitly"""
|
|
visibility.starttracking(repo)
|
|
return 0
|
|
|
|
|
|
@subcmd("stop", [])
|
|
def debugvisibilitystop(ui, repo):
|
|
"""stop tracking commit visibility explicitly"""
|
|
visibility.stoptracking(repo)
|
|
return 0
|