Merge branch 'master' into topic/dependents-dependencies-debug.file

This commit is contained in:
Arya Irani 2020-04-06 15:09:49 -04:00 committed by GitHub
commit 9168d74e20
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 7 deletions

View File

@ -601,9 +601,11 @@ loop = do
let tryUpdateDest srcb dest0 = do
let dest = resolveToAbsolute dest0
-- if dest isn't empty: leave dest unchanged, and complain.
ok <- updateAtM dest $ \destb ->
pure (if Branch.isEmpty destb then srcb else destb)
if ok then success else respond $ BadDestinationBranch dest0
destb <- getAt dest
if Branch.isEmpty destb then do
ok <- updateAtM dest (const $ pure srcb)
if ok then success else respond $ BranchEmpty src0
else respond $ BranchAlreadyExists dest0
case src0 of
Left hash -> resolveShortBranchHash hash >>= \case
Left output -> respond output

View File

@ -92,6 +92,7 @@ data Output v
| SourceLoadFailed String
-- No main function, the [Type v Ann] are the allowed types
| NoMainFunction String PPE.PrettyPrintEnv [Type v Ann]
| BranchEmpty (Either ShortBranchHash Path')
| BranchNotEmpty Path'
| LoadPullRequest RemoteNamespace RemoteNamespace Path' Path' Path'
| CreatedNewBranch Path.Absolute
@ -109,7 +110,6 @@ data Output v
| TermAmbiguous HQ.HashQualified (Set Referent)
| HashAmbiguous ShortHash (Set Referent)
| BranchHashAmbiguous ShortBranchHash (Set ShortBranchHash)
| BadDestinationBranch Path'
| BranchNotFound Path'
| NameNotFound Path.HQSplit'
| PatchNotFound Path.Split'
@ -260,6 +260,7 @@ isFailure o = case o of
BranchAlreadyExists{} -> True
PatchAlreadyExists{} -> True
NoExactTypeMatches -> True
BranchEmpty{} -> True
BranchNotEmpty{} -> True
TypeAlreadyExists{} -> True
TypeParseError{} -> True
@ -271,7 +272,6 @@ isFailure o = case o of
DeleteNameAmbiguous{} -> True
TermAmbiguous{} -> True
BranchHashAmbiguous{} -> True
BadDestinationBranch{} -> True
BadName{} -> True
BranchNotFound{} -> True
NameNotFound{} -> True

View File

@ -362,6 +362,8 @@ notifyUser dir o = case o of
pure . P.warnCallout $ "A type by that name already exists."
PatchAlreadyExists _ ->
pure . P.warnCallout $ "A patch by that name already exists."
BranchEmpty b -> pure . P.warnCallout . P.wrap $
P.group (either P.shown prettyPath' b) <> "is an empty namespace."
BranchNotEmpty path ->
pure . P.warnCallout $ "I was expecting the namespace " <> prettyPath' path
<> " to be empty for this operation, but it isn't."
@ -792,7 +794,8 @@ notifyUser dir o = case o of
NoBranchWithHash _h -> pure . P.callout "😶" $
P.wrap $ "I don't know of a namespace with that hash."
NotImplemented -> pure $ P.wrap "That's not implemented yet. Sorry! 😬"
BranchAlreadyExists _ -> pure "That namespace already exists."
BranchAlreadyExists p -> pure . P.wrap $
"The namespace" <> prettyPath' p <> "already exists."
LabeledReferenceNotFound hq ->
pure . P.callout "\129300" . P.wrap . P.syntaxToColor $
"Sorry, I couldn't find anything named" <> prettyHashQualified hq <> "."
@ -850,7 +853,6 @@ notifyUser dir o = case o of
"",
P.wrap "Try again with a few more hash characters to disambiguate."
]
BadDestinationBranch _ -> pure "That destination namespace is bad."
BadName n ->
pure . P.wrap $ P.string n <> " is not a kind of name I understand."
TermNotFound' sh ->