Repository: readthedocs/readthedocs.org
Issue: Setting default branch uses Version.slug instead of identifier

## Details

* Read the Docs project URL: https://readthedocs.org/projects/test-builds/
* Build URL (if applicable): https://readthedocs.org/projects/test-builds/builds/8319150/
* Read the Docs username (if applicable): humitos

## Expected Result

Build the branch set as default branch as when it's built as [non default](https://readthedocs.org/projects/test-builds/builds/8307296/).

> NOTE: the correct command here is `git checkout --force origin/branch/with/slashes`

## Actual Result

The `git checkout --force branch-with-slashes` command fails because the branch does not exist.

----

`Project.default_branch` is saved in an improperly way.

```
>>> Version.objects.get(slug='branch-with-slashes').__dict__
...
 'type': 'branch',
 'identifier': 'origin/branch/with/slashes',
 'verbose_name': 'branch/with/slashes',
 'slug': 'branch-with-slashes',
>>> Version.objects.get(slug='branch-with-slashes').project.default_branch                                                                                                               
'branch-with-slashes'
```


Changed files:
readthedocs/projects/forms.py, readthedocs/rtd_tests/tests/test_project_forms.py

diff --git a/readthedocs/projects/forms.py b/readthedocs/projects/forms.py
index e8bff7505..c21333e76 100644
--- a/readthedocs/projects/forms.py
+++ b/readthedocs/projects/forms.py
@@ -222,7 +222,7 @@ class ProjectAdvancedForm(ProjectTriggerBuildMixin, ProjectForm):
 
         default_choice = (None, '-' * 9)
         all_versions = self.instance.versions.values_list(
-            'slug', 'verbose_name'
+            'identifier', 'verbose_name'
         )
         self.fields['default_branch'].widget = forms.Select(
             choices=[default_choice] + list(all_versions)
diff --git a/readthedocs/rtd_tests/tests/test_project_forms.py b/readthedocs/rtd_tests/tests/test_project_forms.py
index a40752250..5dbec9304 100644
--- a/readthedocs/rtd_tests/tests/test_project_forms.py
+++ b/readthedocs/rtd_tests/tests/test_project_forms.py
@@ -174,6 +174,7 @@ class TestProjectAdvancedForm(TestCase):
             slug='public-1',
             active=True,
             privacy_level=PUBLIC,
+            identifier='public-1',
         )
         get(
             Version,
@@ -181,6 +182,7 @@ class TestProjectAdvancedForm(TestCase):
             slug='public-2',
             active=True,
             privacy_level=PUBLIC,
+            identifier='public-2',
         )
         get(
             Version,
@@ -188,6 +190,15 @@ class TestProjectAdvancedForm(TestCase):
             slug='public-3',
             active=False,
             privacy_level=PROTECTED,
+            identifier='public-3',
+        )
+        get(
+            Version,
+            project=self.project,
+            slug='public-4',
+            active=False,
+            privacy_level=PUBLIC,
+            identifier='public/4'
         )
         get(
             Version,
@@ -195,6 +206,7 @@ class TestProjectAdvancedForm(TestCase):
             slug='private',
             active=True,
             privacy_level=PRIVATE,
+            identifier='private',
         )
         get(
             Version,
@@ -202,6 +214,7 @@ class TestProjectAdvancedForm(TestCase):
             slug='protected',
             active=True,
             privacy_level=PROTECTED,
+            identifier='protected',
         )
 
     def test_list_only_active_versions_on_default_version(self):
@@ -222,12 +235,12 @@ class TestProjectAdvancedForm(TestCase):
         self.assertTrue(self.project.versions.filter(slug=LATEST).exists())
         self.assertEqual(
             set(
-                slug
-                for slug, _ in form.fields['default_branch'].widget.choices
+                identifier
+                for identifier, _ in form.fields['default_branch'].widget.choices
             ),
             {
-                None, 'latest', 'public-1', 'public-2',
-                'public-3', 'protected', 'private'
+                None, 'master', 'public-1', 'public-2',
+                'public-3', 'public/4', 'protected', 'private'
             },
         )