Beispiel #1
0
def _update_comments(comments, hg):
    """Store comments in the database and store comment changes in mercurial.
    
    Comments specified need not have actually changed.  In other words, it is 
    acceptable that some comments specified already match those in the 
    database.
    
    Arguments:
        comments -- Dict of DNS name -> comment pairs.
        hg -- A mercurial repository from jinx_api.api.lib.hg.
    """
    
    for record_name, comment in comments.iteritems():
        try:
            record = DNSRecord.objects.get(name=record_name)
        except ObjectDoesNotExist:
            record = DNSRecord(name=record_name)
            
        record.comment = comment
        record.save()
        
        if comment is None:
            comment = ""
        hg.put_file("comments/%s" % record_name, comment)