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

View File

@ -92,6 +92,7 @@ data Output v
| SourceLoadFailed String | SourceLoadFailed String
-- No main function, the [Type v Ann] are the allowed types -- No main function, the [Type v Ann] are the allowed types
| NoMainFunction String PPE.PrettyPrintEnv [Type v Ann] | NoMainFunction String PPE.PrettyPrintEnv [Type v Ann]
| BranchEmpty (Either ShortBranchHash Path')
| BranchNotEmpty Path' | BranchNotEmpty Path'
| LoadPullRequest RemoteNamespace RemoteNamespace Path' Path' Path' | LoadPullRequest RemoteNamespace RemoteNamespace Path' Path' Path'
| CreatedNewBranch Path.Absolute | CreatedNewBranch Path.Absolute
@ -109,7 +110,6 @@ data Output v
| TermAmbiguous HQ.HashQualified (Set Referent) | TermAmbiguous HQ.HashQualified (Set Referent)
| HashAmbiguous ShortHash (Set Referent) | HashAmbiguous ShortHash (Set Referent)
| BranchHashAmbiguous ShortBranchHash (Set ShortBranchHash) | BranchHashAmbiguous ShortBranchHash (Set ShortBranchHash)
| BadDestinationBranch Path'
| BranchNotFound Path' | BranchNotFound Path'
| NameNotFound Path.HQSplit' | NameNotFound Path.HQSplit'
| PatchNotFound Path.Split' | PatchNotFound Path.Split'
@ -260,6 +260,7 @@ isFailure o = case o of
BranchAlreadyExists{} -> True BranchAlreadyExists{} -> True
PatchAlreadyExists{} -> True PatchAlreadyExists{} -> True
NoExactTypeMatches -> True NoExactTypeMatches -> True
BranchEmpty{} -> True
BranchNotEmpty{} -> True BranchNotEmpty{} -> True
TypeAlreadyExists{} -> True TypeAlreadyExists{} -> True
TypeParseError{} -> True TypeParseError{} -> True
@ -271,7 +272,6 @@ isFailure o = case o of
DeleteNameAmbiguous{} -> True DeleteNameAmbiguous{} -> True
TermAmbiguous{} -> True TermAmbiguous{} -> True
BranchHashAmbiguous{} -> True BranchHashAmbiguous{} -> True
BadDestinationBranch{} -> True
BadName{} -> True BadName{} -> True
BranchNotFound{} -> True BranchNotFound{} -> True
NameNotFound{} -> 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." pure . P.warnCallout $ "A type by that name already exists."
PatchAlreadyExists _ -> PatchAlreadyExists _ ->
pure . P.warnCallout $ "A patch by that name already exists." 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 -> BranchNotEmpty path ->
pure . P.warnCallout $ "I was expecting the namespace " <> prettyPath' path pure . P.warnCallout $ "I was expecting the namespace " <> prettyPath' path
<> " to be empty for this operation, but it isn't." <> " 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 "😶" $ NoBranchWithHash _h -> pure . P.callout "😶" $
P.wrap $ "I don't know of a namespace with that hash." P.wrap $ "I don't know of a namespace with that hash."
NotImplemented -> pure $ P.wrap "That's not implemented yet. Sorry! 😬" 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 -> LabeledReferenceNotFound hq ->
pure . P.callout "\129300" . P.wrap . P.syntaxToColor $ pure . P.callout "\129300" . P.wrap . P.syntaxToColor $
"Sorry, I couldn't find anything named" <> prettyHashQualified hq <> "." "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." P.wrap "Try again with a few more hash characters to disambiguate."
] ]
BadDestinationBranch _ -> pure "That destination namespace is bad."
BadName n -> BadName n ->
pure . P.wrap $ P.string n <> " is not a kind of name I understand." pure . P.wrap $ P.string n <> " is not a kind of name I understand."
TermNotFound' sh -> TermNotFound' sh ->