##// END OF EJS Templates
subrepo: docstrings
Mads Kiilerich -
r11571:636554d5 stable
parent child Browse files
Show More
@@ -13,6 +13,10 b' hg = None'
13 nullstate = ('', '', 'empty')
13 nullstate = ('', '', 'empty')
14
14
15 def state(ctx):
15 def state(ctx):
16 """return a state dict, mapping subrepo paths configured in .hgsub
17 to tuple: (source from .hgsub, revision from .hgsubstate, kind
18 (key in types dict))
19 """
16 p = config.config()
20 p = config.config()
17 def read(f, sections=None, remap=None):
21 def read(f, sections=None, remap=None):
18 if f in ctx:
22 if f in ctx:
@@ -46,12 +50,14 b' def state(ctx):'
46 return state
50 return state
47
51
48 def writestate(repo, state):
52 def writestate(repo, state):
53 """rewrite .hgsubstate in (outer) repo with these subrepo states"""
49 repo.wwrite('.hgsubstate',
54 repo.wwrite('.hgsubstate',
50 ''.join(['%s %s\n' % (state[s][1], s)
55 ''.join(['%s %s\n' % (state[s][1], s)
51 for s in sorted(state)]), '')
56 for s in sorted(state)]), '')
52
57
53 def submerge(repo, wctx, mctx, actx):
58 def submerge(repo, wctx, mctx, actx):
54 # working context, merging context, ancestor context
59 """delegated from merge.applyupdates: merging of .hgsubstate file
60 in working context, merging context and ancestor context"""
55 if mctx == actx: # backwards?
61 if mctx == actx: # backwards?
56 actx = wctx.p1()
62 actx = wctx.p1()
57 s1 = wctx.substate
63 s1 = wctx.substate
@@ -131,6 +137,7 b' def submerge(repo, wctx, mctx, actx):'
131 writestate(repo, sm)
137 writestate(repo, sm)
132
138
133 def relpath(sub):
139 def relpath(sub):
140 """return path to this subrepo as seen from outermost repo"""
134 if not hasattr(sub, '_repo'):
141 if not hasattr(sub, '_repo'):
135 return sub._path
142 return sub._path
136 parent = sub._repo
143 parent = sub._repo
@@ -139,6 +146,8 b' def relpath(sub):'
139 return sub._repo.root[len(parent.root)+1:]
146 return sub._repo.root[len(parent.root)+1:]
140
147
141 def _abssource(repo, push=False):
148 def _abssource(repo, push=False):
149 """return pull/push path of repo - either based on parent repo
150 .hgsub info or on the subrepos own config"""
142 if hasattr(repo, '_subparent'):
151 if hasattr(repo, '_subparent'):
143 source = repo._subsource
152 source = repo._subsource
144 if source.startswith('/') or '://' in source:
153 if source.startswith('/') or '://' in source:
@@ -158,6 +167,7 b' def _abssource(repo, push=False):'
158 return repo.ui.config('paths', 'default', repo.root)
167 return repo.ui.config('paths', 'default', repo.root)
159
168
160 def subrepo(ctx, path):
169 def subrepo(ctx, path):
170 """return instance of the right subrepo class for subrepo in path"""
161 # subrepo inherently violates our import layering rules
171 # subrepo inherently violates our import layering rules
162 # because it wants to make repo objects from deep inside the stack
172 # because it wants to make repo objects from deep inside the stack
163 # so we manually delay the circular imports to not break
173 # so we manually delay the circular imports to not break
@@ -184,7 +194,7 b' def subrepo(ctx, path):'
184 # get(self, state): run whatever commands are needed to put the
194 # get(self, state): run whatever commands are needed to put the
185 # subrepo into this state
195 # subrepo into this state
186 # merge(self, state): merge currently-saved state with the new state.
196 # merge(self, state): merge currently-saved state with the new state.
187 # push(self, force): perform whatever action is analagous to 'hg push'
197 # push(self, force): perform whatever action is analogous to 'hg push'
188 # This may be a no-op on some systems.
198 # This may be a no-op on some systems.
189
199
190 class hgsubrepo(object):
200 class hgsubrepo(object):
General Comments 0
You need to be logged in to leave comments. Login now