--- a/hgext/mq.py Sun Aug 13 16:11:22 2006 -0700
+++ b/hgext/mq.py Sun Aug 13 16:57:45 2006 -0700
@@ -32,7 +32,7 @@
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 @@
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)
--- a/mercurial/cmdutil.py Sun Aug 13 16:11:22 2006 -0700
+++ b/mercurial/cmdutil.py Sun Aug 13 16:57:45 2006 -0700
@@ -90,3 +90,20 @@
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)
--- a/mercurial/commands.py Sun Aug 13 16:11:22 2006 -0700
+++ b/mercurial/commands.py Sun Aug 13 16:57:45 2006 -0700
@@ -655,22 +655,7 @@
"""
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 @@
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 @@
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)
--- a/mercurial/util.py Sun Aug 13 16:11:22 2006 -0700
+++ b/mercurial/util.py Sun Aug 13 16:57:45 2006 -0700
@@ -995,3 +995,4 @@
if path.startswith('//'):
path = path[2:]
return path
+