artemis.py
changeset 30 b93ab358f2fc
parent 29 0b3edabb7da2
child 31 bffaaa5c8c9b
equal deleted inserted replaced
29:0b3edabb7da2 30:b93ab358f2fc
   136     if id and comment >= len(mbox):
   136     if id and comment >= len(mbox):
   137         ui.warn('No such comment number in mailbox, commenting on the issue itself\n')
   137         ui.warn('No such comment number in mailbox, commenting on the issue itself\n')
   138 
   138 
   139     if not id:
   139     if not id:
   140         outer.add_header('Message-Id', "<%s-0-artemis@%s>" % (issue_id, socket.gethostname()))
   140         outer.add_header('Message-Id', "<%s-0-artemis@%s>" % (issue_id, socket.gethostname()))
   141         root = 0
       
   142     else:
   141     else:
   143         root = keys[0]
   142         root = keys[0]
   144         outer.add_header('Message-Id', "<%s-%s-artemis@%s>" % (issue_id, _random_id(), socket.gethostname()))
   143         outer.add_header('Message-Id', "<%s-%s-artemis@%s>" % (issue_id, _random_id(), socket.gethostname()))
   145         outer.add_header('References', mbox[(comment < len(mbox) and keys[comment]) or root]['Message-Id'])
   144         outer.add_header('References', mbox[(comment < len(mbox) and keys[comment]) or root]['Message-Id'])
   146         outer.add_header('In-Reply-To', mbox[(comment < len(mbox) and keys[comment]) or root]['Message-Id'])
   145         outer.add_header('In-Reply-To', mbox[(comment < len(mbox) and keys[comment]) or root]['Message-Id'])
   147     repo.add([issue_fn[(len(repo.root)+1):] + '/new/'  + mbox.add(outer)])   # +1 for the trailing /
   146     repo.add([issue_fn[(len(repo.root)+1):] + '/new/'  + mbox.add(outer)])   # +1 for the trailing /
   148 
   147 
   149     # Fix properties in the root message
   148     # Fix properties in the root message
   150     msg = mbox[root]
       
   151     if properties:
   149     if properties:
       
   150         root = _find_root_key(mbox)
       
   151         msg = mbox[root]
   152         for property, value in properties:
   152         for property, value in properties:
   153             if property in msg:
   153             if property in msg:
   154                 msg.replace_header(property, value)
   154                 msg.replace_header(property, value)
   155             else:
   155             else:
   156                 msg.add_header(property, value)
   156                 msg.add_header(property, value)
   157     mbox[root] = msg
   157         mbox[root] = msg
   158 
   158 
   159     mbox.close()
   159     mbox.close()
   160 
   160 
   161     # If adding issue, add the new mailbox to the repository
   161     # If adding issue, add the new mailbox to the repository
   162     if not id:
   162     if not id: