Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/cmdutil.py @ 8488:4e1795cf6e94
addremove: mapping isn't really needed, simplify
author | Benoit Boissinot <benoit.boissinot@ens-lyon.org> |
---|---|
date | Sun, 17 May 2009 22:40:04 +0200 |
parents | e84a8482c6f2 |
children | 1a96f1d9599b |
comparison
equal
deleted
inserted
replaced
8484:15573b5dc78f | 8488:4e1795cf6e94 |
---|---|
284 if dry_run is None: | 284 if dry_run is None: |
285 dry_run = opts.get('dry_run') | 285 dry_run = opts.get('dry_run') |
286 if similarity is None: | 286 if similarity is None: |
287 similarity = float(opts.get('similarity') or 0) | 287 similarity = float(opts.get('similarity') or 0) |
288 add, remove = [], [] | 288 add, remove = [], [] |
289 mapping = {} | |
290 audit_path = util.path_auditor(repo.root) | 289 audit_path = util.path_auditor(repo.root) |
291 m = match(repo, pats, opts) | 290 m = match(repo, pats, opts) |
292 for abs in repo.walk(m): | 291 for abs in repo.walk(m): |
293 target = repo.wjoin(abs) | 292 target = repo.wjoin(abs) |
294 good = True | 293 good = True |
298 good = False | 297 good = False |
299 rel = m.rel(abs) | 298 rel = m.rel(abs) |
300 exact = m.exact(abs) | 299 exact = m.exact(abs) |
301 if good and abs not in repo.dirstate: | 300 if good and abs not in repo.dirstate: |
302 add.append(abs) | 301 add.append(abs) |
303 mapping[abs] = rel, m.exact(abs) | |
304 if repo.ui.verbose or not exact: | 302 if repo.ui.verbose or not exact: |
305 repo.ui.status(_('adding %s\n') % ((pats and rel) or abs)) | 303 repo.ui.status(_('adding %s\n') % ((pats and rel) or abs)) |
306 if repo.dirstate[abs] != 'r' and (not good or not util.lexists(target) | 304 if repo.dirstate[abs] != 'r' and (not good or not util.lexists(target) |
307 or (os.path.isdir(target) and not os.path.islink(target))): | 305 or (os.path.isdir(target) and not os.path.islink(target))): |
308 remove.append(abs) | 306 remove.append(abs) |
309 mapping[abs] = rel, exact | |
310 if repo.ui.verbose or not exact: | 307 if repo.ui.verbose or not exact: |
311 repo.ui.status(_('removing %s\n') % ((pats and rel) or abs)) | 308 repo.ui.status(_('removing %s\n') % ((pats and rel) or abs)) |
312 if not dry_run: | 309 if not dry_run: |
313 repo.remove(remove) | 310 repo.remove(remove) |
314 repo.add(add) | 311 repo.add(add) |
315 if similarity > 0: | 312 if similarity > 0: |
316 for old, new, score in findrenames(repo, add, remove, similarity): | 313 for old, new, score in findrenames(repo, add, remove, similarity): |
317 oldrel, oldexact = mapping[old] | 314 oldexact, newexact = m.exact(old), m.exact(new) |
318 newrel, newexact = mapping[new] | |
319 if repo.ui.verbose or not oldexact or not newexact: | 315 if repo.ui.verbose or not oldexact or not newexact: |
316 oldrel, newrel = m.rel(old), m.rel(new) | |
320 repo.ui.status(_('recording removal of %s as rename to %s ' | 317 repo.ui.status(_('recording removal of %s as rename to %s ' |
321 '(%d%% similar)\n') % | 318 '(%d%% similar)\n') % |
322 (oldrel, newrel, score * 100)) | 319 (oldrel, newrel, score * 100)) |
323 if not dry_run: | 320 if not dry_run: |
324 repo.copy(old, new) | 321 repo.copy(old, new) |