Beispiel #1
0
def differ(filename, rev1="", rev2=""):
    filename=to_utf8(filename)
    opts=""
    if rev1 and rev2:
        opts="-r%s -r%s" % (rev1, rev2)
    elif rev1 or rev2:
        opts="-r%s%s" % (rev1, rev2)
        
    cmd = '%(cmd)s %(opts)s -u -q "%(file)s"' % {'cmd':CMD_RCSDIFF, 'opts':opts, 'file':filename}
    log.debug('Command: '+cmd)
    buff = os.popen(cmd).read()
    return to_unicode(buff)
Beispiel #2
0
def backup(wcfile, comment='', user=''):
    if not wcfile:
        raise Exception, "working copy file is not given."
    if not user:
        user = "******"
    if isinstance(comment, (list, tuple)):
        comment = '\n'.join(comment)
    if not comment:
        comment = "no message."
    
    wcfile = to_utf8(wcfile)
    comment = to_utf8(comment)
    user = to_utf8(user, escape=True)
    
    cmd = []
    if not is_rcs_exist(wcfile):
        # -l : lock mode, make wcfile writable
        cmd.append('%(cmd)s -i -q -l -t-"%(msg)s" -w"%(user)s" "%(file)s" 2>&1' % \
                {'cmd':CMD_CI, "file":wcfile, "msg":comment, "user":user})
        # -U : set locking to no-strict.
        cmd.append('%(cmd)s -U -u -M -q "%(file)s"' % {'cmd':CMD_RCS, "file":wcfile})
    else:
        # Warning: w/o -l or -u option, wcfile will be removed after checkin.
        # -l makes wcfile writable;
        # -u : wcfile is not writable unless rcsfile is set to no-strict locking.
        cmd.append('%(cmd)s -q -u -m"%(msg)s" -w"%(user)s" "%(file)s" 2>&1' % \
                {'cmd':CMD_CI, "file":wcfile, "msg":comment, "user":user})

    for i in cmd:
        log.debug("Command: "+i)
        try:
            buff = os.popen(i).read().strip()
        except Exception, e:
            raise
        else:
            if buff:
                os.system('%(cmd)s -U -u -M -q "%(file)s"' % {'cmd':CMD_RCS, "file":wcfile})
                raise Exception, "Error Message: %s\n" % buff