Mercurial > hg
changeset 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 | c6e033a7dd38 |
children | 4148414da120 |
files | hgext/largefiles/overrides.py hgext/mq.py mercurial/archival.py mercurial/cmdutil.py mercurial/context.py mercurial/fileset.py mercurial/localrepo.py mercurial/merge.py mercurial/subrepo.py tests/test-subrepo-svn.t |
diffstat | 10 files changed, 18 insertions(+), 18 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/largefiles/overrides.py Tue Jan 15 02:59:12 2013 +0100 +++ b/hgext/largefiles/overrides.py Wed Dec 12 02:38:14 2012 +0100 @@ -871,7 +871,7 @@ write(f, 'x' in ff and 0755 or 0644, 'l' in ff, getdata) if subrepos: - for subpath in ctx.substate: + for subpath in sorted(ctx.substate): sub = ctx.sub(subpath) submatch = match_.narrowmatcher(subpath, matchfn) sub.archive(repo.ui, archiver, prefix, submatch) @@ -918,7 +918,7 @@ write(f, 'x' in ff and 0755 or 0644, 'l' in ff, getdata) - for subpath in ctx.substate: + for subpath in sorted(ctx.substate): sub = ctx.sub(subpath) submatch = match_.narrowmatcher(subpath, match) sub.archive(ui, archiver, os.path.join(prefix, repo._path) + '/',
--- a/hgext/mq.py Tue Jan 15 02:59:12 2013 +0100 +++ b/hgext/mq.py Wed Dec 12 02:38:14 2012 +0100 @@ -947,7 +947,7 @@ bctx = repo[baserev] else: bctx = wctx.parents()[0] - for s in wctx.substate: + for s in sorted(wctx.substate): if wctx.sub(s).dirty(True): raise util.Abort( _("uncommitted changes in subrepository %s") % s)
--- a/mercurial/archival.py Tue Jan 15 02:59:12 2013 +0100 +++ b/mercurial/archival.py Wed Dec 12 02:38:14 2012 +0100 @@ -299,7 +299,7 @@ repo.ui.progress(_('archiving'), None) if subrepos: - for subpath in ctx.substate: + for subpath in sorted(ctx.substate): sub = ctx.sub(subpath) submatch = matchmod.narrowmatcher(subpath, matchfn) sub.archive(repo.ui, archiver, prefix, submatch)
--- a/mercurial/cmdutil.py Tue Jan 15 02:59:12 2013 +0100 +++ b/mercurial/cmdutil.py Wed Dec 12 02:38:14 2012 +0100 @@ -85,7 +85,7 @@ if modified or added or removed or deleted: raise util.Abort(_("outstanding uncommitted changes")) ctx = repo[None] - for s in ctx.substate: + for s in sorted(ctx.substate): if ctx.sub(s).dirty(): raise util.Abort(_("uncommitted changes in subrepo %s") % s) @@ -1515,7 +1515,7 @@ if ui.verbose or not exact: ui.status(_('adding %s\n') % match.rel(join(f))) - for subpath in wctx.substate: + for subpath in sorted(wctx.substate): sub = wctx.sub(subpath) try: submatch = matchmod.narrowmatcher(subpath, match) @@ -1546,7 +1546,7 @@ if explicitonly: forget = [f for f in forget if match.exact(f)] - for subpath in wctx.substate: + for subpath in sorted(wctx.substate): sub = wctx.sub(subpath) try: submatch = matchmod.narrowmatcher(subpath, match) @@ -1857,7 +1857,7 @@ names[abs] = m.rel(abs), m.exact(abs) # get the list of subrepos that must be reverted - targetsubs = [s for s in ctx.substate if m(s)] + targetsubs = sorted(s for s in ctx.substate if m(s)) m = scmutil.matchfiles(repo, names) changes = repo.status(match=m)[:4] modified, added, removed, deleted = map(set, changes)
--- a/mercurial/context.py Tue Jan 15 02:59:12 2013 +0100 +++ b/mercurial/context.py Wed Dec 12 02:38:14 2012 +0100 @@ -1035,13 +1035,13 @@ return self._parents[0].ancestor(c2) # punt on two parents for now def walk(self, match): - return sorted(self._repo.dirstate.walk(match, self.substate.keys(), + return sorted(self._repo.dirstate.walk(match, sorted(self.substate), True, False)) def dirty(self, missing=False, merge=True, branch=True): "check whether a working directory is modified" # check subrepos first - for s in self.substate: + for s in sorted(self.substate): if self.sub(s).dirty(): return True # check current working dir
--- a/mercurial/fileset.py Tue Jan 15 02:59:12 2013 +0100 +++ b/mercurial/fileset.py Wed Dec 12 02:38:14 2012 +0100 @@ -373,7 +373,7 @@ # i18n: "subrepo" is a keyword getargs(x, 0, 1, _("subrepo takes at most one argument")) ctx = mctx.ctx - sstate = ctx.substate + sstate = sorted(ctx.substate) if x: pat = getstring(x, _("subrepo requires a pattern or no arguments"))
--- a/mercurial/localrepo.py Tue Jan 15 02:59:12 2013 +0100 +++ b/mercurial/localrepo.py Wed Dec 12 02:38:14 2012 +0100 @@ -1500,7 +1500,7 @@ if working: # we need to scan the working dir subrepos = [] if '.hgsub' in self.dirstate: - subrepos = ctx2.substate.keys() + subrepos = sorted(ctx2.substate) s = self.dirstate.status(match, subrepos, listignored, listclean, listunknown) cmp, modified, added, removed, deleted, unknown, ignored, clean = s
--- a/mercurial/merge.py Tue Jan 15 02:59:12 2013 +0100 +++ b/mercurial/merge.py Wed Dec 12 02:38:14 2012 +0100 @@ -222,7 +222,7 @@ if '.hgsubstate' in m1: # check whether sub state is modified - for s in p1.substate: + for s in sorted(p1.substate): if p1.sub(s).dirty(): m1['.hgsubstate'] += "+" break @@ -593,7 +593,7 @@ if not force and (wc.files() or wc.deleted()): raise util.Abort(_("outstanding uncommitted changes"), hint=_("use 'hg status' to list changes")) - for s in wc.substate: + for s in sorted(wc.substate): if wc.sub(s).dirty(): raise util.Abort(_("outstanding uncommitted changes in " "subrepository '%s'") % s)
--- a/mercurial/subrepo.py Tue Jan 15 02:59:12 2013 +0100 +++ b/mercurial/subrepo.py Wed Dec 12 02:38:14 2012 +0100 @@ -147,7 +147,7 @@ r = "%s:%s:%s" % r repo.ui.debug(" subrepo %s: %s %s\n" % (s, msg, r)) - for s, l in s1.items(): + for s, l in sorted(s1.iteritems()): a = sa.get(s, nullstate) ld = l # local state with possible dirty flag for compares if wctx.sub(s).dirty():
--- a/tests/test-subrepo-svn.t Tue Jan 15 02:59:12 2013 +0100 +++ b/tests/test-subrepo-svn.t Wed Dec 12 02:38:14 2012 +0100 @@ -544,11 +544,11 @@ archiving: .hgsubstate 2/2 files (100.00%) archiving (obstruct): 0/1 files (0.00%) archiving (obstruct): 1/1 files (100.00%) + archiving (recreated): 0/1 files (0.00%) + archiving (recreated): 1/1 files (100.00%) archiving (s): 0/2 files (0.00%) archiving (s): 1/2 files (50.00%) archiving (s): 2/2 files (100.00%) - archiving (recreated): 0/1 files (0.00%) - archiving (recreated): 1/1 files (100.00%) $ hg archive -S ../archive-exclude --debug -X **old archiving: 0/2 files (0.00%) @@ -556,10 +556,10 @@ archiving: .hgsubstate 2/2 files (100.00%) archiving (obstruct): 0/1 files (0.00%) archiving (obstruct): 1/1 files (100.00%) + archiving (recreated): 0 files archiving (s): 0/2 files (0.00%) archiving (s): 1/2 files (50.00%) archiving (s): 2/2 files (100.00%) - archiving (recreated): 0 files $ find ../archive-exclude | sort ../archive-exclude ../archive-exclude/.hg_archival.txt