comparison mercurial/commands.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 6c97eb445341
comparison
equal deleted inserted replaced
15911:c654eac03452 15912:2bd54ffaa27e
11 import os, re, difflib, time, tempfile, errno 11 import os, re, difflib, time, tempfile, errno
12 import hg, scmutil, util, revlog, extensions, copies, error, bookmarks 12 import hg, scmutil, util, revlog, extensions, copies, error, bookmarks
13 import patch, help, url, encoding, templatekw, discovery 13 import patch, help, url, encoding, templatekw, discovery
14 import archival, changegroup, cmdutil, hbisect 14 import archival, changegroup, cmdutil, hbisect
15 import sshserver, hgweb, hgweb.server, commandserver 15 import sshserver, hgweb, hgweb.server, commandserver
16 import match as matchmod
17 import merge as mergemod 16 import merge as mergemod
18 import minirst, revset, fileset 17 import minirst, revset, fileset
19 import dagparser, context, simplemerge 18 import dagparser, context, simplemerge
20 import random, setdiscovery, treediscovery, dagutil 19 import random, setdiscovery, treediscovery, dagutil
21 import phases 20 import phases
2447 """ 2446 """
2448 2447
2449 if not pats: 2448 if not pats:
2450 raise util.Abort(_('no files specified')) 2449 raise util.Abort(_('no files specified'))
2451 2450
2452 wctx = repo[None] 2451 m = scmutil.match(repo[None], pats, opts)
2453 m = scmutil.match(wctx, pats, opts) 2452 rejected = cmdutil.forget(ui, repo, m, prefix="", explicitonly=False)[0]
2454 s = repo.status(match=m, clean=True) 2453 return rejected and 1 or 0
2455 forget = sorted(s[0] + s[1] + s[3] + s[6])
2456 subforget = {}
2457 errs = 0
2458
2459 for subpath in wctx.substate:
2460 sub = wctx.sub(subpath)
2461 try:
2462 submatch = matchmod.narrowmatcher(subpath, m)
2463 for fsub in sub.walk(submatch):
2464 if submatch.exact(fsub):
2465 subforget[subpath + '/' + fsub] = (fsub, sub)
2466 except error.LookupError:
2467 ui.status(_("skipping missing subrepository: %s\n") % subpath)
2468
2469 for f in m.files():
2470 if f not in repo.dirstate and not os.path.isdir(m.rel(f)):
2471 if f not in subforget:
2472 if os.path.exists(m.rel(f)):
2473 ui.warn(_('not removing %s: file is already untracked\n')
2474 % m.rel(f))
2475 errs = 1
2476
2477 for f in forget:
2478 if ui.verbose or not m.exact(f):
2479 ui.status(_('removing %s\n') % m.rel(f))
2480
2481 if ui.verbose:
2482 for f in sorted(subforget.keys()):
2483 ui.status(_('removing %s\n') % m.rel(f))
2484
2485 wctx.forget(forget)
2486
2487 for f in sorted(subforget.keys()):
2488 fsub, sub = subforget[f]
2489 sub.forget([fsub])
2490
2491 return errs
2492 2454
2493 @command( 2455 @command(
2494 'graft', 2456 'graft',
2495 [('c', 'continue', False, _('resume interrupted graft')), 2457 [('c', 'continue', False, _('resume interrupted graft')),
2496 ('e', 'edit', False, _('invoke editor on commit messages')), 2458 ('e', 'edit', False, _('invoke editor on commit messages')),