Add a couple of safety checks to series creation
authorYann Dirson <ydirson@altern.org>
Sun, 16 Apr 2006 10:52:32 +0000 (12:52 +0200)
committerCatalin Marinas <catalin.marinas@gmail.com>
Tue, 2 May 2006 20:24:13 +0000 (21:24 +0100)
commitfe847176ac839e64d426e6bf8ab7ad67ba3129d6
tree344e8e2d1db39536104cb08394c330cf2a6731e7
parent8351555474ced37a21799755762ad69b3c826d70
Add a couple of safety checks to series creation

- we must check first whether the operation can complete, instead of
  bombing out halfway.  That means checking that nothing will prevent
  the creation of stgit data (note that calling is_initialised() is
  not enough, as it does not catch a bogus file), which is tested by
  the 3 first couple of testcases, and fixed in stack.py

- creating the git branch unconditionally before knowing whether
  creation of the stgit stuff can be completed is a problem as well:
  being atomic would be much much better.  To emulate atomicity (which
  comeds in the next patch), this patch does a somewhat dirty hack to
  branch.py: we first attempt to create the stgit stuff, and if that
  succeeds, we create the git branch: it is much easier to do at first
  a quick check that the latter will succeed.  Testcase 7/8 ensure
  that such a safety check has not been forgotten.

- when git already reports a problem with that head we would like to
  create, we should catch it.  Testcase 9/10 creates such a situation,
  and the fix to git.py allows to catch the error spit out by
  git-rev-parse.  I cannot tell why the stderr lines were not included
  by the Popen3 object.

Signed-off-by: Yann Dirson <ydirson@altern.org>
stgit/commands/branch.py
stgit/git.py
stgit/stack.py
t/t1000-branch-create.sh [new file with mode: 0755]