##// END OF EJS Templates
subrepo: add table-based dispatch for subrepo types
Augie Fackler -
r10177:5ca0d220 default
parent child Browse files
Show More
@@ -10,7 +10,7 b' from i18n import _'
10 import config, util, node, error
10 import config, util, node, error
11 hg = None
11 hg = None
12
12
13 nullstate = ('', '')
13 nullstate = ('', '', 'empty')
14
14
15 def state(ctx):
15 def state(ctx):
16 p = config.config()
16 p = config.config()
@@ -35,7 +35,13 b' def state(ctx):'
35
35
36 state = {}
36 state = {}
37 for path, src in p[''].items():
37 for path, src in p[''].items():
38 state[path] = (src, rev.get(path, ''))
38 kind = 'hg'
39 if src.startswith('['):
40 if ']' not in src:
41 raise util.Abort(_('missing ] in subrepo source'))
42 kind, src = src.split(']', 1)
43 kind = kind[1:]
44 state[path] = (src, rev.get(path, ''), kind)
39
45
40 return state
46 return state
41
47
@@ -57,7 +63,7 b' def submerge(repo, wctx, mctx, actx):'
57
63
58 def debug(s, msg, r=""):
64 def debug(s, msg, r=""):
59 if r:
65 if r:
60 r = "%s:%s" % r
66 r = "%s:%s:%s" % r
61 repo.ui.debug(" subrepo %s: %s %s\n" % (s, msg, r))
67 repo.ui.debug(" subrepo %s: %s %s\n" % (s, msg, r))
62
68
63 for s, l in s1.items():
69 for s, l in s1.items():
@@ -146,9 +152,9 b' def subrepo(ctx, path):'
146
152
147 util.path_auditor(ctx._repo.root)(path)
153 util.path_auditor(ctx._repo.root)(path)
148 state = ctx.substate.get(path, nullstate)
154 state = ctx.substate.get(path, nullstate)
149 if state[0].startswith('['): # future expansion
155 if state[2] not in types:
150 raise error.Abort('unknown subrepo source %s' % state[0])
156 raise util.Abort(_('unknown subrepo type %s') % t)
151 return hgsubrepo(ctx, path, state)
157 return types[state[2]](ctx, path, state[:2])
152
158
153 # subrepo classes need to implement the following methods:
159 # subrepo classes need to implement the following methods:
154 # __init__(self, ctx, path, state)
160 # __init__(self, ctx, path, state)
@@ -205,7 +211,7 b' class hgsubrepo(object):'
205 hg.clean(self._repo, node.nullid, False)
211 hg.clean(self._repo, node.nullid, False)
206
212
207 def _get(self, state):
213 def _get(self, state):
208 source, revision = state
214 source, revision, kind = state
209 try:
215 try:
210 self._repo.lookup(revision)
216 self._repo.lookup(revision)
211 except error.RepoError:
217 except error.RepoError:
@@ -217,7 +223,7 b' class hgsubrepo(object):'
217
223
218 def get(self, state):
224 def get(self, state):
219 self._get(state)
225 self._get(state)
220 source, revision = state
226 source, revision, kind = state
221 self._repo.ui.debug("getting subrepo %s\n" % self._path)
227 self._repo.ui.debug("getting subrepo %s\n" % self._path)
222 hg.clean(self._repo, revision, False)
228 hg.clean(self._repo, revision, False)
223
229
@@ -243,3 +249,7 b' class hgsubrepo(object):'
243 dsturl = _abssource(self._repo, True)
249 dsturl = _abssource(self._repo, True)
244 other = hg.repository(self._repo.ui, dsturl)
250 other = hg.repository(self._repo.ui, dsturl)
245 self._repo.push(other, force)
251 self._repo.push(other, force)
252
253 types = {
254 'hg': hgsubrepo,
255 }
@@ -104,3 +104,9 b' cd ../tc'
104 hg pull | sed 's/ .*sub/ ...sub/g'
104 hg pull | sed 's/ .*sub/ ...sub/g'
105 hg up # should pull t
105 hg up # should pull t
106 cat t/t
106 cat t/t
107
108 echo % bogus subrepo path aborts
109 echo 'bogus=[boguspath' >> .hgsub
110 hg ci -m 'bogus subrepo path'
111
112 exit 0
@@ -57,7 +57,7 b' resolving manifests'
57 ancestor 1f14a2e2d3ec local f0d2028bf86d+ remote 1831e14459c4
57 ancestor 1f14a2e2d3ec local f0d2028bf86d+ remote 1831e14459c4
58 .hgsubstate: versions differ -> m
58 .hgsubstate: versions differ -> m
59 subrepo merge f0d2028bf86d+ 1831e14459c4 1f14a2e2d3ec
59 subrepo merge f0d2028bf86d+ 1831e14459c4 1f14a2e2d3ec
60 subrepo t: other changed, get t:6747d179aa9a688023c4b0cad32e4c92bb7f34ad
60 subrepo t: other changed, get t:6747d179aa9a688023c4b0cad32e4c92bb7f34ad:hg
61 getting subrepo t
61 getting subrepo t
62 resolving manifests
62 resolving manifests
63 overwrite True partial False
63 overwrite True partial False
@@ -79,7 +79,7 b' resolving manifests'
79 ancestor 1831e14459c4 local e45c8b14af55+ remote f94576341bcf
79 ancestor 1831e14459c4 local e45c8b14af55+ remote f94576341bcf
80 .hgsubstate: versions differ -> m
80 .hgsubstate: versions differ -> m
81 subrepo merge e45c8b14af55+ f94576341bcf 1831e14459c4
81 subrepo merge e45c8b14af55+ f94576341bcf 1831e14459c4
82 subrepo t: both sides changed, merge with t:7af322bc1198a32402fe903e0b7ebcfc5c9bf8f4
82 subrepo t: both sides changed, merge with t:7af322bc1198a32402fe903e0b7ebcfc5c9bf8f4:hg
83 merging subrepo t
83 merging subrepo t
84 searching for copies back to rev 2
84 searching for copies back to rev 2
85 resolving manifests
85 resolving manifests
@@ -201,3 +201,5 b' adding file changes'
201 added 1 changesets with 1 changes to 1 files
201 added 1 changesets with 1 changes to 1 files
202 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
202 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
203 blah
203 blah
204 % bogus subrepo path aborts
205 abort: missing ] in subrepo source
General Comments 0
You need to be logged in to leave comments. Login now