예제 #1
0
def initcommand(orig, ui, dest, **opts):
    with ui.kafkainteraction():
        # Send a heartbeat before we create the repo to ensure the replication
        # system is online. This helps guard against us creating the repo
        # and replication being offline.
        producer = ui.replicationproducer
        # TODO this should ideally go to same partition as replication event.
        for partition in sorted(ui.replicationpartitions):
            vcsrproducer.send_heartbeat(producer, partition=partition)
            break

        res = orig(ui, dest=dest, **opts)

        # init aborts if the repo already existed or in case of error. So we
        # can only get here if we created a repo.
        path = os.path.normpath(os.path.abspath(os.path.expanduser(dest)))
        if not os.path.exists(path):
            raise util.Abort('could not find created repo at %s' % path)

        repo = hg.repository(ui, path)
        gd = 'generaldelta' in repo.requirements

        # TODO we should delete the repo if we can't write this message.
        vcsrproducer.record_new_hg_repo(producer,
                                        repo.replicationwireprotopath,
                                        partition=repo.replicationpartition,
                                        generaldelta=gd)
        ui.status(_('(recorded repository creation in replication log)\n'))

        return res
예제 #2
0
def initcommand(orig, ui, dest, **opts):
    with ui.kafkainteraction():
        # Send a heartbeat before we create the repo to ensure the replication
        # system is online. This helps guard against us creating the repo
        # and replication being offline.
        producer = ui.replicationproducer
        # TODO this should ideally go to same partition as replication event.
        for partition in sorted(ui.replicationpartitions):
            vcsrproducer.send_heartbeat(producer, partition=partition)
            break

        res = orig(ui, dest=dest, **opts)

        # init aborts if the repo already existed or in case of error. So we
        # can only get here if we created a repo.
        path = os.path.normpath(os.path.abspath(os.path.expanduser(dest)))
        if not os.path.exists(path):
            raise util.Abort('could not find created repo at %s' % path)

        repo = hg.repository(ui, path)
        gd = 'generaldelta' in repo.requirements

        # TODO we should delete the repo if we can't write this message.
        vcsrproducer.record_new_hg_repo(producer, repo.replicationwireprotopath,
                                        partition=repo.replicationpartition,
                                        generaldelta=gd)
        ui.status(_('(recorded repository creation in replication log)\n'))

        return res