-
Notifications
You must be signed in to change notification settings - Fork 274
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
render merge conflicts preferring Alice's names
- Loading branch information
1 parent
cba59d4
commit afe7f92
Showing
6 changed files
with
242 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,21 @@ | ||
module Unison.Merge.PrettyPrintEnv | ||
( makePrettyPrintEnvs, | ||
( makePrettyPrintEnv, | ||
) | ||
where | ||
|
||
import Unison.Merge.TwoWay (TwoWay) | ||
import Unison.Merge.TwoWay (TwoWay (..)) | ||
import Unison.Names (Names) | ||
import Unison.Names qualified as Names | ||
import Unison.Prelude | ||
import Unison.PrettyPrintEnv.Names qualified as PPE | ||
import Unison.PrettyPrintEnvDecl (PrettyPrintEnvDecl) | ||
import Unison.PrettyPrintEnvDecl.Names qualified as PPED | ||
|
||
-- Make PPE for Alice that contains all of Alice's names, but suffixified against her names + Bob's names | ||
makePrettyPrintEnvs :: TwoWay Names -> Names -> TwoWay PrettyPrintEnvDecl | ||
makePrettyPrintEnvs names2 libdepsNames = | ||
names2 <&> \names -> PPED.makePPED (PPE.namer (names <> libdepsNames)) suffixifier | ||
-- Create a PPE that uses Alice's names whenever possible, falling back to Bob's names only when Alice doesn't have any. | ||
-- This results in a file that "looks familiar" to Alice (the one merging in Bob's changes), and avoids superfluous | ||
-- textual conflicts that would arise from preferring Bob's names for Bob's code (where his names differ). | ||
makePrettyPrintEnv :: TwoWay Names -> Names -> PrettyPrintEnvDecl | ||
makePrettyPrintEnv names libdepsNames = | ||
PPED.makePPED (PPE.namer (Names.preferring names.alice names.bob <> libdepsNames)) suffixifier | ||
where | ||
suffixifier = PPE.suffixifyByName (fold names2 <> libdepsNames) | ||
suffixifier = PPE.suffixifyByName (fold names <> libdepsNames) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters