mercurial/commands.py
changeset 2882 c2932ad5476a
parent 2881 cf98cd70d2c4
child 2886 9826af4841ef
child 2908 3848488244fc
equal deleted inserted replaced
2881:cf98cd70d2c4 2882:c2932ad5476a
   653     This command is now deprecated and will be removed in a future
   653     This command is now deprecated and will be removed in a future
   654     release. Please use add and remove --after instead.
   654     release. Please use add and remove --after instead.
   655     """
   655     """
   656     ui.warn(_('(the addremove command is deprecated; use add and remove '
   656     ui.warn(_('(the addremove command is deprecated; use add and remove '
   657               '--after instead)\n'))
   657               '--after instead)\n'))
   658     return addremove_lock(ui, repo, pats, opts)
   658     return cmdutil.addremove(repo, pats, opts)
   659 
       
   660 def addremove_lock(ui, repo, pats, opts, wlock=None):
       
   661     add, remove = [], []
       
   662     for src, abs, rel, exact in cmdutil.walk(repo, pats, opts):
       
   663         if src == 'f' and repo.dirstate.state(abs) == '?':
       
   664             add.append(abs)
       
   665             if ui.verbose or not exact:
       
   666                 ui.status(_('adding %s\n') % ((pats and rel) or abs))
       
   667         if repo.dirstate.state(abs) != 'r' and not os.path.exists(rel):
       
   668             remove.append(abs)
       
   669             if ui.verbose or not exact:
       
   670                 ui.status(_('removing %s\n') % ((pats and rel) or abs))
       
   671     if not opts.get('dry_run'):
       
   672         repo.add(add, wlock=wlock)
       
   673         repo.remove(remove, wlock=wlock)
       
   674 
   659 
   675 def annotate(ui, repo, *pats, **opts):
   660 def annotate(ui, repo, *pats, **opts):
   676     """show changeset information per file line
   661     """show changeset information per file line
   677 
   662 
   678     List changes in files, showing the revision id responsible for each line
   663     List changes in files, showing the revision id responsible for each line
   943     or in the EDITOR environment variable is started to enter a message.
   928     or in the EDITOR environment variable is started to enter a message.
   944     """
   929     """
   945     message = logmessage(opts)
   930     message = logmessage(opts)
   946 
   931 
   947     if opts['addremove']:
   932     if opts['addremove']:
   948         addremove_lock(ui, repo, pats, opts)
   933         cmdutil.addremove(repo, pats, opts)
   949     fns, match, anypats = cmdutil.matchpats(repo, pats, opts)
   934     fns, match, anypats = cmdutil.matchpats(repo, pats, opts)
   950     if pats:
   935     if pats:
   951         modified, added, removed = repo.status(files=fns, match=match)[:3]
   936         modified, added, removed = repo.status(files=fns, match=match)[:3]
   952         files = modified + added + removed
   937         files = modified + added + removed
   953     else:
   938     else:
  1720                     ctype, gp = files[f]
  1705                     ctype, gp = files[f]
  1721                     if gp and gp.mode:
  1706                     if gp and gp.mode:
  1722                         x = gp.mode & 0100 != 0
  1707                         x = gp.mode & 0100 != 0
  1723                         dst = os.path.join(repo.root, gp.path)
  1708                         dst = os.path.join(repo.root, gp.path)
  1724                         util.set_exec(dst, x)
  1709                         util.set_exec(dst, x)
  1725                 addremove_lock(ui, repo, cfiles, {}, wlock=wlock)
  1710                 cmdutil.addremove(repo, cfiles, wlock=wlock)
  1726             files = files.keys()
  1711             files = files.keys()
  1727             files.extend([r for r in removes if r not in files])
  1712             files.extend([r for r in removes if r not in files])
  1728             repo.commit(files, message, user, date, wlock=wlock, lock=lock)
  1713             repo.commit(files, message, user, date, wlock=wlock, lock=lock)
  1729         finally:
  1714         finally:
  1730             os.unlink(tmpname)
  1715             os.unlink(tmpname)