In the past, this used to lead to a broken branch which could be
difficult to even delete. This patch allows the branch to be created
properly and be more tolerant to branch deletion.
Signed-off-by: Catalin Marinas <catalin.marinas@gmail.com>
# exception in branch = rev_parse() leaves branchpoint unbound
branchpoint = None
# exception in branch = rev_parse() leaves branchpoint unbound
branchpoint = None
- tree_id = branchpoint or git_id(crt_series, args[1])
+ tree_id = git_id(crt_series, branchpoint or args[1])
if parentbranch:
out.info('Recording "%s" as parent branch' % parentbranch)
if parentbranch:
out.info('Recording "%s" as parent branch' % parentbranch)
self.create_empty_field('top')
def delete(self):
self.create_empty_field('top')
def delete(self):
- for f in os.listdir(self._dir()):
- os.remove(os.path.join(self._dir(), f))
- os.rmdir(self._dir())
- git.delete_ref(self.__top_ref)
+ if os.path.isdir(self._dir()):
+ for f in os.listdir(self._dir()):
+ os.remove(os.path.join(self._dir(), f))
+ os.rmdir(self._dir())
+ else:
+ out.warn('Patch directory "%s" does not exist' % self._dir())
+ try:
+ # the reference might not exist if the repository was corrupted
+ git.delete_ref(self.__top_ref)
+ except git.GitException, e:
+ out.warn(str(e))
if git.ref_exists(self.__log_ref):
git.delete_ref(self.__log_ref)
if git.ref_exists(self.__log_ref):
git.delete_ref(self.__log_ref)