aboutsummaryrefslogtreecommitdiffstats
path: root/becommands
diff options
context:
space:
mode:
authorW. Trevor King <wking@drexel.edu>2009-07-21 07:28:26 -0400
committerW. Trevor King <wking@drexel.edu>2009-07-21 07:28:26 -0400
commit4c7a9d837a268480e61124bba84b5fb01ec3728f (patch)
treeeb20c2f424a0b334316e25fa179d2307befba66d /becommands
parent9ef6ad576c01444e35b91dfee8d05b39ec911d45 (diff)
downloadbugseverywhere-4c7a9d837a268480e61124bba84b5fb01ec3728f.tar.gz
Cleaned up saving/sync_with_disk.
Got rid of a whole bunch of redundant .save() calls when sync_with_disk==True. Fixed up the "File-system access" portion of the BugDir docstring so we can all remember how things are supposed to work ;). Note that some .save() calls are still required. For example in becommands/merge.py, the copied comments have their .bug changed, but that is not a versioned property, so it doesn't trigger an automatic save, and we have to force the .save() by hand. libbe.rcs.RCS.mkdir() is now recursive by default, but you can set check_parents==False if you want it to fail in the case of missing parents. Because of the recursion, we removed the .update() call on preexisting directories, since there will be at least one of these occurrences for every .mkdir(check_parents=True) call, and I don't know of any VCS that actually needs them... Also stripped trailing whitespace from some files...
Diffstat (limited to 'becommands')
-rw-r--r--becommands/comment.py1
-rw-r--r--becommands/depend.py1
-rw-r--r--becommands/diff.py2
-rw-r--r--becommands/merge.py8
-rw-r--r--becommands/new.py1
-rw-r--r--becommands/open.py1
-rw-r--r--becommands/remove.py1
-rw-r--r--becommands/set.py3
-rw-r--r--becommands/severity.py1
-rw-r--r--becommands/status.py1
-rw-r--r--becommands/tag.py3
-rw-r--r--becommands/target.py1
12 files changed, 7 insertions, 17 deletions
diff --git a/becommands/comment.py b/becommands/comment.py
index 66f8da1..eba640e 100644
--- a/becommands/comment.py
+++ b/becommands/comment.py
@@ -153,7 +153,6 @@ def execute(args, test=False):
kids = [c.uuid for c in parent.traverse()]
for nc in new_comments:
assert nc.uuid in kids, "%s wasn't added to %s" % (nc.uuid, parent.uuid)
- bd.save()
def get_parser():
parser = cmdutil.CmdOptionParser("be comment ID [COMMENT]")
diff --git a/becommands/depend.py b/becommands/depend.py
index 48e1527..4a23b0f 100644
--- a/becommands/depend.py
+++ b/becommands/depend.py
@@ -58,7 +58,6 @@ def execute(args, test=False):
else: # add the dependency
estrs.append(depend_string)
bugA.extra_strings = estrs # reassign to notice change
- bugA.save()
depends = []
for estr in bugA.extra_strings:
diff --git a/becommands/diff.py b/becommands/diff.py
index f3474b3..0acfcb2 100644
--- a/becommands/diff.py
+++ b/becommands/diff.py
@@ -24,10 +24,10 @@ def execute(args, test=False):
"""
>>> import os
>>> bd = bugdir.simple_bug_dir()
+ >>> bd.set_sync_with_disk(True)
>>> original = bd.rcs.commit("Original status")
>>> bug = bd.bug_from_uuid("a")
>>> bug.status = "closed"
- >>> bd.save()
>>> changed = bd.rcs.commit("Closed bug a")
>>> os.chdir(bd.root)
>>> if bd.rcs.versioned == True:
diff --git a/becommands/merge.py b/becommands/merge.py
index c030dd0..4aaefa8 100644
--- a/becommands/merge.py
+++ b/becommands/merge.py
@@ -22,6 +22,7 @@ def execute(args, test=False):
"""
>>> from libbe import utility
>>> bd = bugdir.simple_bug_dir()
+ >>> bd.set_sync_with_disk(True)
>>> a = bd.bug_from_shortname("a")
>>> a.comment_root.time = 0
>>> dummy = a.new_comment("Testing")
@@ -35,7 +36,6 @@ def execute(args, test=False):
>>> dummy.time = 1
>>> dummy = dummy.new_reply("1 2 3 4")
>>> dummy.time = 2
- >>> bd.save()
>>> os.chdir(bd.root)
>>> execute(["a", "b"], test=True)
Merging bugs a and b
@@ -140,13 +140,13 @@ def execute(args, test=False):
bugB.load_comments()
mergeA = bugA.new_comment("Merged from bug %s" % bugB.uuid)
newCommTree = copy.deepcopy(bugB.comment_root)
- for comment in newCommTree.traverse():
+ for comment in newCommTree.traverse(): # all descendant comments
comment.bug = bugA
- for comment in newCommTree:
+ comment.save() # force onto disk under bugA
+ for comment in newCommTree: # just the child comments
mergeA.add_reply(comment, allow_time_inversion=True)
bugB.new_comment("Merged into bug %s" % bugA.uuid)
bugB.status = "closed"
- bd.save()
print "Merging bugs %s and %s" % (bugA.uuid, bugB.uuid)
def get_parser():
diff --git a/becommands/new.py b/becommands/new.py
index 5325ccc..af599d7 100644
--- a/becommands/new.py
+++ b/becommands/new.py
@@ -58,7 +58,6 @@ def execute(args, test=False):
bug.assigned = options.assigned
elif bd.default_assignee != None:
bug.assigned = bd.default_assignee
- bd.save()
print "Created bug with ID %s" % bd.bug_shortname(bug)
def get_parser():
diff --git a/becommands/open.py b/becommands/open.py
index b4b1025..2ef5f43 100644
--- a/becommands/open.py
+++ b/becommands/open.py
@@ -43,7 +43,6 @@ def execute(args, test=False):
bd = bugdir.BugDir(from_disk=True, manipulate_encodings=not test)
bug = bd.bug_from_shortname(args[0])
bug.status = "open"
- bd.save()
def get_parser():
parser = cmdutil.CmdOptionParser("be open BUG-ID")
diff --git a/becommands/remove.py b/becommands/remove.py
index d441bfe..d79a7be 100644
--- a/becommands/remove.py
+++ b/becommands/remove.py
@@ -43,7 +43,6 @@ def execute(args, test=False):
bd = bugdir.BugDir(from_disk=True, manipulate_encodings=not test)
bug = bd.bug_from_shortname(args[0])
bd.remove_bug(bug)
- bd.save()
print "Removed bug %s" % bug.uuid
def get_parser():
diff --git a/becommands/set.py b/becommands/set.py
index 510eca7..0c0862f 100644
--- a/becommands/set.py
+++ b/becommands/set.py
@@ -61,7 +61,7 @@ def execute(args, test=False):
print _value_string(bd, args[0])
else:
if args[1] == "none":
- del bd.settings[args[0]]
+ setattr(bd, args[0], settings_object.EMPTY)
else:
if args[0] not in bd.settings_properties:
msg = "Invalid setting %s\n" % args[0]
@@ -70,7 +70,6 @@ def execute(args, test=False):
raise cmdutil.UserError(msg)
old_setting = bd.settings.get(args[0])
setattr(bd, args[0], args[1])
- bd.save()
def get_parser():
parser = cmdutil.CmdOptionParser("be set [NAME] [VALUE]")
diff --git a/becommands/severity.py b/becommands/severity.py
index fde9fba..65467e3 100644
--- a/becommands/severity.py
+++ b/becommands/severity.py
@@ -50,7 +50,6 @@ def execute(args, test=False):
if e.name != "severity":
raise e
raise cmdutil.UserError ("Invalid severity level: %s" % e.value)
- bd.save()
def get_parser():
parser = cmdutil.CmdOptionParser("be severity BUG-ID [SEVERITY]")
diff --git a/becommands/status.py b/becommands/status.py
index 89ae49a..edc948d 100644
--- a/becommands/status.py
+++ b/becommands/status.py
@@ -47,7 +47,6 @@ def execute(args, test=False):
if e.name != "status":
raise
raise cmdutil.UserError ("Invalid status: %s" % e.value)
- bd.save()
def get_parser():
parser = cmdutil.CmdOptionParser("be status BUG-ID [STATUS]")
diff --git a/becommands/tag.py b/becommands/tag.py
index a139528..216ffbc 100644
--- a/becommands/tag.py
+++ b/becommands/tag.py
@@ -22,6 +22,7 @@ def execute(args, test=False):
"""
>>> from libbe import utility
>>> bd = bugdir.simple_bug_dir()
+ >>> bd.set_sync_with_disk(True)
>>> os.chdir(bd.root)
>>> a = bd.bug_from_shortname("a")
>>> print a.extra_strings
@@ -56,7 +57,6 @@ def execute(args, test=False):
>>> a.extra_strings = []
>>> print a.extra_strings
[]
- >>> a.save()
>>> execute(["a"], test=True)
>>> bd._clear_bugs() # resync our copy of bug
>>> a = bd.bug_from_shortname("a")
@@ -102,7 +102,6 @@ def execute(args, test=False):
else: # add the tag
estrs.append(tag_string)
bug.extra_strings = estrs # reassign to notice change
- bd.save()
tags = []
for estr in bug.extra_strings:
diff --git a/becommands/target.py b/becommands/target.py
index 905c639..527b16a 100644
--- a/becommands/target.py
+++ b/becommands/target.py
@@ -65,7 +65,6 @@ def execute(args, test=False):
bug.target = None
else:
bug.target = args[1]
- bd.save()
def get_parser():
parser = cmdutil.CmdOptionParser("be target BUG-ID [TARGET]\nor: be target --list")