aboutsummaryrefslogtreecommitdiffstats
path: root/becommands
diff options
context:
space:
mode:
authorW. Trevor King <wking@drexel.edu>2009-06-25 07:45:57 -0400
committerW. Trevor King <wking@drexel.edu>2009-06-25 07:45:57 -0400
commit797bf225ff29a73fa0770d6cefef12a27cc3d760 (patch)
treeeb9d40593427525b6ee6f9189c36a35362cb61ce /becommands
parent269778a3983bc56b02c921a306b257b18fe16c47 (diff)
downloadbugseverywhere-797bf225ff29a73fa0770d6cefef12a27cc3d760.tar.gz
tag --remove now returns bug.settings["extra_strings"] to EMPTY.
extra_strings returns to a defaulting property from a cached/generator property, with the help of the new, mutable defaults. Lots of deepcopies avoid mutable default uncertainty too ;). And copy.deepcopy([]) should be pretty cheap. tag --remove had previously left settings["extra_strings"] as [], which polluted the bug's values file. Now the improved defaulting_property notices a return to the default [], and sets the internally stored value to EMPTY. I struggled with creating a more intuitive way to notice changes to extra_strings than the tmp = bug.extra_strings <work on tmp> bug.extra_strings = tmp but didn't have any luck. The problem seems to be that if you only hand out copies of your default, you don't have any pointers to what you handed out to check for changes. On the other hand, if you hand out your original default, any external changes will _change_ your original default. I suppose you could only hand out copies, but keep a list of all copies handed out, but that sounds like a disaster. Reassigning is easy enough.
Diffstat (limited to 'becommands')
-rw-r--r--becommands/tag.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/becommands/tag.py b/becommands/tag.py
index 0b19e91..b8030f3 100644
--- a/becommands/tag.py
+++ b/becommands/tag.py
@@ -61,6 +61,11 @@ def execute(args, test=False):
>>> a = bd.bug_from_shortname("a")
>>> print a.extra_strings
[]
+ >>> execute(["a", "Alphabetically first"], test=True)
+ Tagging bug a:
+ Alphabetically first
+ >>> execute(["--remove", "a", "Alphabetically first"], test=True)
+ Tags for a:
"""
parser = get_parser()
options, args = parser.parse_args(args)
@@ -79,7 +84,6 @@ def execute(args, test=False):
new_tag = None
if len(args) == 2:
given_tag = args[1]
- # reassign list so the change_hook realizes we've altered it.
tags = bug.extra_strings
tag_string = "TAG:%s" % given_tag
if options.remove == True:
@@ -87,15 +91,15 @@ def execute(args, test=False):
else: # add the tag
new_tag = given_tag
tags.append(tag_string)
- bug.extra_strings = tags
+ bug.extra_strings = tags # reassign to notice change
+
+ bug.save()
tags = []
for estr in bug.extra_strings:
if estr.startswith("TAG:"):
tags.append(estr[4:])
- bd.save()
-
if new_tag == None:
print "Tags for %s:" % bug.uuid
else: