unison icon indicating copy to clipboard operation
unison copied to clipboard

deleting the last branch in a project makes things awkward

Open ceedubs opened this issue 2 years ago • 3 comments

If you have only one branch in a project (let's say project foo and branch main) and you delete it, it's unclear how to continue to use the project.

If you try switch foo then it says that foo/main doesn't exist.

If you try branch foo/main then it will create main from your current namespace, which is likely the root of your codebase (and in my case takes ages to subsequently delete.branch).

.> project.create foo

  🎉 I've created the project foo.

  I'll now fetch the latest version of the base Unison library...
updateRoot: 531 ms (cpu), 548 ms (system)

  🎨 Type `ui` to explore this project's code in your browser.
  🔭 Discover libraries at https://share.unison-lang.org
  📖 Use `help-topic projects` to learn more about projects.
  
  Write your first Unison code with UCM:
  
    1. Open scratch.u.
    2. Write some Unison code and save the file.
    3. In UCM, type `add` to save it to your new project.
  
  🎉 🥳 Happy coding!
InputPattern: 619 ms (cpu), 1.78 s (system)
foo/main> branch.delete main
updateRoot: 259 ms (cpu), 270 ms (system)
InputPattern: 265 ms (cpu), 299 ms (system)
.> switch foo

  foo/main does not exist.
InputPattern: 1.82 ms (cpu), 4.56 ms (system)
.> branch foo/main
updateRoot: 16.3 ms (cpu), 27.4 ms (system)

  Done. I've created the foo/main branch from the namespace ..
InputPattern: 21.0 ms (cpu), 55.8 ms (system)

ceedubs avatar Jul 10 '23 21:07 ceedubs

Indeed it is awkward, but we had decided (for now) that we ought not to disallow a technically-valid state.

mitchellwrosen avatar Jul 10 '23 22:07 mitchellwrosen

@mitchellwrosen once in this state, how would one create an empty main branch for their technically-valid project?

With some digging I found that there was a branch.empty command, but it doesn't seem that I can use it:

.> branch.empty /httpserver/main

  branch.empty (or branch.create-empty, create.empty-branch)
  Create a new empty branch.

I also think that the behavior of branch.create from a (root) namespace (not within the project) forking the root namespace into the new branch is probably never want people want/expect. But maybe that would be less of a problem if it didn't take minutes to delete the branch afterwards.

ceedubs avatar Jul 11 '23 10:07 ceedubs

@mitchellwrosen once in this state, how would one create an empty main branch for their technically-valid project?

Hrm... I suppose today it would have to be like

.> cd asdfkjasdf
.asdfkjasdf> branch.create-empty foo/main

:sweat_smile:

I also think that the behavior of branch.create from a (root) namespace (not within the project) forking the root namespace into the new branch is probably never want people want/expect. But maybe that would be less of a problem if it didn't take minutes to delete the branch afterwards.

Yeah, agreed. Though we are somewhat unkeen on adding too many code paths that treat the root namespace differently than all others, because we want to refactor away from having all code loaded into one namespace in the first place.

mitchellwrosen avatar Jul 11 '23 16:07 mitchellwrosen