##// END OF EJS Templates
addremove: build lists of already added and removed files too (issue1696)
Matt Mackall -
r8990:62739933 default
parent child Browse files
Show More
@@ -298,7 +298,8 b' def addremove(repo, pats=[], opts={}, dr'
298 dry_run = opts.get('dry_run')
298 dry_run = opts.get('dry_run')
299 if similarity is None:
299 if similarity is None:
300 similarity = float(opts.get('similarity') or 0)
300 similarity = float(opts.get('similarity') or 0)
301 unknown, deleted = [], []
301 # we'd use status here, except handling of symlinks and ignore is tricky
302 added, unknown, deleted, removed = [], [], [], []
302 audit_path = util.path_auditor(repo.root)
303 audit_path = util.path_auditor(repo.root)
303 m = match(repo, pats, opts)
304 m = match(repo, pats, opts)
304 for abs in repo.walk(m):
305 for abs in repo.walk(m):
@@ -314,16 +315,22 b' def addremove(repo, pats=[], opts={}, dr'
314 unknown.append(abs)
315 unknown.append(abs)
315 if repo.ui.verbose or not exact:
316 if repo.ui.verbose or not exact:
316 repo.ui.status(_('adding %s\n') % ((pats and rel) or abs))
317 repo.ui.status(_('adding %s\n') % ((pats and rel) or abs))
317 if repo.dirstate[abs] != 'r' and (not good or not util.lexists(target)
318 elif repo.dirstate[abs] != 'r' and (not good or not util.lexists(target)
318 or (os.path.isdir(target) and not os.path.islink(target))):
319 or (os.path.isdir(target) and not os.path.islink(target))):
319 deleted.append(abs)
320 deleted.append(abs)
320 if repo.ui.verbose or not exact:
321 if repo.ui.verbose or not exact:
321 repo.ui.status(_('removing %s\n') % ((pats and rel) or abs))
322 repo.ui.status(_('removing %s\n') % ((pats and rel) or abs))
323 # for finding renames
324 elif repo.dirstate[abs] == 'r':
325 removed.append(abs)
326 elif repo.dirstate[abs] == 'a':
327 added.append(abs)
322 if not dry_run:
328 if not dry_run:
323 repo.remove(deleted)
329 repo.remove(deleted)
324 repo.add(unknown)
330 repo.add(unknown)
325 if similarity > 0:
331 if similarity > 0:
326 for old, new, score in findrenames(repo, unknown, deleted, similarity):
332 for old, new, score in findrenames(repo, added + unknown,
333 removed + deleted, similarity):
327 if repo.ui.verbose or not m.exact(old) or not m.exact(new):
334 if repo.ui.verbose or not m.exact(old) or not m.exact(new):
328 repo.ui.status(_('recording removal of %s as rename to %s '
335 repo.ui.status(_('recording removal of %s as rename to %s '
329 '(%d%% similar)\n') %
336 '(%d%% similar)\n') %
@@ -22,5 +22,6 b' hg commit -Ama'
22 mv a b
22 mv a b
23 rm c
23 rm c
24 echo d > d
24 echo d > d
25 hg addremove -n -s 50 # issue 1696
25 hg addremove -s 50
26 hg addremove -s 50
26 hg commit -mb
27 hg commit -mb
@@ -15,3 +15,8 b' adding b'
15 removing c
15 removing c
16 adding d
16 adding d
17 recording removal of a as rename to b (100% similar)
17 recording removal of a as rename to b (100% similar)
18 removing a
19 adding b
20 removing c
21 adding d
22 recording removal of a as rename to b (100% similar)
General Comments 0
You need to be logged in to leave comments. Login now