Mercurial > public > mercurial-scm > hg
comparison mercurial/scmutil.py @ 41575:aec185af621e
config: introduce a new value for ui.relative-paths getting old behavior
The few places I've modified so far to respect ui.relative-paths have
traditionally defaulted showing the path from the repo root. However,
some commands (at least `hg files`) default to showing paths relative
to the cwd. Let's allow a special value for ui.relative-paths to
preserve the old behavior, so we can use that as default value for
it. I don't expect that anyone would want to set this value, so
perhaps we could have relied on it being unset, but I don't really
like behaviors that can only be achieved by a unset config option.
Differential Revision: https://phab.mercurial-scm.org/D5800
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Fri, 01 Feb 2019 22:28:55 -0800 |
parents | 02186c6871ac |
children | 8785188d1915 |
comparison
equal
deleted
inserted
replaced
41574:b436059c1cca | 41575:aec185af621e |
---|---|
723 return [parents[0], repo[nullrev]] | 723 return [parents[0], repo[nullrev]] |
724 if parents[0].rev() >= intrev(ctx) - 1: | 724 if parents[0].rev() >= intrev(ctx) - 1: |
725 return [] | 725 return [] |
726 return parents | 726 return parents |
727 | 727 |
728 def getuipathfn(repo, relative=None): | 728 def getuipathfn(repo, legacyrelativevalue=False, forcerelativevalue=None): |
729 if relative is None: | 729 """Return a function that produced paths for presenting to the user. |
730 relative = repo.ui.configbool('ui', 'relative-paths') | 730 |
731 The returned function takes a repo-relative path and produces a path | |
732 that can be presented in the UI. | |
733 | |
734 Depending on the value of ui.relative-paths, either a repo-relative or | |
735 cwd-relative path will be produced. | |
736 | |
737 legacyrelativevalue is the value to use if ui.relative-paths=legacy | |
738 | |
739 If forcerelativevalue is not None, then that value will be used regardless | |
740 of what ui.relative-paths is set to. | |
741 """ | |
742 if forcerelativevalue is not None: | |
743 relative = forcerelativevalue | |
744 else: | |
745 config = repo.ui.config('ui', 'relative-paths') | |
746 if config == 'legacy': | |
747 relative = legacyrelativevalue | |
748 else: | |
749 relative = stringutil.parsebool(config) | |
750 if relative is None: | |
751 raise error.ConfigError( | |
752 _("ui.relative-paths is not a boolean ('%s')") % config) | |
753 | |
731 if relative: | 754 if relative: |
732 cwd = repo.getcwd() | 755 cwd = repo.getcwd() |
733 pathto = repo.pathto | 756 pathto = repo.pathto |
734 return lambda f: pathto(f, cwd) | 757 return lambda f: pathto(f, cwd) |
735 else: | 758 else: |