mercurial/cmdutil.py
changeset 12270 166b9866580a
parent 12269 877236cdd437
child 12345 e0ee3e822a9a
equal deleted inserted replaced
12269:877236cdd437 12270:166b9866580a
  1278                 prepare(ctx, fns)
  1278                 prepare(ctx, fns)
  1279             for rev in nrevs:
  1279             for rev in nrevs:
  1280                 yield change(rev)
  1280                 yield change(rev)
  1281     return iterate()
  1281     return iterate()
  1282 
  1282 
  1283 def add(ui, repo, match, dryrun):
  1283 def add(ui, repo, match, dryrun, listsubrepos, prefix):
       
  1284     join = lambda f: os.path.join(prefix, f)
  1284     bad = []
  1285     bad = []
  1285     oldbad = match.bad
  1286     oldbad = match.bad
  1286     match.bad = lambda x, y: bad.append(x) or oldbad(x, y)
  1287     match.bad = lambda x, y: bad.append(x) or oldbad(x, y)
  1287     names = []
  1288     names = []
       
  1289     wctx = repo[None]
  1288     for f in repo.walk(match):
  1290     for f in repo.walk(match):
  1289         exact = match.exact(f)
  1291         exact = match.exact(f)
  1290         if exact or f not in repo.dirstate:
  1292         if exact or f not in repo.dirstate:
  1291             names.append(f)
  1293             names.append(f)
  1292             if ui.verbose or not exact:
  1294             if ui.verbose or not exact:
  1293                 ui.status(_('adding %s\n') % match.rel(f))
  1295                 ui.status(_('adding %s\n') % match.rel(join(f)))
       
  1296 
       
  1297     if listsubrepos:
       
  1298         for subpath in wctx.substate:
       
  1299             sub = wctx.sub(subpath)
       
  1300             try:
       
  1301                 submatch = matchmod.narrowmatcher(subpath, match)
       
  1302                 bad.extend(sub.add(ui, submatch, dryrun, prefix))
       
  1303             except error.LookupError:
       
  1304                 ui.status(_("skipping missing subrepository: %s\n")
       
  1305                                % join(subpath))
       
  1306 
  1294     if not dryrun:
  1307     if not dryrun:
  1295         rejected = repo[None].add(names)
  1308         rejected = wctx.add(names, prefix)
  1296         bad.extend(f for f in rejected if f in match.files())
  1309         bad.extend(f for f in rejected if f in match.files())
  1297     return bad
  1310     return bad
  1298 
  1311 
  1299 def commit(ui, repo, commitfunc, pats, opts):
  1312 def commit(ui, repo, commitfunc, pats, opts):
  1300     '''commit the specified files or all outstanding changes'''
  1313     '''commit the specified files or all outstanding changes'''