From d311609eaaf044f803134c72a045e08816cf6dcb Mon Sep 17 00:00:00 2001 From: Prat T Date: Wed, 2 Oct 2019 22:12:30 -0700 Subject: [PATCH 1/4] Add FindPatchI outputs to LoopState's numberedArgs --- .../src/Unison/Codebase/Editor/HandleInput.hs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/parser-typechecker/src/Unison/Codebase/Editor/HandleInput.hs b/parser-typechecker/src/Unison/Codebase/Editor/HandleInput.hs index f9ad88caf..e36feddf8 100644 --- a/parser-typechecker/src/Unison/Codebase/Editor/HandleInput.hs +++ b/parser-typechecker/src/Unison/Codebase/Editor/HandleInput.hs @@ -825,12 +825,13 @@ loop = do -- next update for that file (which will happen immediately) latestFile .= ((, True) <$> loc) - FindPatchI -> - let patches = Set.fromList + FindPatchI -> do + let patches = [ Path.toName $ Path.snoc p seg | (p, b) <- Branch.toList0 currentBranch0 , (seg, _) <- Map.toList (Branch._edits b) ] - in respond $ ListOfPatches patches + respond $ ListOfPatches $ Set.fromList patches + numberedArgs .= fmap Name.toString patches FindShallowI pathArg -> do prettyPrintNames0 <- basicPrettyPrintNames0 From 38dcbf4a025600518dda85a10db60be216c5aeed Mon Sep 17 00:00:00 2001 From: Prat T Date: Thu, 3 Oct 2019 19:44:52 -0700 Subject: [PATCH 2/4] format list of patches --- .../src/Unison/CommandLine/OutputMessages.hs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/parser-typechecker/src/Unison/CommandLine/OutputMessages.hs b/parser-typechecker/src/Unison/CommandLine/OutputMessages.hs index a11031076..e9987744a 100644 --- a/parser-typechecker/src/Unison/CommandLine/OutputMessages.hs +++ b/parser-typechecker/src/Unison/CommandLine/OutputMessages.hs @@ -523,9 +523,15 @@ notifyUser dir o = case o of , "You're missing:" `P.hang` P.lines (fmap (P.text . Reference.toText) new) , "I'm missing:" `P.hang` P.lines (fmap (P.text . Reference.toText) old) ] - ListOfPatches patches -> - -- todo: make this prettier - pure . P.lines . fmap prettyName $ toList patches + ListOfPatches patches -> pure $ + if null patches then P.lit "nothing to show" + else numberedPatches patches + where + numberedPatches :: Set Name -> P.Pretty P.ColorText + numberedPatches patches = + (P.column2 . fmap format) ([(1::Integer)..] `zip` (toList patches)) + where + format (i, p) = (P.hiBlack . fromString $ show i <> ".", prettyName p) NoConfiguredGitUrl pp p -> pure . P.fatalCallout . P.wrap $ "I don't know where to " <> From ac3eb09f8eb2881257c1cfcd6034f66bc27f14e4 Mon Sep 17 00:00:00 2001 From: Prat T Date: Thu, 3 Oct 2019 23:08:37 -0700 Subject: [PATCH 3/4] Update CONTRIBUTORS.markdown --- CONTRIBUTORS.markdown | 1 + 1 file changed, 1 insertion(+) diff --git a/CONTRIBUTORS.markdown b/CONTRIBUTORS.markdown index 74389bcbc..c6ec1e6c5 100644 --- a/CONTRIBUTORS.markdown +++ b/CONTRIBUTORS.markdown @@ -26,3 +26,4 @@ The format for this list: name, GitHub handle, and then optional blurb about wha * Ian Jeffries (@seagreen) * Silvino Escalona (@sunrisem) * James Sully (@sullyj3) +* Prat Tana (@pt2121) From d49164fdb8503a4a1cfaf0e22f229c82bb4ded6d Mon Sep 17 00:00:00 2001 From: Prat T Date: Fri, 11 Oct 2019 22:09:46 -0700 Subject: [PATCH 4/4] Add a transcript for find-patch --- unison-src/transcripts/find-patch.md | 24 ++++++ unison-src/transcripts/find-patch.output.md | 83 +++++++++++++++++++++ 2 files changed, 107 insertions(+) create mode 100644 unison-src/transcripts/find-patch.md create mode 100644 unison-src/transcripts/find-patch.output.md diff --git a/unison-src/transcripts/find-patch.md b/unison-src/transcripts/find-patch.md new file mode 100644 index 000000000..1ea90f3bb --- /dev/null +++ b/unison-src/transcripts/find-patch.md @@ -0,0 +1,24 @@ +# find.patch Test + +```unison test.u +hey = "yello" +``` + +```ucm +.> add +``` + +Update + +```unison test.u +hey = "hello" +``` + +Update + +```ucm +.> update +.> find.patch +.> view.patch patch +.> view.patch 1 +``` diff --git a/unison-src/transcripts/find-patch.output.md b/unison-src/transcripts/find-patch.output.md new file mode 100644 index 000000000..51c981fe0 --- /dev/null +++ b/unison-src/transcripts/find-patch.output.md @@ -0,0 +1,83 @@ +# find.patch Test + +```unison +--- +title: test.u +--- +hey = "yello" + +``` + + +```ucm + + I found and typechecked these definitions in test.u. If you do + an `add` or `update`, here's how your codebase would change: + + ⍟ These new definitions are ok to `add`: + + hey : builtin.Text + + Now evaluating any watch expressions (lines starting with + `>`)... Ctrl+C cancels. + +``` +```ucm +.> add + + ⍟ I've added these definitions: + + hey : builtin.Text + +``` +Update + +```unison +--- +title: test.u +--- +hey = "hello" + +``` + + +```ucm + + I found and typechecked these definitions in test.u. If you do + an `add` or `update`, here's how your codebase would change: + + ⍟ These new definitions will replace existing ones of the + same name and are ok to `update`: + + hey : builtin.Text + + Now evaluating any watch expressions (lines starting with + `>`)... Ctrl+C cancels. + +``` +Update + +```ucm +.> update + + ⍟ I've updated to these definitions: + + hey : builtin.Text + + ✅ + + No conflicts or edits in progress. + +.> find.patch + + 1. patch + +.> view.patch patch + + Edited Terms: hey#8e79ctircj -> hey + +.> view.patch 1 + + Edited Terms: hey#8e79ctircj -> hey + +```