Beispiel #1
0
def getqqueues(repo):
    ui = repo.ui.copy()
    ui.quiet = True  # don't append "(active)"
    ui.pushbuffer()
    try:
        opts = {'list': True}
        mqmod.qqueue(ui, repo, None, **opts)
        qqueues = tounicode(ui.popbuffer()).splitlines()
    except (util.Abort, EnvironmentError):
        qqueues = []
    return qqueues
Beispiel #2
0
def get_repo_revision():
    repo_path, repo_type = get_repo_root()
    if repo_type == 'hg':
        from mercurial import hg, ui, commands
        ui = ui.ui()
        repo = hg.repository(ui, repo_path)
        ui.pushbuffer()
        commands.identify(ui, repo, rev='.')
        return ui.popbuffer().split()[0]
    elif repo_type == 'git':
        import subprocess
        return subprocess.check_output(['git', 'rev-parse', 'HEAD']).strip()
Beispiel #3
0
def get_repo_revision():
    repo_path, repo_type = get_repo_root()
    if repo_type == 'hg':
        from mercurial import hg, ui, commands
        ui = ui.ui()
        repo = hg.repository(ui, repo_path)
        ui.pushbuffer()
        commands.identify(ui, repo, rev='.')
        return ui.popbuffer().split()[0]
    elif repo_type == 'git':
        import subprocess
        return subprocess.check_output(['git', 'rev-parse', 'HEAD']).strip()
def security_check(ui, repo, **kwargs):
    ui.debug('running security_check\n')
    error = False

    ui.pushbuffer()
    _quiet(
        ui, lambda: commands.log(ui,
                                 repo,
                                 rev=['%s:tip' % kwargs['node']],
                                 template='{node}\n',
                                 date=None,
                                 user=None,
                                 logfile=None))
    nodes = ui.popbuffer().split('\n')

    # reenable this code if we need to blacklist a node
    for node in nodes:
        if node.startswith('8555e8551203') or node.startswith('e09bb3ece6c7'):
            ui.warn('blacklisted changeid found: node %s is blacklisted\n' %
                    node)
            error = True  # fail the push

    # Look for blacklisted bugs
    blacklist = [
        # Serrano
        580489,
        604354,
        # Wasabi
        507624,
        # Cyril
        570049,
        628834,
    ]

    bugs = re.compile('(%s)' % '|'.join([str(bug) for bug in blacklist]))

    ui.pushbuffer()
    _quiet(
        ui, lambda: commands.log(ui,
                                 repo,
                                 rev=['%s:tip' % kwargs['node']],
                                 template='{desc}',
                                 date=None,
                                 user=None,
                                 logfile=None))
    descs = ui.popbuffer()

    searchDescs = bugs.search(descs)
    if searchDescs:
        ui.warn('blacklisted bug found: %s\n' % searchDescs.groups()[0])
        error = True

    return error
Beispiel #5
0
    def _reload(self):
        ui, repo = self.repo.ui.copy(), self.repo

        self.queueCombo.clear()

        ui.quiet = True  # don't append "(active)"
        ui.pushbuffer()
        mqmod.qqueue(ui, repo, list=True)
        out = ui.popbuffer()
        for i, qname in enumerate(out.splitlines()):
            if qname == repo.thgactivemqname:
                current = i
            self.queueCombo.addItem(hglib.tounicode(qname))
        self.queueCombo.setCurrentIndex(current)
        self.queueCombo.setEnabled(self.queueCombo.count() > 1)

        self.messages = []
        for patch in repo.mq.series:
            ctx = repo.changectx(patch)
            msg = hglib.tounicode(ctx.description())
            if msg:
                self.messages.append((patch, msg))
        self.msgSelectCombo.reset(self.messages)

        if os.path.isdir(repo.mq.join('.hg')):
            self.revisionOrCommitBtn.setText(_('QCommit'))
        else:
            self.revisionOrCommitBtn.setText(_('Create MQ repo'))

        pctx = repo.changectx('.')
        newmode = self.newCheckBox.isChecked()
        if 'qtip' in pctx.tags():
            self.stwidget.tv.setEnabled(True)
            self.messageEditor.setEnabled(True)
            self.msgSelectCombo.setEnabled(True)
            self.qnewOrRefreshBtn.setEnabled(True)
            if not newmode:
                self.setMessage(hglib.tounicode(pctx.description()))
                name = repo.mq.applied[-1].name
                self.patchNameLE.setText(hglib.tounicode(name))
        else:
            self.stwidget.tv.setEnabled(newmode)
            self.messageEditor.setEnabled(newmode)
            self.msgSelectCombo.setEnabled(newmode)
            self.qnewOrRefreshBtn.setEnabled(newmode)
            if not newmode:
                self.setMessage('')
                self.patchNameLE.setText('')
        self.patchNameLE.setEnabled(newmode)
Beispiel #6
0
def security_check(ui, repo, **kwargs):
    ui.debug("running security_check\n")
    error = False

    ui.pushbuffer()
    _quiet(
        ui,
        lambda: commands.log(
            ui, repo, rev=["%s:tip" % kwargs["node"]], template="{node}\n", date=None, user=None, logfile=None
        ),
    )
    nodes = ui.popbuffer().split("\n")

    # reenable this code if we need to blacklist a node
    for node in nodes:
        if node.startswith("8555e8551203") or node.startswith("e09bb3ece6c7"):
            ui.warn("blacklisted changeid found: node %s is blacklisted\n" % node)
            error = True  # fail the push

    # Look for blacklisted bugs
    blacklist = [
        # Serrano
        580489,
        604354,
        # Wasabi
        507624,
        # Cyril
        570049,
        628834,
    ]

    bugs = re.compile("(%s)" % "|".join([str(bug) for bug in blacklist]))

    ui.pushbuffer()
    _quiet(
        ui,
        lambda: commands.log(
            ui, repo, rev=["%s:tip" % kwargs["node"]], template="{desc}", date=None, user=None, logfile=None
        ),
    )
    descs = ui.popbuffer()

    searchDescs = bugs.search(descs)
    if searchDescs:
        ui.warn("blacklisted bug found: %s\n" % searchDescs.groups()[0])
        error = True

    return error
Beispiel #7
0
import os
from mercurial import hg, ui, commands


def get_repo_root():
    path = os.path.dirname(os.path.realpath(__file__))
    while os.path.exists(path):
        if '.hg' in os.listdir(path):
            return path
        path = os.path.realpath(os.path.join(path, '..'))
    raise RuntimeError('No .hg repository found!')


ui = ui.ui()
repo_path = get_repo_root()
repo = hg.repository(ui, repo_path)
ui.pushbuffer()
commands.identify(ui, repo, rev='.')
print ui.popbuffer().split()[0]