--- a/mercurial/hg.py Thu Nov 15 22:24:36 2012 -0800
+++ b/mercurial/hg.py Fri Nov 16 10:01:26 2012 -0600
@@ -171,11 +171,14 @@
r = repository(ui, root)
default = srcrepo.ui.config('paths', 'default')
- if default:
- fp = r.opener("hgrc", "w", text=True)
- fp.write("[paths]\n")
- fp.write("default = %s\n" % default)
- fp.close()
+ if not default:
+ # set default to source for being able to clone subrepos
+ default = os.path.abspath(util.urllocalpath(origsource))
+ fp = r.opener("hgrc", "w", text=True)
+ fp.write("[paths]\n")
+ fp.write("default = %s\n" % default)
+ fp.close()
+ r.ui.setconfig('paths', 'default', default)
if update:
r.ui.status(_("updating working directory\n"))
--- a/mercurial/scmutil.py Thu Nov 15 22:24:36 2012 -0800
+++ b/mercurial/scmutil.py Fri Nov 16 10:01:26 2012 -0600
@@ -279,37 +279,38 @@
mode += "b" # for that other OS
nlink = -1
- dirname, basename = util.split(f)
- # If basename is empty, then the path is malformed because it points
- # to a directory. Let the posixfile() call below raise IOError.
- if basename and mode not in ('r', 'rb'):
- if atomictemp:
- if not os.path.isdir(dirname):
- util.makedirs(dirname, self.createmode)
- return util.atomictempfile(f, mode, self.createmode)
- try:
- if 'w' in mode:
- util.unlink(f)
+ if mode not in ('r', 'rb'):
+ dirname, basename = util.split(f)
+ # If basename is empty, then the path is malformed because it points
+ # to a directory. Let the posixfile() call below raise IOError.
+ if basename:
+ if atomictemp:
+ if not os.path.isdir(dirname):
+ util.makedirs(dirname, self.createmode)
+ return util.atomictempfile(f, mode, self.createmode)
+ try:
+ if 'w' in mode:
+ util.unlink(f)
+ nlink = 0
+ else:
+ # nlinks() may behave differently for files on Windows
+ # shares if the file is open.
+ fd = util.posixfile(f)
+ nlink = util.nlinks(f)
+ if nlink < 1:
+ nlink = 2 # force mktempcopy (issue1922)
+ fd.close()
+ except (OSError, IOError), e:
+ if e.errno != errno.ENOENT:
+ raise
nlink = 0
- else:
- # nlinks() may behave differently for files on Windows
- # shares if the file is open.
- fd = util.posixfile(f)
- nlink = util.nlinks(f)
- if nlink < 1:
- nlink = 2 # force mktempcopy (issue1922)
- fd.close()
- except (OSError, IOError), e:
- if e.errno != errno.ENOENT:
- raise
- nlink = 0
- if not os.path.isdir(dirname):
- util.makedirs(dirname, self.createmode)
- if nlink > 0:
- if self._trustnlink is None:
- self._trustnlink = nlink > 1 or util.checknlink(f)
- if nlink > 1 or not self._trustnlink:
- util.rename(util.mktempcopy(f), f)
+ if not os.path.isdir(dirname):
+ util.makedirs(dirname, self.createmode)
+ if nlink > 0:
+ if self._trustnlink is None:
+ self._trustnlink = nlink > 1 or util.checknlink(f)
+ if nlink > 1 or not self._trustnlink:
+ util.rename(util.mktempcopy(f), f)
fp = util.posixfile(f, mode)
if nlink == 0:
self._fixfilemode(f)
--- a/tests/run-tests.py Thu Nov 15 22:24:36 2012 -0800
+++ b/tests/run-tests.py Fri Nov 16 10:01:26 2012 -0600
@@ -768,13 +768,18 @@
True -> passed
False -> failed'''
- global results, iolock
+ global results, resultslock, iolock
testpath = os.path.join(TESTDIR, test)
+ def result(l, e):
+ resultslock.acquire()
+ results[l].append(e)
+ resultslock.release()
+
def skip(msg):
if not options.verbose:
- results['s'].append((test, msg))
+ result('s', (test, msg))
else:
iolock.acquire()
print "\nSkipping %s: %s" % (testpath, msg)
@@ -797,15 +802,15 @@
rename(testpath + ".err", testpath)
else:
rename(testpath + ".err", testpath + ".out")
- success(test)
+ result('p', test)
return
- results['f'].append((test, msg))
+ result('f', (test, msg))
def success():
- results['p'].append(test)
+ result('p', test)
def ignore(msg):
- results['i'].append((test, msg))
+ result('i', (test, msg))
if (os.path.basename(test).startswith("test-") and '~' not in test and
('.' not in test or test.endswith('.py') or
@@ -1118,6 +1123,7 @@
sys.exit(failures != 0)
results = dict(p=[], f=[], s=[], i=[])
+resultslock = threading.Lock()
times = []
iolock = threading.Lock()
--- a/tests/test-subrepo.t Thu Nov 15 22:24:36 2012 -0800
+++ b/tests/test-subrepo.t Fri Nov 16 10:01:26 2012 -0600
@@ -718,6 +718,14 @@
committing subrepository subrepo-2
$ hg st subrepo-2/file
+Check that share works with subrepo
+ $ hg --config extensions.share= share . ../shared
+ updating working directory
+ cloning subrepo subrepo-2 from $TESTTMP/subrepo-status/subrepo-2
+ 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
+ $ test -f ../shared/subrepo-1/.hg/sharedpath
+ [1]
+
Check hg update --clean
$ cd $TESTTMP/t
$ rm -r t/t.orig