Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/cmdutil.py @ 24413:a8595176dd64
subrepo: add basic support to hgsubrepo for the files command
Paths into the subrepo are not yet supported.
The need to use the workingctx in the subrepo will likely be used more in the
future, with the proposed working directory revset symbol. It is also needed
with archive, if that code is to be reused to support 'extdiff -S'.
Unfortunately, it doesn't seem possible to put the smarts in subrepo.subrepo(),
as it breaks various status and diff tests.
I opted not to pass the desired revision into the subrepo method explicitly,
because the only ones that do pass an explicit revision are methods like status
and diff, which actually operate on two contexts- the subrepo state and the
explicitly passed revision.
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Wed, 18 Mar 2015 23:03:41 -0400 |
parents | 6c3a93e690c7 |
children | 2bdd35ea0a03 |
comparison
equal
deleted
inserted
replaced
24409:30b8db6d0c04 | 24413:a8595176dd64 |
---|---|
2259 rejected = wctx.forget(forget, prefix) | 2259 rejected = wctx.forget(forget, prefix) |
2260 bad.extend(f for f in rejected if f in match.files()) | 2260 bad.extend(f for f in rejected if f in match.files()) |
2261 forgot.extend(f for f in forget if f not in rejected) | 2261 forgot.extend(f for f in forget if f not in rejected) |
2262 return bad, forgot | 2262 return bad, forgot |
2263 | 2263 |
2264 def files(ui, ctx, m, fm, fmt): | 2264 def files(ui, ctx, m, fm, fmt, subrepos): |
2265 rev = ctx.rev() | 2265 rev = ctx.rev() |
2266 ret = 1 | 2266 ret = 1 |
2267 ds = ctx.repo().dirstate | 2267 ds = ctx.repo().dirstate |
2268 | 2268 |
2269 for f in ctx.matches(m): | 2269 for f in ctx.matches(m): |
2274 fc = ctx[f] | 2274 fc = ctx[f] |
2275 fm.write('size flags', '% 10d % 1s ', fc.size(), fc.flags()) | 2275 fm.write('size flags', '% 10d % 1s ', fc.size(), fc.flags()) |
2276 fm.data(abspath=f) | 2276 fm.data(abspath=f) |
2277 fm.write('path', fmt, m.rel(f)) | 2277 fm.write('path', fmt, m.rel(f)) |
2278 ret = 0 | 2278 ret = 0 |
2279 | |
2280 if subrepos: | |
2281 for subpath in sorted(ctx.substate): | |
2282 sub = ctx.sub(subpath) | |
2283 try: | |
2284 submatch = matchmod.narrowmatcher(subpath, m) | |
2285 if sub.printfiles(ui, submatch, fm, fmt) == 0: | |
2286 ret = 0 | |
2287 except error.LookupError: | |
2288 ui.status(_("skipping missing subrepository: %s\n") | |
2289 % m.abs(subpath)) | |
2279 | 2290 |
2280 return ret | 2291 return ret |
2281 | 2292 |
2282 def remove(ui, repo, m, prefix, after, force, subrepos): | 2293 def remove(ui, repo, m, prefix, after, force, subrepos): |
2283 join = lambda f: os.path.join(prefix, f) | 2294 join = lambda f: os.path.join(prefix, f) |