Show More
@@ -27,8 +27,29 b' from .utils import stringutil' | |||
|
27 | 27 | |
|
28 | 28 | nullstate = (b'', b'', b'empty') |
|
29 | 29 | |
|
30 | if pycompat.TYPE_CHECKING: | |
|
31 | from typing import ( | |
|
32 | Any, | |
|
33 | Dict, | |
|
34 | List, | |
|
35 | Optional, | |
|
36 | Set, | |
|
37 | Tuple, | |
|
38 | ) | |
|
39 | from . import ( | |
|
40 | context, | |
|
41 | localrepo, | |
|
42 | match as matchmod, | |
|
43 | scmutil, | |
|
44 | subrepo, | |
|
45 | ui as uimod, | |
|
46 | ) | |
|
47 | ||
|
48 | Substate = Dict[bytes, Tuple[bytes, bytes, bytes]] | |
|
49 | ||
|
30 | 50 | |
|
31 | 51 | def state(ctx, ui): |
|
52 | # type: (context.changectx, uimod.ui) -> Substate | |
|
32 | 53 | """return a state dict, mapping subrepo paths configured in .hgsub |
|
33 | 54 | to tuple: (source from .hgsub, revision from .hgsubstate, kind |
|
34 | 55 | (key in types dict)) |
@@ -84,6 +105,7 b' def state(ctx, ui):' | |||
|
84 | 105 | raise |
|
85 | 106 | |
|
86 | 107 | def remap(src): |
|
108 | # type: (bytes) -> bytes | |
|
87 | 109 | for pattern, repl in p.items(b'subpaths'): |
|
88 | 110 | # Turn r'C:\foo\bar' into r'C:\\foo\\bar' since re.sub |
|
89 | 111 | # does a string decode. |
@@ -105,7 +127,7 b' def state(ctx, ui):' | |||
|
105 | 127 | return src |
|
106 | 128 | |
|
107 | 129 | state = {} |
|
108 | for path, src in p.items(b''): | |
|
130 | for path, src in p.items(b''): # type: bytes | |
|
109 | 131 | kind = b'hg' |
|
110 | 132 | if src.startswith(b'['): |
|
111 | 133 | if b']' not in src: |
@@ -136,6 +158,7 b' def state(ctx, ui):' | |||
|
136 | 158 | |
|
137 | 159 | |
|
138 | 160 | def writestate(repo, state): |
|
161 | # type: (localrepo.localrepository, Substate) -> None | |
|
139 | 162 | """rewrite .hgsubstate in (outer) repo with these subrepo states""" |
|
140 | 163 | lines = [ |
|
141 | 164 | b'%s %s\n' % (state[s][1], s) |
@@ -146,6 +169,8 b' def writestate(repo, state):' | |||
|
146 | 169 | |
|
147 | 170 | |
|
148 | 171 | def submerge(repo, wctx, mctx, actx, overwrite, labels=None): |
|
172 | # type: (localrepo.localrepository, context.workingctx, context.changectx, context.changectx, bool, Optional[Any]) -> Substate | |
|
173 | # TODO: type the `labels` arg | |
|
149 | 174 | """delegated from merge.applyupdates: merging of .hgsubstate file |
|
150 | 175 | in working context, merging context and ancestor context""" |
|
151 | 176 | if mctx == actx: # backwards? |
@@ -285,6 +310,7 b' def submerge(repo, wctx, mctx, actx, ove' | |||
|
285 | 310 | |
|
286 | 311 | |
|
287 | 312 | def precommit(ui, wctx, status, match, force=False): |
|
313 | # type: (uimod.ui, context.workingcommitctx, scmutil.status, matchmod.basematcher, bool) -> Tuple[List[bytes], Set[bytes], Substate] | |
|
288 | 314 | """Calculate .hgsubstate changes that should be applied before committing |
|
289 | 315 | |
|
290 | 316 | Returns (subs, commitsubs, newstate) where |
@@ -355,6 +381,7 b' def precommit(ui, wctx, status, match, f' | |||
|
355 | 381 | |
|
356 | 382 | |
|
357 | 383 | def reporelpath(repo): |
|
384 | # type: (localrepo.localrepository) -> bytes | |
|
358 | 385 | """return path to this (sub)repo as seen from outermost repo""" |
|
359 | 386 | parent = repo |
|
360 | 387 | while util.safehasattr(parent, b'_subparent'): |
@@ -363,11 +390,13 b' def reporelpath(repo):' | |||
|
363 | 390 | |
|
364 | 391 | |
|
365 | 392 | def subrelpath(sub): |
|
393 | # type: (subrepo.abstractsubrepo) -> bytes | |
|
366 | 394 | """return path to this subrepo as seen from outermost repo""" |
|
367 | 395 | return sub._relpath |
|
368 | 396 | |
|
369 | 397 | |
|
370 | 398 | def _abssource(repo, push=False, abort=True): |
|
399 | # type: (localrepo.localrepository, bool, bool) -> Optional[bytes] | |
|
371 | 400 | """return pull/push path of repo - either based on parent repo .hgsub info |
|
372 | 401 | or on the top repo config. Abort or return None if no source found.""" |
|
373 | 402 | if util.safehasattr(repo, b'_subparent'): |
@@ -416,6 +445,7 b' def _abssource(repo, push=False, abort=T' | |||
|
416 | 445 | |
|
417 | 446 | |
|
418 | 447 | def newcommitphase(ui, ctx): |
|
448 | # type: (uimod.ui, context.changectx) -> int | |
|
419 | 449 | commitphase = phases.newcommitphase(ui) |
|
420 | 450 | substate = getattr(ctx, "substate", None) |
|
421 | 451 | if not substate: |
General Comments 0
You need to be logged in to leave comments.
Login now