diff mercurial/debugcommands.py @ 51398:e2dfa403452d

debug: add a debug::unbundle command that simulate the unbundle from a push The code have different behavior when the unbundle comes from a push, so we introduce a command that can simulate such unbundle. For our copy of mozilla-try-2023-03-22, this make the unbundle jump from 2.5 seconds (with `hg unbundle`) to 15 seconds (with `hg debug::unbundle`). That 15 seconds timings is consistent with the issue seen in production.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Fri, 23 Feb 2024 04:26:03 +0100
parents 39f349391898
children 15e680a44502
line wrap: on
line diff
--- a/mercurial/debugcommands.py	Wed Feb 14 08:14:46 2024 +0100
+++ b/mercurial/debugcommands.py	Fri Feb 23 04:26:03 2024 +0100
@@ -4077,6 +4077,30 @@
 
 
 @command(
+    b'debug::unbundle',
+    [
+        (
+            b'u',
+            b'update',
+            None,
+            _(b'update to new branch head if changesets were unbundled'),
+        )
+    ],
+    _(b'[-u] FILE...'),
+    helpcategory=command.CATEGORY_IMPORT_EXPORT,
+)
+def debugunbundle(ui, repo, *args, **kwargs):
+    """same as `hg unbundle`, but pretent to come from a push
+
+    This is useful to debug behavior and performance change in this case.
+    """
+    from . import commands  # avoid cycle
+
+    unbundle = cmdutil.findcmd(b'unbundle', commands.table)[1][0]
+    return unbundle(ui, repo, *args, _unbundle_source=b'push', **kwargs)
+
+
+@command(
     b'debugwalk', cmdutil.walkopts, _(b'[OPTION]... [FILE]...'), inferrepo=True
 )
 def debugwalk(ui, repo, *pats, **opts):