Changeset 72cf064 in mainline for contrib/bazaar/bzreml/__init__.py
- Timestamp:
- 2012-08-13T17:17:04Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 33fee91
- Parents:
- f4a8734 (diff), 4820360 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
contrib/bazaar/bzreml/__init__.py
rf4a8734 r72cf064 102 102 return "" 103 103 104 def iter_reverse_revision_history(repository, revision_id): 105 """Iterate backwards through revision ids in the lefthand history""" 106 107 graph = repository.get_graph() 108 stop_revisions = (None, _mod_revision.NULL_REVISION) 109 return graph.iter_lefthand_ancestry(revision_id, stop_revisions) 110 104 111 def revision_sequence(branch, revision_old_id, revision_new_id): 105 112 """Calculate a sequence of revisions""" 106 113 107 for revision_ac_id in branch.repository.iter_reverse_revision_history(revision_new_id):114 for revision_ac_id in iter_reverse_revision_history(branch.repository, revision_new_id): 108 115 if (revision_ac_id == revision_old_id): 109 116 break 117 110 118 yield revision_ac_id 111 119 … … 117 125 branch.repository.lock_read() 118 126 try: 119 body = StringIO()127 revision_prev_id = revision_old_id 120 128 121 for revision_ac_id in revision_sequence(branch, revision_old_id, revision_new_id): 129 for revision_ac_id in reversed(list(revision_sequence(branch, revision_old_id, revision_new_id))): 130 body = StringIO() 131 122 132 revision_ac = branch.repository.get_revision(revision_ac_id) 123 133 revision_ac_no = branch.revision_id_to_revno(revision_ac_id) … … 139 149 body.write("\n") 140 150 141 commit_message = ""151 commit_message = None 142 152 body.write("Log:\n") 143 153 if (not revision_ac.message): … … 147 157 for line in log.split("\n"): 148 158 body.write("%s\n" % line) 149 if (commit_message == ""):159 if (commit_message == None): 150 160 commit_message = line 151 161 152 if (commit_message == ""):162 if (commit_message == None): 153 163 commit_message = "(empty)" 154 164 155 165 body.write("\n") 166 167 tree_prev = branch.repository.revision_tree(revision_prev_id) 168 tree_ac = branch.repository.revision_tree(revision_ac_id) 169 170 delta = tree_ac.changes_from(tree_prev) 171 172 if (len(delta.added) > 0): 173 body.write("Added:\n") 174 for item in delta.added: 175 body.write(" %s\n" % item[0]) 176 177 if (len(delta.removed) > 0): 178 body.write("Removed:\n") 179 for item in delta.removed: 180 body.write(" %s\n" % item[0]) 181 182 if (len(delta.renamed) > 0): 183 body.write("Renamed:\n") 184 for item in delta.renamed: 185 body.write(" %s -> %s\n" % (item[0], item[1])) 186 187 if (len(delta.kind_changed) > 0): 188 body.write("Changed:\n") 189 for item in delta.kind_changed: 190 body.write(" %s\n" % item[0]) 191 192 if (len(delta.modified) > 0): 193 body.write("Modified:\n") 194 for item in delta.modified: 195 body.write(" %s\n" % item[0]) 196 197 body.write("\n") 198 199 tree_prev.lock_read() 200 try: 201 tree_ac.lock_read() 202 try: 203 diff = DiffTree.from_trees_options(tree_prev, tree_ac, body, "utf8", None, "", "", None) 204 diff.show_diff(None, None) 205 finally: 206 tree_ac.unlock() 207 finally: 208 tree_prev.unlock() 209 210 subject = "r%d - %s" % (revision_ac_no, commit_message) 211 send_smtp("localhost", config_sender(config), config_to(config), subject, body.getvalue()) 212 213 revision_prev_id = revision_ac_id 156 214 157 tree_old = branch.repository.revision_tree(revision_old_id)158 tree_new = branch.repository.revision_tree(revision_new_id)159 160 revision_new_no = branch.revision_id_to_revno(revision_new_id)161 delta = tree_new.changes_from(tree_old)162 163 if (len(delta.added) > 0):164 body.write("Added:\n")165 for item in delta.added:166 body.write(" %s\n" % item[0])167 168 if (len(delta.removed) > 0):169 body.write("Removed:\n")170 for item in delta.removed:171 body.write(" %s\n" % item[0])172 173 if (len(delta.renamed) > 0):174 body.write("Renamed:\n")175 for item in delta.renamed:176 body.write(" %s -> %s\n" % (item[0], item[1]))177 178 if (len(delta.kind_changed) > 0):179 body.write("Changed:\n")180 for item in delta.kind_changed:181 body.write(" %s\n" % item[0])182 183 if (len(delta.modified) > 0):184 body.write("Modified:\n")185 for item in delta.modified:186 body.write(" %s\n" % item[0])187 188 body.write("\n")189 190 tree_old.lock_read()191 try:192 tree_new.lock_read()193 try:194 diff = DiffTree.from_trees_options(tree_old, tree_new, body, "utf8", None, "", "", None)195 diff.show_diff(None, None)196 finally:197 tree_new.unlock()198 finally:199 tree_old.unlock()200 201 subject = "r%d - %s" % (revision_new_no, commit_message)202 203 send_smtp("localhost", config_sender(config), config_to(config), subject, body.getvalue())204 215 finally: 205 216 branch.repository.unlock()
Note:
See TracChangeset
for help on using the changeset viewer.