From 1cef6f1875462583e57d1543f313d4b4c585149f Mon Sep 17 00:00:00 2001 From: "Jasper St. Pierre" Date: Mon, 12 Mar 2012 16:27:35 -0400 Subject: attach: Obsolete patches with the same subject For plain 'git bz attach', always obsolete existing patches if they have the same subject as the commit being attached. For 'git bz attach -e', make this the default. https://bugzilla.gnome.org/show_bug.cgi?id=671941 --- git-bz | 7 ++++++- git-bz.txt | 5 +++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/git-bz b/git-bz index 0554f16..1259d6f 100755 --- a/git-bz +++ b/git-bz @@ -1725,7 +1725,8 @@ def edit_attachment_comment(bug, initial_description, initial_body): template.write("\n\n") if len(bug.patches) > 0: for patch in bug.patches: - template.write("#Obsoletes: %d - %s\n" % (patch.attach_id, patch.description)) + obsoleted = (initial_description == patch.description) + template.write("%sObsoletes: %d - %s\n" % ("" if obsoleted else "#", patch.attach_id, patch.description)) template.write("\n") template.write("""# Please edit the description (first line) and comment (other lines). Lines @@ -1771,6 +1772,10 @@ def attach_commits(bug, commits, include_comments=True, edit_comments=False, sta else: description = commit.subject obsoletes = [] + for attachment in bug.patches: + if attachment.description == commit.subject: + obsoletes.append(attachment.attach_id) + bug.create_patch(description, body, filename, patch, obsoletes=obsoletes, status=status) def do_attach(*args): diff --git a/git-bz.txt b/git-bz.txt index 9817120..02df8d1 100644 --- a/git-bz.txt +++ b/git-bz.txt @@ -187,6 +187,11 @@ to the bug (see 'git bz add-url'). This can be suppressed with the allow the user to edit the description and comment for each patch, and (by uncommenting lines) obsolete old patches. +When a commit with the same subject as an existing patch is attached, +this is interpreted as a new version of the existing patch and the old +patch is obsoleted. (With '-e', the obsoletes line can be commented +to suppress this.) + Examples: ---------------------------------------- # Attach the last commit -- cgit v1.2.3