changeset 15101:a21ccf4412d5

share: allow trailing newline on .hg/sharedpath. This is extremely handy for those occasional circumstances where you need to edit .hg/sharedpath manually, since modern Unix text editors make it surprisingly difficult to create a text file with no trailing newline.
author Greg Ward <greg@gerg.ca>
date Wed, 14 Sep 2011 22:28:27 -0400
parents a051f8a6a7cc
children a7e375d087f6
files mercurial/localrepo.py tests/test-share.t
diffstat 2 files changed, 10 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/localrepo.py	Wed Sep 07 10:24:26 2011 -0400
+++ b/mercurial/localrepo.py	Wed Sep 14 22:28:27 2011 -0400
@@ -79,7 +79,7 @@
 
         self.sharedpath = self.path
         try:
-            s = os.path.realpath(self.opener.read("sharedpath"))
+            s = os.path.realpath(self.opener.read("sharedpath").rstrip('\n'))
             if not os.path.exists(s):
                 raise error.RepoError(
                     _('.hg/sharedpath points to nonexistent directory %s') % s)
--- a/tests/test-share.t	Wed Sep 07 10:24:26 2011 -0400
+++ b/tests/test-share.t	Wed Sep 14 22:28:27 2011 -0400
@@ -28,6 +28,15 @@
   $ cat .hg/sharedpath; echo
   $TESTTMP/repo1/.hg
 
+trailing newline on .hg/sharedpath is ok
+  $ hg tip -q
+  0:d3873e73d99e
+  $ echo '' >> .hg/sharedpath
+  $ cat .hg/sharedpath
+  $TESTTMP/repo1/.hg
+  $ hg tip -q
+  0:d3873e73d99e
+
 commit in shared clone
 
   $ echo a >> a