contrib/hammerclient.py
author Martin von Zweigbergk <martinvonz@google.com>
Thu, 26 Dec 2019 10:21:31 -0800
changeset 5229 d8ea3c829477
parent 4809 f97379faefa3
permissions -rwxr-xr-x
topic: make in-memory rebase preserve topic The override code thought that `__init__` would return the runtime instance, but it's actually the first argument to the function (the `self` argument), so the code had no effect at all before this patch. I think the bug only affected in-memory rebase because the in-working-copy rebase used the current topic, which was set correctly since 5156a67f66a6 (topics: update current topic to the topic of newly rebased commit (issue5551), 2017-06-29).

#!/usr/bin/env python
import os
import sys
import subprocess

if len(sys.argv) < 2:
    execname = os.path.basename(sys.argv[0])
    sys.stderr.write("usage: %s CLIENT_ID\n" % execname)

client_id = sys.argv[1]

subprocess.check_call(['hg', 'branch', "--force", "hammer-branch-%s" % client_id])

while True:
    subprocess.check_call([
        'hg', 'commit',
        "--config", "ui.allowemptycommit=yes",
        "--message", "hammer-%s" % client_id,
    ])
    nodeid = subprocess.check_output([
        'hg', 'log', '--rev', '.', '--template', '{node}'
    ])
    subprocess.check_call([
        'hg', 'debugobsolete', ''.join(reversed(nodeid)), nodeid
    ])
    subprocess.check_call(['hg', 'pull'])
    subprocess.check_call(['hg', 'push', '--force'])