mercurial/commands.py
changeset 1255 e825dfea3823
parent 1254 e6560042b7b8
child 1257 fe7fbfdb066d
equal deleted inserted replaced
1254:e6560042b7b8 1255:e825dfea3823
   483 def add(ui, repo, *pats, **opts):
   483 def add(ui, repo, *pats, **opts):
   484     '''add the specified files on the next commit'''
   484     '''add the specified files on the next commit'''
   485     names = []
   485     names = []
   486     for src, abs, rel, exact in walk(repo, pats, opts):
   486     for src, abs, rel, exact in walk(repo, pats, opts):
   487         if exact:
   487         if exact:
       
   488             if ui.verbose: ui.status('adding %s\n' % rel)
   488             names.append(abs)
   489             names.append(abs)
   489         elif repo.dirstate.state(abs) == '?':
   490         elif repo.dirstate.state(abs) == '?':
   490             ui.status('adding %s\n' % rel)
   491             ui.status('adding %s\n' % rel)
   491             names.append(abs)
   492             names.append(abs)
   492     repo.add(names)
   493     repo.add(names)
   495     """add all new files, delete all missing files"""
   496     """add all new files, delete all missing files"""
   496     add, remove = [], []
   497     add, remove = [], []
   497     for src, abs, rel, exact in walk(repo, pats, opts):
   498     for src, abs, rel, exact in walk(repo, pats, opts):
   498         if src == 'f' and repo.dirstate.state(abs) == '?':
   499         if src == 'f' and repo.dirstate.state(abs) == '?':
   499             add.append(abs)
   500             add.append(abs)
   500             if not exact:
   501             if ui.verbose or not exact:
   501                 ui.status('adding ', rel, '\n')
   502                 ui.status('adding ', rel, '\n')
   502         if repo.dirstate.state(abs) != 'r' and not os.path.exists(rel):
   503         if repo.dirstate.state(abs) != 'r' and not os.path.exists(rel):
   503             remove.append(abs)
   504             remove.append(abs)
   504             if not exact:
   505             if ui.verbose or not exact:
   505                 ui.status('removing ', rel, '\n')
   506                 ui.status('removing ', rel, '\n')
   506     repo.add(add)
   507     repo.add(add)
   507     repo.remove(remove)
   508     repo.remove(remove)
   508 
   509 
   509 def annotate(ui, repo, *pats, **opts):
   510 def annotate(ui, repo, *pats, **opts):
   964     """don't add the specified files on the next commit"""
   965     """don't add the specified files on the next commit"""
   965     forget = []
   966     forget = []
   966     for src, abs, rel, exact in walk(repo, pats, opts):
   967     for src, abs, rel, exact in walk(repo, pats, opts):
   967         if repo.dirstate.state(abs) == 'a':
   968         if repo.dirstate.state(abs) == 'a':
   968             forget.append(abs)
   969             forget.append(abs)
   969             if not exact:
   970             if ui.verbose or not exact:
   970                 ui.status('forgetting ', rel, '\n')
   971                 ui.status('forgetting ', rel, '\n')
   971     repo.forget(forget)
   972     repo.forget(forget)
   972 
   973 
   973 def grep(ui, repo, pattern, *pats, **opts):
   974 def grep(ui, repo, pattern, *pats, **opts):
   974     """search for a pattern in specified files and revisions"""
   975     """search for a pattern in specified files and revisions"""
  1402         c, a, d, u = repo.changes(files = [abs])
  1403         c, a, d, u = repo.changes(files = [abs])
  1403         reason = None
  1404         reason = None
  1404         if c: reason = 'is modified'
  1405         if c: reason = 'is modified'
  1405         elif a: reason = 'has been marked for add'
  1406         elif a: reason = 'has been marked for add'
  1406         elif u: reason = 'is not managed'
  1407         elif u: reason = 'is not managed'
  1407         if reason and exact:
  1408         if reason:
  1408             ui.warn('not removing %s: file %s\n' % (rel, reason))
  1409             if exact: ui.warn('not removing %s: file %s\n' % (rel, reason))
  1409         else:
  1410         else:
  1410             return True
  1411             return True
  1411     for src, abs, rel, exact in walk(repo, (pat,) + pats, opts):
  1412     for src, abs, rel, exact in walk(repo, (pat,) + pats, opts):
  1412         if okaytoremove(abs, rel, exact):
  1413         if okaytoremove(abs, rel, exact):
  1413             if ui.verbose or not exact: ui.status('removing %s\n' % rel)
  1414             if ui.verbose or not exact: ui.status('removing %s\n' % rel)