##// END OF EJS Templates
subrepo: abort instead of pushing/pulling to the repo itself...
Mads Kiilerich -
r12753:ef5eaf53 default
parent child Browse files
Show More
@@ -167,26 +167,33 b' def subrelpath(sub):'
167 return sub._path
167 return sub._path
168 return reporelpath(sub._repo)
168 return reporelpath(sub._repo)
169
169
170 def _abssource(repo, push=False):
170 def _abssource(repo, push=False, abort=True):
171 """return pull/push path of repo - either based on parent repo
171 """return pull/push path of repo - either based on parent repo .hgsub info
172 .hgsub info or on the subrepos own config"""
172 or on the top repo config. Abort or return None if no source found."""
173 if hasattr(repo, '_subparent'):
173 if hasattr(repo, '_subparent'):
174 source = repo._subsource
174 source = repo._subsource
175 if source.startswith('/') or '://' in source:
175 if source.startswith('/') or '://' in source:
176 return source
176 return source
177 parent = _abssource(repo._subparent, push)
177 parent = _abssource(repo._subparent, push, abort=False)
178 if '://' in parent:
178 if parent:
179 if parent[-1] == '/':
179 if '://' in parent:
180 parent = parent[:-1]
180 if parent[-1] == '/':
181 r = urlparse.urlparse(parent + '/' + source)
181 parent = parent[:-1]
182 r = urlparse.urlunparse((r[0], r[1],
182 r = urlparse.urlparse(parent + '/' + source)
183 posixpath.normpath(r[2]),
183 r = urlparse.urlunparse((r[0], r[1],
184 r[3], r[4], r[5]))
184 posixpath.normpath(r[2]),
185 return r
185 r[3], r[4], r[5]))
186 return posixpath.normpath(os.path.join(parent, repo._subsource))
186 return r
187 if push and repo.ui.config('paths', 'default-push'):
187 else: # plain file system path
188 return repo.ui.config('paths', 'default-push', repo.root)
188 return posixpath.normpath(os.path.join(parent, repo._subsource))
189 return repo.ui.config('paths', 'default', repo.root)
189 else: # recursion reached top repo
190 if push and repo.ui.config('paths', 'default-push'):
191 return repo.ui.config('paths', 'default-push')
192 if repo.ui.config('paths', 'default'):
193 return repo.ui.config('paths', 'default')
194 if abort:
195 raise util.Abort(_("default path for subrepository %s not found") %
196 reporelpath(repo))
190
197
191 def itersubrepos(ctx1, ctx2):
198 def itersubrepos(ctx1, ctx2):
192 """find subrepos in ctx1 or ctx2"""
199 """find subrepos in ctx1 or ctx2"""
@@ -314,11 +321,12 b' class hgsubrepo(abstractsubrepo):'
314 fp.write('[paths]\n')
321 fp.write('[paths]\n')
315
322
316 def addpathconfig(key, value):
323 def addpathconfig(key, value):
317 fp.write('%s = %s\n' % (key, value))
324 if value:
318 self._repo.ui.setconfig('paths', key, value)
325 fp.write('%s = %s\n' % (key, value))
326 self._repo.ui.setconfig('paths', key, value)
319
327
320 defpath = _abssource(self._repo)
328 defpath = _abssource(self._repo, abort=False)
321 defpushpath = _abssource(self._repo, True)
329 defpushpath = _abssource(self._repo, True, abort=False)
322 addpathconfig('default', defpath)
330 addpathconfig('default', defpath)
323 if defpath != defpushpath:
331 if defpath != defpushpath:
324 addpathconfig('default-push', defpushpath)
332 addpathconfig('default-push', defpushpath)
@@ -585,3 +585,64 b' Issue1977: multirepo push should fail if'
585 $ hg -R repo update
585 $ hg -R repo update
586 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
586 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
587 $ rm -rf repo2 repo
587 $ rm -rf repo2 repo
588
589
590 Issue1852 subrepos with relative paths always push/pull relative to default
591
592 Prepare a repo with subrepo
593
594 $ hg init issue1852a
595 $ cd issue1852a
596 $ hg init sub/repo
597 $ echo test > sub/repo/foo
598 $ hg -R sub/repo add sub/repo/foo
599 $ echo sub/repo = sub/repo > .hgsub
600 $ hg add .hgsub
601 $ hg ci -mtest
602 committing subrepository sub/repo
603 $ echo test >> sub/repo/foo
604 $ hg ci -mtest
605 committing subrepository sub/repo
606 $ cd ..
607
608 Create repo without default path, pull top repo, and see what happens on update
609
610 $ hg init issue1852b
611 $ hg -R issue1852b pull issue1852a
612 pulling from issue1852a
613 requesting all changes
614 adding changesets
615 adding manifests
616 adding file changes
617 added 2 changesets with 3 changes to 2 files
618 (run 'hg update' to get a working copy)
619 $ hg -R issue1852b update
620 abort: default path for subrepository sub/repo not found
621 [255]
622
623 Pull -u now doesn't help
624
625 $ hg -R issue1852b pull -u issue1852a
626 pulling from issue1852a
627 searching for changes
628 no changes found
629
630 Try the same, but with pull -u
631
632 $ hg init issue1852c
633 $ hg -R issue1852c pull -r0 -u issue1852a
634 pulling from issue1852a
635 requesting all changes
636 adding changesets
637 adding manifests
638 adding file changes
639 added 1 changesets with 2 changes to 2 files
640 abort: default path for subrepository sub/repo not found
641 [255]
642
643 Try to push from the other side
644
645 $ hg -R issue1852a push issue1852c
646 pushing to issue1852c
647 abort: default path for subrepository sub/repo not found
648 [255]
General Comments 0
You need to be logged in to leave comments. Login now