Show More
@@ -13,6 +13,7 b' import hg, scmutil, util, revlog, extens' | |||||
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 | |||
16 | import merge as mergemod |
|
17 | import merge as mergemod | |
17 | import minirst, revset, fileset |
|
18 | import minirst, revset, fileset | |
18 | import dagparser, context, simplemerge |
|
19 | import dagparser, context, simplemerge | |
@@ -2432,23 +2433,45 b' def forget(ui, repo, *pats, **opts):' | |||||
2432 | if not pats: |
|
2433 | if not pats: | |
2433 | raise util.Abort(_('no files specified')) |
|
2434 | raise util.Abort(_('no files specified')) | |
2434 |
|
2435 | |||
2435 | m = scmutil.match(repo[None], pats, opts) |
|
2436 | wctx = repo[None] | |
|
2437 | m = scmutil.match(wctx, pats, opts) | |||
2436 | s = repo.status(match=m, clean=True) |
|
2438 | s = repo.status(match=m, clean=True) | |
2437 | forget = sorted(s[0] + s[1] + s[3] + s[6]) |
|
2439 | forget = sorted(s[0] + s[1] + s[3] + s[6]) | |
|
2440 | subforget = {} | |||
2438 | errs = 0 |
|
2441 | errs = 0 | |
2439 |
|
2442 | |||
|
2443 | for subpath in wctx.substate: | |||
|
2444 | sub = wctx.sub(subpath) | |||
|
2445 | try: | |||
|
2446 | submatch = matchmod.narrowmatcher(subpath, m) | |||
|
2447 | for fsub in sub.walk(submatch): | |||
|
2448 | if submatch.exact(fsub): | |||
|
2449 | subforget[os.path.join(subpath, fsub)] = (fsub, sub) | |||
|
2450 | except error.LookupError: | |||
|
2451 | ui.status(_("skipping missing subrepository: %s\n") % subpath) | |||
|
2452 | ||||
2440 | for f in m.files(): |
|
2453 | for f in m.files(): | |
2441 | if f not in repo.dirstate and not os.path.isdir(m.rel(f)): |
|
2454 | if f not in repo.dirstate and not os.path.isdir(m.rel(f)): | |
2442 | if os.path.exists(m.rel(f)): |
|
2455 | if f not in subforget: | |
2443 | ui.warn(_('not removing %s: file is already untracked\n') |
|
2456 | if os.path.exists(m.rel(f)): | |
2444 | % m.rel(f)) |
|
2457 | ui.warn(_('not removing %s: file is already untracked\n') | |
2445 | errs = 1 |
|
2458 | % m.rel(f)) | |
|
2459 | errs = 1 | |||
2446 |
|
2460 | |||
2447 | for f in forget: |
|
2461 | for f in forget: | |
2448 | if ui.verbose or not m.exact(f): |
|
2462 | if ui.verbose or not m.exact(f): | |
2449 | ui.status(_('removing %s\n') % m.rel(f)) |
|
2463 | ui.status(_('removing %s\n') % m.rel(f)) | |
2450 |
|
2464 | |||
2451 | repo[None].forget(forget) |
|
2465 | if ui.verbose: | |
|
2466 | for f in sorted(subforget.keys()): | |||
|
2467 | ui.status(_('removing %s\n') % m.rel(f)) | |||
|
2468 | ||||
|
2469 | wctx.forget(forget) | |||
|
2470 | ||||
|
2471 | for f in sorted(subforget.keys()): | |||
|
2472 | fsub, sub = subforget[f] | |||
|
2473 | sub.forget([fsub]) | |||
|
2474 | ||||
2452 | return errs |
|
2475 | return errs | |
2453 |
|
2476 | |||
2454 | @command( |
|
2477 | @command( |
@@ -95,6 +95,9 b' Interaction with Mercurial Commands' | |||||
95 | elements. Git and Subversion subrepositories are currently |
|
95 | elements. Git and Subversion subrepositories are currently | |
96 | silently ignored. |
|
96 | silently ignored. | |
97 |
|
97 | |||
|
98 | :forget: forget currently only handles exact file matches in subrepos. | |||
|
99 | Git and Subversion subrepositories are currently silently ignored. | |||
|
100 | ||||
98 | :incoming: incoming does not recurse in subrepos unless -S/--subrepos |
|
101 | :incoming: incoming does not recurse in subrepos unless -S/--subrepos | |
99 | is specified. Git and Subversion subrepositories are currently |
|
102 | is specified. Git and Subversion subrepositories are currently | |
100 | silently ignored. |
|
103 | silently ignored. |
@@ -360,6 +360,9 b' class abstractsubrepo(object):' | |||||
360 | ''' |
|
360 | ''' | |
361 | pass |
|
361 | pass | |
362 |
|
362 | |||
|
363 | def forget(self, files): | |||
|
364 | pass | |||
|
365 | ||||
363 | class hgsubrepo(abstractsubrepo): |
|
366 | class hgsubrepo(abstractsubrepo): | |
364 | def __init__(self, ctx, path, state): |
|
367 | def __init__(self, ctx, path, state): | |
365 | self._path = path |
|
368 | self._path = path | |
@@ -553,6 +556,10 b' class hgsubrepo(abstractsubrepo):' | |||||
553 | ctx = self._repo[None] |
|
556 | ctx = self._repo[None] | |
554 | return ctx.walk(match) |
|
557 | return ctx.walk(match) | |
555 |
|
558 | |||
|
559 | def forget(self, files): | |||
|
560 | ctx = self._repo[None] | |||
|
561 | ctx.forget(files) | |||
|
562 | ||||
556 | class svnsubrepo(abstractsubrepo): |
|
563 | class svnsubrepo(abstractsubrepo): | |
557 | def __init__(self, ctx, path, state): |
|
564 | def __init__(self, ctx, path, state): | |
558 | self._path = path |
|
565 | self._path = path |
@@ -1006,12 +1006,12 b' Adding with a pattern with -S also adds ' | |||||
1006 | committing subrepository s |
|
1006 | committing subrepository s | |
1007 |
|
1007 | |||
1008 | Test behavior of forget for explicit path in subrepo: |
|
1008 | Test behavior of forget for explicit path in subrepo: | |
1009 |
Forgetting an explicit path in a subrepo |
|
1009 | Forgetting an explicit path in a subrepo untracks the file | |
1010 | $ echo c19 > s/f19 |
|
1010 | $ echo c19 > s/f19 | |
1011 | $ hg add s/f19 |
|
1011 | $ hg add s/f19 | |
1012 | $ hg st -S |
|
1012 | $ hg st -S | |
1013 | A s/f19 |
|
1013 | A s/f19 | |
1014 | $ hg forget s/f19 |
|
1014 | $ hg forget s/f19 | |
1015 | not removing s/f19: file is already untracked |
|
1015 | $ hg st -S | |
1016 | [1] |
|
1016 | ? s/f19 | |
1017 | $ rm s/f19 |
|
1017 | $ rm s/f19 |
General Comments 0
You need to be logged in to leave comments.
Login now