[PATCH 1 of 2] subrepo: subrepo does not get config from subparent repo (1/3)
Simon Heimberg
simohe at besonet.ch
Sat Jul 28 11:37:51 CDT 2012
# HG changeset patch
# User Simon Heimberg <simohe at besonet.ch>
# Date 1343492444 -7200
# Branch stable
# Node ID 586d3bf61bd66bb7a504b08db3cc88f4160d45d9
# Parent d11c193a798626be1a205b4f69e019d98d5836ce
subrepo: subrepo does not get config from subparent repo (1/3)
part one, fix the cases with calling repo.baseui instead of repo.ui
and add a new test for testing this with hooks in subrepos
the new test still fails
diff -r d11c193a7986 -r 586d3bf61bd6 mercurial/commands.py
--- a/mercurial/commands.py Sam Jul 28 18:20:06 2012 +0200
+++ b/mercurial/commands.py Sam Jul 28 18:20:44 2012 +0200
@@ -1254,6 +1254,7 @@
if opts.get('subrepos'):
# Let --subrepos on the command line overide config setting.
ui.setconfig('ui', 'commitsubrepos', True)
+ repo.baseui.setconfig('ui', 'commitsubrepos', True)
extra = {}
if opts.get('close_branch'):
diff -r d11c193a7986 -r 586d3bf61bd6 mercurial/subrepo.py
--- a/mercurial/subrepo.py Sam Jul 28 18:20:06 2012 +0200
+++ b/mercurial/subrepo.py Sam Jul 28 18:20:44 2012 +0200
@@ -395,7 +395,7 @@
if not os.path.exists(os.path.join(root, '.hg')):
create = True
util.makedirs(root)
- self._repo = hg.repository(r.ui, root, create=create)
+ self._repo = hg.repository(r.baseui, root, create=create)
self._initrepo(r, state[0], create)
def _initrepo(self, parentrepo, source, create):
@@ -497,7 +497,7 @@
if revision not in self._repo:
self._repo._subsource = source
srcurl = _abssource(self._repo)
- other = hg.peer(self._repo.ui, {}, srcurl)
+ other = hg.peer(self._repo.baseui, {}, srcurl)
if len(self._repo) == 0:
self._repo.ui.status(_('cloning subrepo %s from %s\n')
% (subrelpath(self), srcurl))
diff -r d11c193a7986 -r 586d3bf61bd6 tests/test-hook-subrepo.t
--- /dev/null Don Jan 01 00:00:00 1970 +0000
+++ b/tests/test-hook-subrepo.t Sam Jul 28 18:20:44 2012 +0200
@@ -0,0 +1,240 @@
+
+ $ cat >> $HGRCPATH << EOF
+ >
+ > [hooks]
+ > changegroup.g = python:$TESTTMP/test_hook.py:on_changegroup
+ > incoming.g = echo _ incoming hooks in \`pwd\`:
+ > outgoing.g = echo _ outgoing hooks in \`pwd\`:
+ > commit.g = echo _ commit hooks in \`pwd\`:
+ > tag.g = echo _ tag hooks in \`pwd\`:
+ > update.g = echo _ update hooks in \`pwd\`:
+ > EOF
+
+ $ cat > test_hook.py << EOF
+ > def on_changegroup(ui, repo, hooktype=None, node=None, url=None,
+ > source=None):
+ > t = "$TESTTMP" # this is replaced by the shell
+ > lt = len(t)
+ > uif = set(f.split(":", 1)[0] for f in ui._tcfg._source.values())
+ > uif = list(uif)
+ > for i, f in enumerate(uif):
+ > if f.startswith(t):
+ > uif[i] = "@t" + f[lt:]
+ > elif f == "$HGRCPATH":
+ > uif[i] = "@g"
+ > uif.sort()
+ > ui.write("_ changegroup hooks in repo %s:\n uif=%s\n" %
+ > (repo.root, uif))
+ > EOF
+
+create 1st repo with hooks
+ $ hg init r1
+ $ cd r1
+ $ cat > .hg/hgrc << EOF
+ >
+ > [hooks]
+ > changegroup.r1 = echo . h.r1
+ > incoming.r1 = echo . h.r1.i
+ > outgoing.r1 = echo . h.r1.o
+ > commit.r1 = echo . h.r1.ci
+ > tag.r1 = echo . h.r1.t
+ > update.r1 = echo . h.r1.u
+ > EOF
+
+ $ hg init s
+ $ sed s/.r1/.sr1/g .hg/hgrc > s/.hg/hgrc
+
+add subrepo
+ $ echo s=s > .hgsub
+ $ hg add .hgsub
+ $ hg ci -m "add s1"
+ _ commit hooks in $TESTTMP/r1:
+ . h.r1.ci
+
+create clone and add hooks
+ $ hg clone . ../r2
+ _ outgoing hooks in $TESTTMP/r1:
+ . h.r1.o
+ updating to branch default
+ _ update hooks in $TESTTMP/r2/s:
+ _ update hooks in $TESTTMP/r2:
+ 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
+ repo hooks not yet defined
+
+ $ cd ../r2
+ $ sed s/.r1/.r2/g ../r1/.hg/hgrc >> .hg/hgrc
+
+ $ sed s/.r1/.sr2a/g ../r1/.hg/hgrc >> s/.hg/hgrc
+
+add file in subrepo
+ $ cd ../r1
+ $ echo 1 >> s/f1
+ $ hg add s/f1
+ $ hg ci -Am "add f1" --subrepos
+ committing subrepository s
+ _ commit hooks in $TESTTMP/r1/s:
+ . h.sr1.ci
+ _ commit hooks in $TESTTMP/r1:
+ . h.r1.ci
+
+pull and update
+ $ cd ../r2
+ $ hg pull
+ pulling from $TESTTMP/r1
+ searching for changes
+ adding changesets
+ _ outgoing hooks in $TESTTMP/r1:
+ . h.r1.o
+ adding manifests
+ adding file changes
+ added 1 changesets with 1 changes to 1 files
+ _ changegroup hooks in repo $TESTTMP/r2:
+ uif=['', '@g', '@t/r2/.hg/hgrc']
+ . h.r2
+ _ incoming hooks in $TESTTMP/r2:
+ . h.r2.i
+ (run 'hg update' to get a working copy)
+
+ $ hg up
+ cloning subrepo s from $TESTTMP/r1/s
+ _ outgoing hooks in $TESTTMP/r1/s:
+ . h.sr1.o
+ _ update hooks in $TESTTMP/r2/s:
+ _ update hooks in $TESTTMP/r2:
+ . h.r2.u
+ 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+ no chg hook because there was no subrepo
+
+check clone overwrote hook and write new one
+ $ grep changegroup s/.hg/hgrc || true
+
+ $ sed s/.r1/.sr2/g ../r1/.hg/hgrc >> s/.hg/hgrc
+
+change file
+ $ cd ../r1
+ $ echo 11 >> s/f1
+ $ hg ci -m L11 --subrepo
+ committing subrepository s
+ _ commit hooks in $TESTTMP/r1/s:
+ . h.sr1.ci
+ _ commit hooks in $TESTTMP/r1:
+ . h.r1.ci
+
+push and update
+ $ hg push ../r2
+ pushing to ../r2
+ pushing subrepo s to ../r2/s
+ searching for changes
+ adding changesets
+ _ outgoing hooks in $TESTTMP/r1/s:
+ . h.sr1.o
+ adding manifests
+ adding file changes
+ added 1 changesets with 1 changes to 1 files
+ _ changegroup hooks in repo $TESTTMP/r2/s:
+ uif=['', '@g', '@t/r2/s/.hg/hgrc']
+ . h.sr2
+ _ incoming hooks in $TESTTMP/r2/s:
+ . h.sr2.i
+ searching for changes
+ adding changesets
+ _ outgoing hooks in $TESTTMP/r1:
+ . h.r1.o
+ adding manifests
+ adding file changes
+ added 1 changesets with 1 changes to 1 files
+ _ changegroup hooks in repo $TESTTMP/r2:
+ uif=['', '@g', '@t/r2/.hg/hgrc']
+ . h.r2
+ _ incoming hooks in $TESTTMP/r2:
+ . h.r2.i
+
+ $ hg up -R ../r2
+ _ update hooks in $TESTTMP/r2/s:
+ . h.sr2.u
+ _ update hooks in $TESTTMP/r2:
+ . h.r2.u
+ 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+
+3rd line to file
+ $ cd ../r1
+ $ echo 111 >> s/f1
+ $ hg ci -m L111 --subrepo
+ committing subrepository s
+ _ commit hooks in $TESTTMP/r1/s:
+ . h.sr1.ci
+ _ commit hooks in $TESTTMP/r1:
+ . h.r1.ci
+
+
+pull and update - subrepo exists
+ $ cd ../r2
+ $ hg pull
+ pulling from $TESTTMP/r1
+ searching for changes
+ adding changesets
+ _ outgoing hooks in $TESTTMP/r1:
+ . h.r1.o
+ adding manifests
+ adding file changes
+ added 1 changesets with 1 changes to 1 files
+ _ changegroup hooks in repo $TESTTMP/r2:
+ uif=['', '@g', '@t/r2/.hg/hgrc']
+ . h.r2
+ _ incoming hooks in $TESTTMP/r2:
+ . h.r2.i
+ (run 'hg update' to get a working copy)
+
+ $ hg up
+ pulling subrepo s from $TESTTMP/r1/s
+ searching for changes
+ adding changesets
+ _ outgoing hooks in $TESTTMP/r1/s:
+ . h.sr1.o
+ adding manifests
+ adding file changes
+ added 1 changesets with 1 changes to 1 files
+ _ changegroup hooks in repo $TESTTMP/r2/s:
+ uif=['', '@g', '@t/r2/s/.hg/hgrc']
+ . h.sr2
+ _ incoming hooks in $TESTTMP/r2/s:
+ . h.sr2.i
+ _ update hooks in $TESTTMP/r2/s:
+ . h.sr2.u
+ _ update hooks in $TESTTMP/r2:
+ . h.r2.u
+ 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+
+add and push tags
+ $ cd ../r1/s
+ $ hg tag t_in_s
+ _ tag hooks in $TESTTMP/r1/s:
+ . h.sr1.t
+ _ commit hooks in $TESTTMP/r1/s:
+ . h.sr1.ci
+
+ $ cd ..
+ $ hg tag t
+ _ tag hooks in $TESTTMP/r1:
+ . h.r1.t
+ _ commit hooks in $TESTTMP/r1:
+ . h.r1.ci
+
+ $ cd ../r2
+ $ hg pull -u
+ pulling from $TESTTMP/r1
+ searching for changes
+ adding changesets
+ _ outgoing hooks in $TESTTMP/r1:
+ . h.r1.o
+ adding manifests
+ adding file changes
+ added 1 changesets with 1 changes to 1 files
+ _ changegroup hooks in repo $TESTTMP/r2:
+ uif=['', '@g', '@t/r2/.hg/hgrc']
+ . h.r2
+ _ incoming hooks in $TESTTMP/r2:
+ . h.r2.i
+ _ update hooks in $TESTTMP/r2:
+ . h.r2.u
+ 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
More information about the Mercurial-devel
mailing list