/** * Creates and saves a new branch, including setting up initial commit etc * * @param name * @param user * @param session * @return */ public Branch createBranch(String name, Profile user, Session session) { Commit head = new Commit(); head.setCreatedDate(new Date()); head.setEditor(user); head.setItemHash(null); session.save(head); Branch b = new Branch(); b.setName(Branch.TRUNK); b.setRepository(this); b.setHead(head); session.save(b); if (getBranches() == null) { setBranches(new ArrayList<Branch>()); } getBranches().add(b); return b; }