"""Close a bug"""
from libbe import cmdutil
def execute(args):
+ """
+ >>> from libbe import tests
+ >>> import os
+ >>> dir = tests.simple_bug_dir()
+ >>> os.chdir(dir.dir)
+ >>> dir.get_bug("a").status
+ 'open'
+ >>> execute(("a",))
+ >>> dir.get_bug("a").status
+ 'closed'
+ """
assert(len(args) == 1)
bug = cmdutil.get_bug(args[0])
bug.status = "closed"
map_save(self.rcs, os.path.join(self.dir, "settings"), self.settings)
def get_rcs(self):
- if self._rcs is not None and self.rcs_name == _rcs.name:
+ if self._rcs is not None and self.rcs_name == self._rcs.name:
return self._rcs
self._rcs = rcs_by_name(self.rcs_name)
return self._rcs
def list(self):
for uuid in self.list_uuids():
- yield Bug(self.bugs_path, uuid, self.rcs_name)
+ yield self.get_bug(uuid)
+
+ def get_bug(self, uuid):
+ return Bug(self.bugs_path, uuid, self.rcs_name)
def list_uuids(self):
for uuid in os.listdir(self.bugs_path):
continue
yield uuid
- def new_bug(self):
- uuid = names.uuid()
+ def new_bug(self, uuid=None):
+ if uuid is None:
+ uuid = names.uuid()
path = os.path.join(self.bugs_path, uuid)
self.rcs.mkdir(path)
bug = Bug(self.bugs_path, None, self.rcs_name)
def cmp_date(comm1, comm2):
return cmp(comm1.date, comm2.date)
-def new_bug(dir):
- bug = dir.new_bug()
+def new_bug(dir, uuid=None):
+ bug = dir.new_bug(uuid)
bug.creator = names.creator()
bug.severity = "minor"
bug.status = "open"
def bug_arch_dir():
dir = arch_dir()
return bugdir.create_bug_dir(dir.name, arch)
+
+def simple_bug_dir():
+ dir = bug_arch_dir()
+ bug_a = bugdir.new_bug(dir, "a")
+ bug_b = bugdir.new_bug(dir, "b")
+ bug_b.status = "closed"
+ bug_a.save()
+ bug_b.save()
+ return dir