Patchwork [1,of,3] ui: define disppath for converting paths before showing to the user

login
register
mail settings
Submitter Simon Heimberg
Date March 20, 2013, 10:39 a.m.
Message ID <1b3fe856c993907ba4e1.1363775976@lapsi.heimberg.home>
Download mbox | patch
Permalink /patch/1142/
State Changes Requested, archived
Headers show

Comments

Simon Heimberg - March 20, 2013, 10:39 a.m.
# HG changeset patch
# User Simon Heimberg <simohe@besonet.ch>
# Date 1363775803 -3600
# Node ID 1b3fe856c993907ba4e14663e8c293f4f32333e8
# Parent  a04dd2b1e40fcd6e22e057bb46d99c02f68d34f9
ui: define disppath for converting paths before showing to the user
Bryan O'Sullivan - March 27, 2013, 3:46 p.m.
On Wed, Mar 20, 2013 at 3:39 AM, Simon Heimberg <simohe@besonet.ch> wrote:

> ui: define disppath for converting paths before showing to the user
>

Could you give this a better name, e.g. displaypath?

Patch

diff -r a04dd2b1e40f -r 1b3fe856c993 mercurial/ui.py
--- a/mercurial/ui.py	Son Mär 17 14:12:56 2013 +0100
+++ b/mercurial/ui.py	Mit Mär 20 11:36:43 2013 +0100
@@ -391,6 +391,13 @@ 
             return feature not in exceptions
         return True
 
+    @util.propertycache
+    def disppath(self):
+        "returns a function converting path seperators for showing to the user"
+        if self.configbool('ui', 'slash') and os.sep != '/':
+            return util.normpath
+        return lambda p: p # no conversion
+
     def username(self):
         """Return default username to be used in commits.