comparison mercurial/cmdutil.py @ 18364:6252b4f1c4b4

subrepos: process subrepos in sorted order Add sorted() in places found by testing with PYTHONHASHSEED=random and code inspection. An alternative to sprinkling sorted() all over would be to change substate to a custom dict with sorted iterators...
author Mads Kiilerich <mads@kiilerich.com>
date Wed, 12 Dec 2012 02:38:14 +0100
parents 8802277c40ee
children 94317c2d53b8
comparison
equal deleted inserted replaced
18363:c6e033a7dd38 18364:6252b4f1c4b4
83 raise util.Abort(_('outstanding uncommitted merge')) 83 raise util.Abort(_('outstanding uncommitted merge'))
84 modified, added, removed, deleted = repo.status()[:4] 84 modified, added, removed, deleted = repo.status()[:4]
85 if modified or added or removed or deleted: 85 if modified or added or removed or deleted:
86 raise util.Abort(_("outstanding uncommitted changes")) 86 raise util.Abort(_("outstanding uncommitted changes"))
87 ctx = repo[None] 87 ctx = repo[None]
88 for s in ctx.substate: 88 for s in sorted(ctx.substate):
89 if ctx.sub(s).dirty(): 89 if ctx.sub(s).dirty():
90 raise util.Abort(_("uncommitted changes in subrepo %s") % s) 90 raise util.Abort(_("uncommitted changes in subrepo %s") % s)
91 91
92 def logmessage(ui, opts): 92 def logmessage(ui, opts):
93 """ get the log message according to -m and -l option """ 93 """ get the log message according to -m and -l option """
1513 cca(f) 1513 cca(f)
1514 names.append(f) 1514 names.append(f)
1515 if ui.verbose or not exact: 1515 if ui.verbose or not exact:
1516 ui.status(_('adding %s\n') % match.rel(join(f))) 1516 ui.status(_('adding %s\n') % match.rel(join(f)))
1517 1517
1518 for subpath in wctx.substate: 1518 for subpath in sorted(wctx.substate):
1519 sub = wctx.sub(subpath) 1519 sub = wctx.sub(subpath)
1520 try: 1520 try:
1521 submatch = matchmod.narrowmatcher(subpath, match) 1521 submatch = matchmod.narrowmatcher(subpath, match)
1522 if listsubrepos: 1522 if listsubrepos:
1523 bad.extend(sub.add(ui, submatch, dryrun, listsubrepos, prefix, 1523 bad.extend(sub.add(ui, submatch, dryrun, listsubrepos, prefix,
1544 s = repo.status(match=match, clean=True) 1544 s = repo.status(match=match, clean=True)
1545 forget = sorted(s[0] + s[1] + s[3] + s[6]) 1545 forget = sorted(s[0] + s[1] + s[3] + s[6])
1546 if explicitonly: 1546 if explicitonly:
1547 forget = [f for f in forget if match.exact(f)] 1547 forget = [f for f in forget if match.exact(f)]
1548 1548
1549 for subpath in wctx.substate: 1549 for subpath in sorted(wctx.substate):
1550 sub = wctx.sub(subpath) 1550 sub = wctx.sub(subpath)
1551 try: 1551 try:
1552 submatch = matchmod.narrowmatcher(subpath, match) 1552 submatch = matchmod.narrowmatcher(subpath, match)
1553 subbad, subforgot = sub.forget(ui, submatch, prefix) 1553 subbad, subforgot = sub.forget(ui, submatch, prefix)
1554 bad.extend([subpath + '/' + f for f in subbad]) 1554 bad.extend([subpath + '/' + f for f in subbad])
1855 for abs in ctx.walk(m): 1855 for abs in ctx.walk(m):
1856 if abs not in names: 1856 if abs not in names:
1857 names[abs] = m.rel(abs), m.exact(abs) 1857 names[abs] = m.rel(abs), m.exact(abs)
1858 1858
1859 # get the list of subrepos that must be reverted 1859 # get the list of subrepos that must be reverted
1860 targetsubs = [s for s in ctx.substate if m(s)] 1860 targetsubs = sorted(s for s in ctx.substate if m(s))
1861 m = scmutil.matchfiles(repo, names) 1861 m = scmutil.matchfiles(repo, names)
1862 changes = repo.status(match=m)[:4] 1862 changes = repo.status(match=m)[:4]
1863 modified, added, removed, deleted = map(set, changes) 1863 modified, added, removed, deleted = map(set, changes)
1864 1864
1865 # if f is a rename, also revert the source 1865 # if f is a rename, also revert the source