# HG changeset patch # User Matt Harbison # Date 1354067787 18000 # Node ID f254ab6207aedf3445e5497b3d5fdb0268ce1eb1 # Parent 21daee53c10109e898fb9bb73bf07e0eacf79521 subrepo: use sharepath if available when locating the source repo This is an alternative fix for issue3518, enabling sharing of repositories with subrepos, without unconditionally setting the default path in the resulting repo's hgrc file. Better test coverage is added here, but won't prove this code is working until fd903f89e42b is backed out. The problem with the original fix is, if a default path is not available to be copied over from the share source, the default path on the resulting repo is set to the source location. Since that's where the actual repository is stored, the path is essentially self-referential, so push, pull, incoming and outgoing effectively operate on itself. While incoming and outgoing make it look like nothing was changed, push currently hangs (see issue3657). In this case where there is not a real default path, these operations should abort with "default(-push) not found", like the source repo would. Note this problem with the original fix affected repos without subrepos too. diff -r 21daee53c101 -r f254ab6207ae mercurial/subrepo.py --- a/mercurial/subrepo.py Tue Jan 22 14:33:17 2013 +0100 +++ b/mercurial/subrepo.py Tue Nov 27 20:56:27 2012 -0500 @@ -264,6 +264,9 @@ return repo.ui.config('paths', 'default-push') if repo.ui.config('paths', 'default'): return repo.ui.config('paths', 'default') + if repo.sharedpath != repo.path: + # chop off the .hg component to get the default path form + return os.path.dirname(repo.sharedpath) if abort: raise util.Abort(_("default path for subrepository not found")) diff -r 21daee53c101 -r f254ab6207ae tests/test-subrepo.t --- a/tests/test-subrepo.t Tue Jan 22 14:33:17 2013 +0100 +++ b/tests/test-subrepo.t Tue Nov 27 20:56:27 2012 -0500 @@ -725,6 +725,19 @@ 2 files updated, 0 files merged, 0 files removed, 0 files unresolved $ test -f ../shared/subrepo-1/.hg/sharedpath [1] + $ hg -R ../shared in + comparing with $TESTTMP/subrepo-status (glob) + searching for changes + no changes found + [1] + $ hg -R ../shared/subrepo-2 showconfig paths + paths.default=$TESTTMP/subrepo-status/subrepo-2 + $ hg -R ../shared/subrepo-1 sum --remote + parent: -1:000000000000 tip (empty repository) + branch: default + commit: (clean) + update: (current) + remote: (synced) Check hg update --clean $ cd $TESTTMP/t