Mercurial > public > mercurial-scm > hg
diff mercurial/cmdutil.py @ 15912:2bd54ffaa27e
forget: fix subrepo recursion for explicit path handling
When support for handling explicit paths in subrepos was added to the forget
command (95174c381525), subrepo recursion wasn't taken into account. This
change fixes that by pulling the majority of the logic of commands.forget into
cmdutil.forget, which can then be called from both there and subrepo.forget.
author | David M. Carr <david@carrclan.us> |
---|---|
date | Tue, 17 Jan 2012 19:10:59 -0500 |
parents | c654eac03452 |
children | f11eee00c652 |
line wrap: on
line diff
--- a/mercurial/cmdutil.py Tue Jan 17 19:10:58 2012 -0500 +++ b/mercurial/cmdutil.py Tue Jan 17 19:10:59 2012 -0500 @@ -1201,6 +1201,48 @@ bad.extend(f for f in rejected if f in match.files()) return bad +def forget(ui, repo, match, prefix, explicitonly): + join = lambda f: os.path.join(prefix, f) + bad = [] + oldbad = match.bad + match.bad = lambda x, y: bad.append(x) or oldbad(x, y) + wctx = repo[None] + forgot = [] + s = repo.status(match=match, clean=True) + forget = sorted(s[0] + s[1] + s[3] + s[6]) + if explicitonly: + forget = [f for f in forget if match.exact(f)] + + for subpath in wctx.substate: + sub = wctx.sub(subpath) + try: + submatch = matchmod.narrowmatcher(subpath, match) + subbad, subforgot = sub.forget(ui, submatch, prefix) + bad.extend([subpath + '/' + f for f in subbad]) + forgot.extend([subpath + '/' + f for f in subforgot]) + except error.LookupError: + ui.status(_("skipping missing subrepository: %s\n") + % join(subpath)) + + for f in match.files(): + if match.exact(f) or not explicitonly: + if f not in repo.dirstate and not os.path.isdir(match.rel(join(f))): + if f not in forgot: + if os.path.exists(match.rel(join(f))): + ui.warn(_('not removing %s: ' + 'file is already untracked\n') + % match.rel(join(f))) + bad.append(f) + + for f in forget: + if ui.verbose or not match.exact(f): + ui.status(_('removing %s\n') % match.rel(join(f))) + + rejected = wctx.forget(forget, prefix) + bad.extend(f for f in rejected if f in match.files()) + forgot.extend(forget) + return bad, forgot + def duplicatecopies(repo, rev, p1): "Reproduce copies found in the source revision in the dirstate for grafts" for dst, src in copies.pathcopies(repo[p1], repo[rev]).iteritems():