[PATCH STABLE?] share: allow trailing newline on .hg/sharedpath
Greg Ward
greg-hg at gerg.ca
Wed Sep 14 21:29:34 CDT 2011
# HG changeset patch
# User Greg Ward <greg at gerg.ca>
# Date 1316053707 14400
# Node ID d2c9c1c55130c92cc86a810ad4d19eb690461769
# Parent edf7ae547b0e475936831fb8459c850d13b2d310
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.
diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -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)
diff --git a/tests/test-share.t b/tests/test-share.t
--- a/tests/test-share.t
+++ b/tests/test-share.t
@@ -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
More information about the Mercurial-devel
mailing list