Refactor revision tag comments.
    Capirca generates the filter text having the following tag keys:

    - $Id:$
    - $Revision:$
    - $Date:$

    This function goes through all the config lines and replaces
    those tags with the content requested by the user.
    If a certain value is not provided, the corresponding tag will be stripped.

def _revision_tag(text,
                  revision_id=None,
                  revision_no=None,
                  revision_date=True,
                  revision_date_format='%Y/%m/%d'):
    '''
    Refactor revision tag comments.
    Capirca generates the filter text having the following tag keys:

    - $Id:$
    - $Revision:$
    - $Date:$

    This function goes through all the config lines and replaces
    those tags with the content requested by the user.
    If a certain value is not provided, the corresponding tag will be stripped.
    '''
    timestamp = datetime.datetime.now().strftime(revision_date_format)
    new_text = []
    for line in text.splitlines():
        if '$Id:$' in line:
            if not revision_id:  # if no explicit revision ID required
                continue  # jump to next line, ignore this one
            line = line.replace('$Id:$', '$Id: {rev_id} $'.format(rev_id=revision_id))
        if '$Revision:$' in line:
            if not revision_no:  # if no explicit revision number required
                continue  # jump to next line, ignore this one
            line = line.replace('$Revision:$', '$Revision: {rev_no} $'.format(rev_no=revision_no))
        if '$Date:$' in line:
            if not revision_date:
                continue  # jump
            line = line.replace('$Date:$', '$Date: {ts} $'.format(ts=timestamp))
        new_text.append(line)
    return '\n'.join(new_text)