##// 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 10 import config, util, node, error
11 11 hg = None
12 12
13 nullstate = ('', '')
13 nullstate = ('', '', 'empty')
14 14
15 15 def state(ctx):
16 16 p = config.config()
@@ -35,7 +35,13 b' def state(ctx):'
35 35
36 36 state = {}
37 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 46 return state
41 47
@@ -57,7 +63,7 b' def submerge(repo, wctx, mctx, actx):'
57 63
58 64 def debug(s, msg, r=""):
59 65 if r:
60 r = "%s:%s" % r
66 r = "%s:%s:%s" % r
61 67 repo.ui.debug(" subrepo %s: %s %s\n" % (s, msg, r))
62 68
63 69 for s, l in s1.items():
@@ -146,9 +152,9 b' def subrepo(ctx, path):'
146 152
147 153 util.path_auditor(ctx._repo.root)(path)
148 154 state = ctx.substate.get(path, nullstate)
149 if state[0].startswith('['): # future expansion
150 raise error.Abort('unknown subrepo source %s' % state[0])
151 return hgsubrepo(ctx, path, state)
155 if state[2] not in types:
156 raise util.Abort(_('unknown subrepo type %s') % t)
157 return types[state[2]](ctx, path, state[:2])
152 158
153 159 # subrepo classes need to implement the following methods:
154 160 # __init__(self, ctx, path, state)
@@ -205,7 +211,7 b' class hgsubrepo(object):'
205 211 hg.clean(self._repo, node.nullid, False)
206 212
207 213 def _get(self, state):
208 source, revision = state
214 source, revision, kind = state
209 215 try:
210 216 self._repo.lookup(revision)
211 217 except error.RepoError:
@@ -217,7 +223,7 b' class hgsubrepo(object):'
217 223
218 224 def get(self, state):
219 225 self._get(state)
220 source, revision = state
226 source, revision, kind = state
221 227 self._repo.ui.debug("getting subrepo %s\n" % self._path)
222 228 hg.clean(self._repo, revision, False)
223 229
@@ -243,3 +249,7 b' class hgsubrepo(object):'
243 249 dsturl = _abssource(self._repo, True)
244 250 other = hg.repository(self._repo.ui, dsturl)
245 251 self._repo.push(other, force)
252
253 types = {
254 'hg': hgsubrepo,
255 }
@@ -104,3 +104,9 b' cd ../tc'
104 104 hg pull | sed 's/ .*sub/ ...sub/g'
105 105 hg up # should pull t
106 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 57 ancestor 1f14a2e2d3ec local f0d2028bf86d+ remote 1831e14459c4
58 58 .hgsubstate: versions differ -> m
59 59 subrepo merge f0d2028bf86d+ 1831e14459c4 1f14a2e2d3ec
60 subrepo t: other changed, get t:6747d179aa9a688023c4b0cad32e4c92bb7f34ad
60 subrepo t: other changed, get t:6747d179aa9a688023c4b0cad32e4c92bb7f34ad:hg
61 61 getting subrepo t
62 62 resolving manifests
63 63 overwrite True partial False
@@ -79,7 +79,7 b' resolving manifests'
79 79 ancestor 1831e14459c4 local e45c8b14af55+ remote f94576341bcf
80 80 .hgsubstate: versions differ -> m
81 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 83 merging subrepo t
84 84 searching for copies back to rev 2
85 85 resolving manifests
@@ -201,3 +201,5 b' adding file changes'
201 201 added 1 changesets with 1 changes to 1 files
202 202 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
203 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