Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/commands.py @ 2407:8fe3d60b7f19
revert: better fix for not printing 'reverting' message
author | Vadim Gelfer <vadim.gelfer@gmail.com> |
---|---|
date | Wed, 07 Jun 2006 13:16:25 -0700 |
parents | 4a678e408ce5 |
children | 1e80d47b8581 |
comparison
equal
deleted
inserted
replaced
2406:4a678e408ce5 | 2407:8fe3d60b7f19 |
---|---|
2324 elif p2 != nullid: | 2324 elif p2 != nullid: |
2325 raise util.Abort(_('working dir has two parents; ' | 2325 raise util.Abort(_('working dir has two parents; ' |
2326 'you must specify the revision to revert to')) | 2326 'you must specify the revision to revert to')) |
2327 else: | 2327 else: |
2328 node = parent | 2328 node = parent |
2329 pmf = None | |
2330 mf = repo.manifest.read(repo.changelog.read(node)[0]) | 2329 mf = repo.manifest.read(repo.changelog.read(node)[0]) |
2330 if node == parent: | |
2331 pmf = mf | |
2332 else: | |
2333 pmf = None | |
2331 | 2334 |
2332 wlock = repo.wlock() | 2335 wlock = repo.wlock() |
2333 | 2336 |
2334 # need all matching names in dirstate and manifest of target rev, | 2337 # need all matching names in dirstate and manifest of target rev, |
2335 # so have to walk both. do not print errors if files exist in one | 2338 # so have to walk both. do not print errors if files exist in one |
2351 badmatch=names.has_key): | 2354 badmatch=names.has_key): |
2352 if abs in names: continue | 2355 if abs in names: continue |
2353 names[abs] = (rel, exact) | 2356 names[abs] = (rel, exact) |
2354 target_only[abs] = True | 2357 target_only[abs] = True |
2355 | 2358 |
2356 changes = repo.changes(node, match=names.has_key, wlock=wlock) | 2359 changes = repo.changes(match=names.has_key, wlock=wlock) |
2357 modified, added, removed, deleted, unknown = map(dict.fromkeys, changes) | 2360 modified, added, removed, deleted, unknown = map(dict.fromkeys, changes) |
2358 | 2361 |
2359 revert = ([], _('reverting %s\n')) | 2362 revert = ([], _('reverting %s\n')) |
2360 add = ([], _('adding %s\n')) | 2363 add = ([], _('adding %s\n')) |
2361 remove = ([], _('removing %s\n')) | 2364 remove = ([], _('removing %s\n')) |
2380 | 2383 |
2381 entries = names.items() | 2384 entries = names.items() |
2382 entries.sort() | 2385 entries.sort() |
2383 | 2386 |
2384 for abs, (rel, exact) in entries: | 2387 for abs, (rel, exact) in entries: |
2385 in_mf = abs in mf | 2388 mfentry = mf.get(abs) |
2386 def handle(xlist, dobackup): | 2389 def handle(xlist, dobackup): |
2387 xlist[0].append(abs) | 2390 xlist[0].append(abs) |
2391 update[abs] = 1 | |
2388 if dobackup and not opts['no_backup'] and os.path.exists(rel): | 2392 if dobackup and not opts['no_backup'] and os.path.exists(rel): |
2389 bakname = "%s.orig" % rel | 2393 bakname = "%s.orig" % rel |
2390 ui.note(_('saving current version of %s as %s\n') % | 2394 ui.note(_('saving current version of %s as %s\n') % |
2391 (rel, bakname)) | 2395 (rel, bakname)) |
2392 shutil.copyfile(rel, bakname) | 2396 shutil.copyfile(rel, bakname) |
2394 if ui.verbose or not exact: | 2398 if ui.verbose or not exact: |
2395 ui.status(xlist[1] % rel) | 2399 ui.status(xlist[1] % rel) |
2396 for table, hitlist, misslist, backuphit, backupmiss in disptable: | 2400 for table, hitlist, misslist, backuphit, backupmiss in disptable: |
2397 if abs not in table: continue | 2401 if abs not in table: continue |
2398 # file has changed in dirstate | 2402 # file has changed in dirstate |
2399 if in_mf: | 2403 if mfentry: |
2400 handle(hitlist, backuphit) | 2404 handle(hitlist, backuphit) |
2401 elif misslist is not None: | 2405 elif misslist is not None: |
2402 handle(misslist, backupmiss) | 2406 handle(misslist, backupmiss) |
2403 else: | 2407 else: |
2404 if exact: ui.warn(_('file not managed: %s\n' % rel)) | 2408 if exact: ui.warn(_('file not managed: %s\n' % rel)) |
2406 else: | 2410 else: |
2407 # file has not changed in dirstate | 2411 # file has not changed in dirstate |
2408 if node == parent: | 2412 if node == parent: |
2409 if exact: ui.warn(_('no changes needed to %s\n' % rel)) | 2413 if exact: ui.warn(_('no changes needed to %s\n' % rel)) |
2410 continue | 2414 continue |
2411 if not in_mf: | 2415 if pmf is None: |
2412 if pmf is None: | 2416 # only need parent manifest in this unlikely case, |
2413 # only need parent manifest in this unlikely case, | 2417 # so do not read by default |
2414 # so do not read by default | 2418 pmf = repo.manifest.read(repo.changelog.read(parent)[0]) |
2415 pmf = repo.manifest.read(repo.changelog.read(parent)[0]) | 2419 if abs in pmf: |
2416 if abs in pmf: | 2420 if mfentry: |
2421 # if version of file is same in parent and target | |
2422 # manifests, do nothing | |
2423 if pmf[abs] != mfentry: | |
2424 handle(revert, False) | |
2425 else: | |
2417 handle(remove, False) | 2426 handle(remove, False) |
2418 update[abs] = True | |
2419 | 2427 |
2420 repo.dirstate.forget(forget[0]) | 2428 repo.dirstate.forget(forget[0]) |
2421 r = repo.update(node, False, True, update.has_key, False, wlock=wlock, | 2429 r = repo.update(node, False, True, update.has_key, False, wlock=wlock, |
2422 show_stats=False) | 2430 show_stats=False) |
2423 repo.dirstate.update(add[0], 'a') | 2431 repo.dirstate.update(add[0], 'a') |