i went with a simple batch file as i'd never done anything substantial using them.
you'll also need Curl (this is what i used to send the get requests)
Here is the code i used
[spoiler]
@ECHO off
set /p _folder=FolderName:
call ToLower %_folder% >temp.tmp
set /p _folder_lower=
del temp.tmp
echo ------------------------------- >Setup.log
echo --- Creating Mercurial Repo --- >>Setup.log
echo ------------------------------- >>Setup.log
echo. >>Setup.log
curl -X POST -d "name=%_folder%&is_private=true" https://api.bitbucket.org/1.0/repositories/ -u [UserName Here]:[Password Here] -k >>Setup.log
echo. >>Setup.log
echo ------------------------------ >>Setup.log
echo --- Cloning Mercurial Repo --- >>Setup.log
PING 1.1.1.1 -n 1 -w 5000 >NUL
echo ------------------------------ >>Setup.log
echo.
echo ------------------------------ >>Setup.log
echo --- Cloning Mercurial Repo --- >>Setup.log
echo. >>Setup.log
hg clone http://[UserName Here]:[Password Here]@bitbucket.org/[UserName Here]/%_folder_lower% %_folder% >>Setup.log
echo. >>Setup.log
echo ------------------------------ >>Setup.log
echo ---------------------------------- >>Setup.log
echo --- Creating Local Directories --- >>Setup.log
echo ---------------------------------- >>Setup.log
echo. >>Setup.log
echo empty > %_folder%\.empty
mkdir %_folder%\Design
echo %_folder%\Design >>Setup.log
echo empty > %_folder%\Design\.empty
mkdir %_folder%\Assets
echo %_folder%\Assets >>Setup.log
echo empty > %_folder%\Assets\.empty
mkdir %_folder%\Deliverables
echo %_folder%\Deliverables >>Setup.log
echo empty > %_folder%\Deliverables\.empty
mkdir %_folder%\Source
echo %_folder%\Source >>Setup.log
echo empty > %_folder%\Source\.empty
mkdir %_folder%\TestFolder
echo %_folder%\TestFolder >>Setup.log
echo empty > %_folder%\TestFolder\.empty
mkdir %_folder%\Markting
echo %_folder%\Marketing >>Setup.log
echo empty > %_folder%\Marekting\.empty
echo. >>Setup.log
echo ---------------------------------- >>Setup.log
echo --- Adding Files to Repository --- >>Setup.log
echo ---------------------------------- >>Setup.log
echo. >>Setup.log
cd %_folder%
hg add >>./Setup.log
hg commit -m "Project Setup" >>./Setup.log
hg push >>./Setup.log
cd ..
echo. >>Setup.log
echo ---------- Done ------------- >>Setup.log
move Setup.log %_folder%
[/spoiler]
It takes a single argument which is a folder/project name
Most of what it does is pretty standard but i'll go over some of the more interesting parts.
set /p _folder=FolderName:
call ToLower %_folder% >temp.tmp
set /p _folder_lower=
del temp.tmp
This is neede because the project names in butbucket have some issues with capitalised names and was the best method i coudl find for lowercasing a string.
all it does is uses ToLower and saves it out, then reads it in to a variable called _folder_lower
I had some trouble with getting the result of ToLower to save directly to a variable which is why i used this method, feel free to swap with something less ugly.
curl -X POST -d "name=%_folder%&is_private=true" https://api.bitbucket.org/1.0/repositories/ -u [UserName Here]:[Password Here] -k >>Setup.log
This creates the project in bitbucket, i won't go into detail about the curls syntax as its pretty well documented however the properties i am passing are:
name=[FolderName]
is_private=true
As i said previously, bitbucket allow private repositories which is what the is_private variable is for.
PING 1.1.1.1 -n 1 -w 5000 >NUL
I found this to be almost always needed, it gives some space between the creation of the project and the first cloning of the repository
mkdir %_folder%\Design
echo empty > %_folder%\Design\.empty
This is a mercurial requirement, it only stores files(as opposed to folders) so to have the folders in the repository structure you need to add a file to them.
I chose a .empty file
you can remove these once you add someting else to the folder.
After this i add the newly created .empty files, commit to the local repository and push to the bitbucket repo.
Job done.
It is very ugly and could probably be much prettier/more efficient, but it does the job so i leave it alone.
also the directory structure is my own personal preference, there is no reason you cannot substitute your own folder structure(provided you add.empty files to each folder)