Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/subrepo.py @ 35184:ee64e677c3cf
merge with stable
author | Augie Fackler <augie@google.com> |
---|---|
date | Thu, 30 Nov 2017 15:48:42 -0500 |
parents | 3da4bd50103d 5c6b96b832c2 |
children | c999d246e48c |
comparison
equal
deleted
inserted
replaced
35183:bdd2e18b54c5 | 35184:ee64e677c3cf |
---|---|
291 | 291 |
292 # record merged .hgsubstate | 292 # record merged .hgsubstate |
293 writestate(repo, sm) | 293 writestate(repo, sm) |
294 return sm | 294 return sm |
295 | 295 |
296 def precommit(ui, wctx, status, match, force=False): | |
297 """Calculate .hgsubstate changes that should be applied before committing | |
298 | |
299 Returns (subs, commitsubs, newstate) where | |
300 - subs: changed subrepos (including dirty ones) | |
301 - commitsubs: dirty subrepos which the caller needs to commit recursively | |
302 - newstate: new state dict which the caller must write to .hgsubstate | |
303 | |
304 This also updates the given status argument. | |
305 """ | |
306 subs = [] | |
307 commitsubs = set() | |
308 newstate = wctx.substate.copy() | |
309 | |
310 # only manage subrepos and .hgsubstate if .hgsub is present | |
311 if '.hgsub' in wctx: | |
312 # we'll decide whether to track this ourselves, thanks | |
313 for c in status.modified, status.added, status.removed: | |
314 if '.hgsubstate' in c: | |
315 c.remove('.hgsubstate') | |
316 | |
317 # compare current state to last committed state | |
318 # build new substate based on last committed state | |
319 oldstate = wctx.p1().substate | |
320 for s in sorted(newstate.keys()): | |
321 if not match(s): | |
322 # ignore working copy, use old state if present | |
323 if s in oldstate: | |
324 newstate[s] = oldstate[s] | |
325 continue | |
326 if not force: | |
327 raise error.Abort( | |
328 _("commit with new subrepo %s excluded") % s) | |
329 dirtyreason = wctx.sub(s).dirtyreason(True) | |
330 if dirtyreason: | |
331 if not ui.configbool('ui', 'commitsubrepos'): | |
332 raise error.Abort(dirtyreason, | |
333 hint=_("use --subrepos for recursive commit")) | |
334 subs.append(s) | |
335 commitsubs.add(s) | |
336 else: | |
337 bs = wctx.sub(s).basestate() | |
338 newstate[s] = (newstate[s][0], bs, newstate[s][2]) | |
339 if oldstate.get(s, (None, None, None))[1] != bs: | |
340 subs.append(s) | |
341 | |
342 # check for removed subrepos | |
343 for p in wctx.parents(): | |
344 r = [s for s in p.substate if s not in newstate] | |
345 subs += [s for s in r if match(s)] | |
346 if subs: | |
347 if (not match('.hgsub') and | |
348 '.hgsub' in (wctx.modified() + wctx.added())): | |
349 raise error.Abort(_("can't commit subrepos without .hgsub")) | |
350 status.modified.insert(0, '.hgsubstate') | |
351 | |
352 elif '.hgsub' in status.removed: | |
353 # clean up .hgsubstate when .hgsub is removed | |
354 if ('.hgsubstate' in wctx and | |
355 '.hgsubstate' not in (status.modified + status.added + | |
356 status.removed)): | |
357 status.removed.insert(0, '.hgsubstate') | |
358 | |
359 return subs, commitsubs, newstate | |
360 | |
296 def _updateprompt(ui, sub, dirty, local, remote): | 361 def _updateprompt(ui, sub, dirty, local, remote): |
297 if dirty: | 362 if dirty: |
298 msg = (_(' subrepository sources for %s differ\n' | 363 msg = (_(' subrepository sources for %s differ\n' |
299 'use (l)ocal source (%s) or (r)emote source (%s)?' | 364 'use (l)ocal source (%s) or (r)emote source (%s)?' |
300 '$$ &Local $$ &Remote') | 365 '$$ &Local $$ &Remote') |