Esempio n. 1
0
def openrevlog(repo, cmd, file_, opts):
    """opens the changelog, manifest, a filelog or a given revlog"""
    cl = opts['changelog']
    mf = opts['manifest']
    msg = None
    if cl and mf:
        msg = _('cannot specify --changelog and --manifest at the same time')
    elif cl or mf:
        if file_:
            msg = _('cannot specify filename with --changelog or --manifest')
        elif not repo:
            msg = _('cannot specify --changelog or --manifest '
                    'without a repository')
    if msg:
        raise util.Abort(msg)

    r = None
    if repo:
        if cl:
            r = repo.changelog
        elif mf:
            r = repo.manifest
        elif file_:
            filelog = repo.file(file_)
            if len(filelog):
                r = filelog
    if not r:
        if not file_:
            raise error.CommandError(cmd, _('invalid arguments'))
        if not os.path.isfile(file_):
            raise util.Abort(_("revlog '%s' not found") % file_)
        r = revlog.revlog(scmutil.opener(os.getcwd(), audit=False),
                          file_[:-2] + ".i")
    return r
Esempio n. 2
0
def openrevlog(repo, cmd, file_, opts):
    """opens the changelog, manifest, a filelog or a given revlog"""
    cl = opts['changelog']
    mf = opts['manifest']
    msg = None
    if cl and mf:
        msg = _('cannot specify --changelog and --manifest at the same time')
    elif cl or mf:
        if file_:
            msg = _('cannot specify filename with --changelog or --manifest')
        elif not repo:
            msg = _('cannot specify --changelog or --manifest '
                    'without a repository')
    if msg:
        raise util.Abort(msg)

    r = None
    if repo:
        if cl:
            r = repo.changelog
        elif mf:
            r = repo.manifest
        elif file_:
            filelog = repo.file(file_)
            if len(filelog):
                r = filelog
    if not r:
        if not file_:
            raise error.CommandError(cmd, _('invalid arguments'))
        if not os.path.isfile(file_):
            raise util.Abort(_("revlog '%s' not found") % file_)
        r = revlog.revlog(scmutil.opener(os.getcwd(), audit=False),
                          file_[:-2] + ".i")
    return r
Esempio n. 3
0
def simplemerge(ui, local, base, other, **opts):
    def readfile(filename):
        f = open(filename, "rb")
        text = f.read()
        f.close()
        if util.binary(text):
            msg = _("%s looks like a binary file.") % filename
            if not opts.get('quiet'):
                ui.warn(_('warning: %s\n') % msg)
            if not opts.get('text'):
                raise util.Abort(msg)
        return text

    name_a = local
    name_b = other
    name_base = None
    labels = opts.get('label', [])
    if len(labels) > 0:
        name_a = labels[0]
    if len(labels) > 1:
        name_b = labels[1]
    if len(labels) > 2:
        name_base = labels[2]
    if len(labels) > 3:
        raise util.Abort(_("can only specify three labels."))

    try:
        localtext = readfile(local)
        basetext = readfile(base)
        othertext = readfile(other)
    except util.Abort:
        return 1

    local = os.path.realpath(local)
    if not opts.get('print'):
        opener = scmutil.opener(os.path.dirname(local))
        out = opener(os.path.basename(local), "w", atomictemp=True)
    else:
        out = sys.stdout

    m3 = Merge3Text(basetext, localtext, othertext)
    extrakwargs = {}
    if name_base is not None:
        extrakwargs['base_marker'] = '|||||||'
        extrakwargs['name_base'] = name_base
    for line in m3.merge_lines(name_a=name_a, name_b=name_b, **extrakwargs):
        out.write(line)

    if not opts.get('print'):
        out.close()

    if m3.conflicts:
        if not opts.get('quiet'):
            ui.warn(_("warning: conflicts during merge.\n"))
        return 1
Esempio n. 4
0
def simplemerge(ui, local, base, other, **opts):
    def readfile(filename):
        f = open(filename, "rb")
        text = f.read()
        f.close()
        if util.binary(text):
            msg = _("%s looks like a binary file.") % filename
            if not opts.get('quiet'):
                ui.warn(_('warning: %s\n') % msg)
            if not opts.get('text'):
                raise util.Abort(msg)
        return text

    name_a = local
    name_b = other
    labels = opts.get('label', [])
    if labels:
        name_a = labels.pop(0)
    if labels:
        name_b = labels.pop(0)
    if labels:
        raise util.Abort(_("can only specify two labels."))

    try:
        localtext = readfile(local)
        basetext = readfile(base)
        othertext = readfile(other)
    except util.Abort:
        return 1

    local = os.path.realpath(local)
    if not opts.get('print'):
        opener = scmutil.opener(os.path.dirname(local))
        out = opener(os.path.basename(local), "w", atomictemp=True)
    else:
        out = sys.stdout

    reprocess = not opts.get('no_minimal')

    m3 = Merge3Text(basetext, localtext, othertext)
    for line in m3.merge_lines(name_a=name_a,
                               name_b=name_b,
                               reprocess=reprocess):
        out.write(line)

    if not opts.get('print'):
        out.close()

    if m3.conflicts:
        if not opts.get('quiet'):
            ui.warn(_("warning: conflicts during merge.\n"))
        return 1
Esempio n. 5
0
def simplemerge(ui, local, base, other, **opts):
    def readfile(filename):
        f = open(filename, "rb")
        text = f.read()
        f.close()
        if util.binary(text):
            msg = _("%s looks like a binary file.") % filename
            if not opts.get('quiet'):
                ui.warn(_('warning: %s\n') % msg)
            if not opts.get('text'):
                raise util.Abort(msg)
        return text

    name_a = local
    name_b = other
    labels = opts.get('label', [])
    if labels:
        name_a = labels.pop(0)
    if labels:
        name_b = labels.pop(0)
    if labels:
        raise util.Abort(_("can only specify two labels."))

    try:
        localtext = readfile(local)
        basetext = readfile(base)
        othertext = readfile(other)
    except util.Abort:
        return 1

    local = os.path.realpath(local)
    if not opts.get('print'):
        opener = scmutil.opener(os.path.dirname(local))
        out = opener(os.path.basename(local), "w", atomictemp=True)
    else:
        out = sys.stdout

    reprocess = not opts.get('no_minimal')

    m3 = Merge3Text(basetext, localtext, othertext)
    for line in m3.merge_lines(name_a=name_a, name_b=name_b,
                               reprocess=reprocess):
        out.write(line)

    if not opts.get('print'):
        out.close()

    if m3.conflicts:
        if not opts.get('quiet'):
            ui.warn(_("warning: conflicts during merge.\n"))
        return 1
Esempio n. 6
0
 def __init__(self, name, mtime):
     self.basedir = name
     self.opener = scmutil.opener(self.basedir)
Esempio n. 7
0
 def __init__(self, name, mtime):
     self.basedir = name
     self.opener = scmutil.opener(self.basedir)