##// END OF EJS Templates
revert: better fix for not printing 'reverting' message
Vadim Gelfer -
r2407:8fe3d60b default
parent child Browse files
Show More
@@ -2326,8 +2326,11 b' def revert(ui, repo, *pats, **opts):'
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
@@ -2353,7 +2356,7 b' def revert(ui, repo, *pats, **opts):'
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'))
@@ -2382,9 +2385,10 b' def revert(ui, repo, *pats, **opts):'
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') %
@@ -2396,7 +2400,7 b' def revert(ui, repo, *pats, **opts):'
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)
@@ -2408,14 +2412,18 b' def revert(ui, repo, *pats, **opts):'
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,
@@ -1,5 +1,6 b''
1 # basic operation
1 # basic operation
2 adding a
2 adding a
3 reverting a
3 changeset 2:b38a34ddfd9f backs out changeset 1:a820f4f40a57
4 changeset 2:b38a34ddfd9f backs out changeset 1:a820f4f40a57
4 a
5 a
5 # file that was removed is recreated
6 # file that was removed is recreated
@@ -13,6 +14,7 b' changeset 3:0dd8a0ed5e99 backs out chang'
13 cat: a: No such file or directory
14 cat: a: No such file or directory
14 # backout with merge
15 # backout with merge
15 adding a
16 adding a
17 reverting a
16 changeset 3:6c77ecc28460 backs out changeset 1:314f55b1bf23
18 changeset 3:6c77ecc28460 backs out changeset 1:314f55b1bf23
17 merging with changeset 2:b66ea5b77abb
19 merging with changeset 2:b66ea5b77abb
18 merging a
20 merging a
@@ -54,3 +54,4 b' executable'
54 %% issue 241
54 %% issue 241
55 adding a
55 adding a
56 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
56 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
57 reverting a
General Comments 0
You need to be logged in to leave comments. Login now