# HG changeset patch # User Vadim Gelfer # Date 2006-08-13 23:57:45 # Node ID c2932ad5476a92ece6a11e52fb9808b2432730be # Parent cf98cd70d2c44ccd6ac93cddbea50828cce82144 move commands.addremove_lock to cmdutil.addremove diff --git a/hgext/mq.py b/hgext/mq.py --- a/hgext/mq.py +++ b/hgext/mq.py @@ -32,7 +32,7 @@ refresh contents of top applied patch from mercurial.demandload import * from mercurial.i18n import gettext as _ demandload(globals(), "os sys re struct traceback errno bz2") -demandload(globals(), "mercurial:commands,hg,patch,revlog,ui,util") +demandload(globals(), "mercurial:cmdutil,commands,hg,patch,revlog,ui,util") commands.norepo += " qclone qversion" @@ -480,8 +480,7 @@ class queue: cfiles = files if cwd: cfiles = [util.pathto(cwd, f) for f in files] - commands.addremove_lock(self.ui, repo, cfiles, - opts={}, wlock=wlock) + cmdutil.addremove(repo, cfiles, wlock=wlock) n = repo.commit(files, message, user, date, force=1, lock=lock, wlock=wlock) diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py --- a/mercurial/cmdutil.py +++ b/mercurial/cmdutil.py @@ -90,3 +90,20 @@ def walk(repo, pats, opts, node=None, he files, matchfn, results = makewalk(repo, pats, opts, node, head, badmatch) for r in results: yield r + +def addremove(repo, pats, opts={}, wlock=None, dry_run=None): + if dry_run is None: + dry_run = opts.get('dry_run') + add, remove = [], [] + for src, abs, rel, exact in walk(repo, pats, opts): + if src == 'f' and repo.dirstate.state(abs) == '?': + add.append(abs) + if repo.ui.verbose or not exact: + repo.ui.status(_('adding %s\n') % ((pats and rel) or abs)) + if repo.dirstate.state(abs) != 'r' and not os.path.exists(rel): + remove.append(abs) + if repo.ui.verbose or not exact: + repo.ui.status(_('removing %s\n') % ((pats and rel) or abs)) + if not dry_run: + repo.add(add, wlock=wlock) + repo.remove(remove, wlock=wlock) diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -655,22 +655,7 @@ def addremove(ui, repo, *pats, **opts): """ ui.warn(_('(the addremove command is deprecated; use add and remove ' '--after instead)\n')) - return addremove_lock(ui, repo, pats, opts) - -def addremove_lock(ui, repo, pats, opts, wlock=None): - add, remove = [], [] - for src, abs, rel, exact in cmdutil.walk(repo, pats, opts): - if src == 'f' and repo.dirstate.state(abs) == '?': - add.append(abs) - if ui.verbose or not exact: - ui.status(_('adding %s\n') % ((pats and rel) or abs)) - if repo.dirstate.state(abs) != 'r' and not os.path.exists(rel): - remove.append(abs) - if ui.verbose or not exact: - ui.status(_('removing %s\n') % ((pats and rel) or abs)) - if not opts.get('dry_run'): - repo.add(add, wlock=wlock) - repo.remove(remove, wlock=wlock) + return cmdutil.addremove(repo, pats, opts) def annotate(ui, repo, *pats, **opts): """show changeset information per file line @@ -945,7 +930,7 @@ def commit(ui, repo, *pats, **opts): message = logmessage(opts) if opts['addremove']: - addremove_lock(ui, repo, pats, opts) + cmdutil.addremove(repo, pats, opts) fns, match, anypats = cmdutil.matchpats(repo, pats, opts) if pats: modified, added, removed = repo.status(files=fns, match=match)[:3] @@ -1722,7 +1707,7 @@ def import_(ui, repo, patch1, *patches, x = gp.mode & 0100 != 0 dst = os.path.join(repo.root, gp.path) util.set_exec(dst, x) - addremove_lock(ui, repo, cfiles, {}, wlock=wlock) + cmdutil.addremove(repo, cfiles, wlock=wlock) files = files.keys() files.extend([r for r in removes if r not in files]) repo.commit(files, message, user, date, wlock=wlock, lock=lock) diff --git a/mercurial/util.py b/mercurial/util.py --- a/mercurial/util.py +++ b/mercurial/util.py @@ -995,3 +995,4 @@ def drop_scheme(scheme, path): if path.startswith('//'): path = path[2:] return path +