Show More
@@ -48,7 +48,7 b' def makewalk(repo, pats, opts, node=None' | |||||
48 | exact = dict(zip(files, files)) |
|
48 | exact = dict(zip(files, files)) | |
49 | def walk(): |
|
49 | def walk(): | |
50 | for src, fn in repo.walk(node=node, files=files, match=matchfn, |
|
50 | for src, fn in repo.walk(node=node, files=files, match=matchfn, | |
51 |
badmatch= |
|
51 | badmatch=badmatch): | |
52 | yield src, fn, util.pathto(repo.getcwd(), fn), fn in exact |
|
52 | yield src, fn, util.pathto(repo.getcwd(), fn), fn in exact | |
53 | return files, matchfn, walk() |
|
53 | return files, matchfn, walk() | |
54 |
|
54 | |||
@@ -2349,11 +2349,27 b' def revert(ui, repo, *pats, **opts):' | |||||
2349 |
|
2349 | |||
2350 | wlock = repo.wlock() |
|
2350 | wlock = repo.wlock() | |
2351 |
|
2351 | |||
2352 | entries = [] |
|
2352 | # need all matching names in dirstate and manifest of target rev, | |
|
2353 | # so have to walk both. do not print errors if files exist in one | |||
|
2354 | # but not other. | |||
|
2355 | ||||
2353 | names = {} |
|
2356 | names = {} | |
|
2357 | target_only = {} | |||
|
2358 | ||||
|
2359 | # walk dirstate. | |||
|
2360 | ||||
2354 | for src, abs, rel, exact in walk(repo, pats, opts, badmatch=mf.has_key): |
|
2361 | for src, abs, rel, exact in walk(repo, pats, opts, badmatch=mf.has_key): | |
2355 |
names[abs] = |
|
2362 | names[abs] = (rel, exact) | |
2356 | entries.append((abs, rel, exact)) |
|
2363 | if src == 'b': | |
|
2364 | target_only[abs] = True | |||
|
2365 | ||||
|
2366 | # walk target manifest. | |||
|
2367 | ||||
|
2368 | for src, abs, rel, exact in walk(repo, pats, opts, node=node, | |||
|
2369 | badmatch=names.has_key): | |||
|
2370 | if abs in names: continue | |||
|
2371 | names[abs] = (rel, exact) | |||
|
2372 | target_only[abs] = True | |||
2357 |
|
2373 | |||
2358 | changes = repo.changes(match=names.has_key, wlock=wlock) |
|
2374 | changes = repo.changes(match=names.has_key, wlock=wlock) | |
2359 | modified, added, removed, deleted, unknown = map(dict.fromkeys, changes) |
|
2375 | modified, added, removed, deleted, unknown = map(dict.fromkeys, changes) | |
@@ -2377,9 +2393,14 b' def revert(ui, repo, *pats, **opts):' | |||||
2377 | (removed, undelete, None, False, False), |
|
2393 | (removed, undelete, None, False, False), | |
2378 | (deleted, revert, remove, False, False), |
|
2394 | (deleted, revert, remove, False, False), | |
2379 | (unknown, add, None, True, False), |
|
2395 | (unknown, add, None, True, False), | |
|
2396 | (target_only, add, None, False, False), | |||
2380 | ) |
|
2397 | ) | |
2381 |
|
2398 | |||
2382 | for abs, rel, exact in entries: |
|
2399 | entries = names.items() | |
|
2400 | entries.sort() | |||
|
2401 | ||||
|
2402 | for abs, (rel, exact) in entries: | |||
|
2403 | in_mf = abs in mf | |||
2383 | def handle(xlist, dobackup): |
|
2404 | def handle(xlist, dobackup): | |
2384 | xlist[0].append(abs) |
|
2405 | xlist[0].append(abs) | |
2385 | if dobackup and not opts['no_backup'] and os.path.exists(rel): |
|
2406 | if dobackup and not opts['no_backup'] and os.path.exists(rel): | |
@@ -2393,7 +2414,7 b' def revert(ui, repo, *pats, **opts):' | |||||
2393 | for table, hitlist, misslist, backuphit, backupmiss in disptable: |
|
2414 | for table, hitlist, misslist, backuphit, backupmiss in disptable: | |
2394 | if abs not in table: continue |
|
2415 | if abs not in table: continue | |
2395 | # file has changed in dirstate |
|
2416 | # file has changed in dirstate | |
2396 |
if |
|
2417 | if in_mf: | |
2397 | handle(hitlist, backuphit) |
|
2418 | handle(hitlist, backuphit) | |
2398 | elif misslist is not None: |
|
2419 | elif misslist is not None: | |
2399 | handle(misslist, backupmiss) |
|
2420 | handle(misslist, backupmiss) | |
@@ -2405,8 +2426,8 b' def revert(ui, repo, *pats, **opts):' | |||||
2405 | if node == parent: |
|
2426 | if node == parent: | |
2406 | if exact: ui.warn(_('no changes needed to %s\n' % rel)) |
|
2427 | if exact: ui.warn(_('no changes needed to %s\n' % rel)) | |
2407 | continue |
|
2428 | continue | |
2408 |
if |
|
2429 | if not in_mf: | |
2409 |
remove |
|
2430 | handle(remove, False) | |
2410 | update[abs] = True |
|
2431 | update[abs] = True | |
2411 |
|
2432 | |||
2412 | repo.dirstate.forget(forget[0]) |
|
2433 | repo.dirstate.forget(forget[0]) |
@@ -294,7 +294,8 b' class dirstate(object):' | |||||
294 | kind)) |
|
294 | kind)) | |
295 | return False |
|
295 | return False | |
296 |
|
296 | |||
297 |
def statwalk(self, files=None, match=util.always, dc=None, ignored=False |
|
297 | def statwalk(self, files=None, match=util.always, dc=None, ignored=False, | |
|
298 | badmatch=None): | |||
298 | self.lazyread() |
|
299 | self.lazyread() | |
299 |
|
300 | |||
300 | # walk all files by default |
|
301 | # walk all files by default | |
@@ -311,11 +312,12 b' class dirstate(object):' | |||||
311 | return False |
|
312 | return False | |
312 | return match(file_) |
|
313 | return match(file_) | |
313 |
|
314 | |||
314 |
return self.walkhelper(files=files, statmatch=statmatch, dc=dc |
|
315 | return self.walkhelper(files=files, statmatch=statmatch, dc=dc, | |
|
316 | badmatch=badmatch) | |||
315 |
|
317 | |||
316 | def walk(self, files=None, match=util.always, dc=None): |
|
318 | def walk(self, files=None, match=util.always, dc=None, badmatch=None): | |
317 | # filter out the stat |
|
319 | # filter out the stat | |
318 | for src, f, st in self.statwalk(files, match, dc): |
|
320 | for src, f, st in self.statwalk(files, match, dc, badmatch=badmatch): | |
319 | yield src, f |
|
321 | yield src, f | |
320 |
|
322 | |||
321 | # walk recursively through the directory tree, finding all files |
|
323 | # walk recursively through the directory tree, finding all files | |
@@ -330,7 +332,7 b' class dirstate(object):' | |||||
330 | # dc is an optional arg for the current dirstate. dc is not modified |
|
332 | # dc is an optional arg for the current dirstate. dc is not modified | |
331 | # directly by this function, but might be modified by your statmatch call. |
|
333 | # directly by this function, but might be modified by your statmatch call. | |
332 | # |
|
334 | # | |
333 | def walkhelper(self, files, statmatch, dc): |
|
335 | def walkhelper(self, files, statmatch, dc, badmatch=None): | |
334 | # recursion free walker, faster than os.walk. |
|
336 | # recursion free walker, faster than os.walk. | |
335 | def findfiles(s): |
|
337 | def findfiles(s): | |
336 | work = [s] |
|
338 | work = [s] | |
@@ -379,9 +381,12 b' class dirstate(object):' | |||||
379 | found = True |
|
381 | found = True | |
380 | break |
|
382 | break | |
381 | if not found: |
|
383 | if not found: | |
382 | self.ui.warn('%s: %s\n' % ( |
|
384 | if inst.errno != errno.ENOENT or not badmatch: | |
383 | util.pathto(self.getcwd(), ff), |
|
385 | self.ui.warn('%s: %s\n' % ( | |
384 | inst.strerror)) |
|
386 | util.pathto(self.getcwd(), ff), | |
|
387 | inst.strerror)) | |||
|
388 | elif badmatch and badmatch(ff) and statmatch(ff, None): | |||
|
389 | yield 'b', ff, None | |||
385 | continue |
|
390 | continue | |
386 | if stat.S_ISDIR(st.st_mode): |
|
391 | if stat.S_ISDIR(st.st_mode): | |
387 | cmp1 = (lambda x, y: cmp(x[1], y[1])) |
|
392 | cmp1 = (lambda x, y: cmp(x[1], y[1])) |
@@ -498,7 +498,7 b' class localrepository(object):' | |||||
498 | self.ui.warn(_('%s: No such file in rev %s\n') % ( |
|
498 | self.ui.warn(_('%s: No such file in rev %s\n') % ( | |
499 | util.pathto(self.getcwd(), fn), short(node))) |
|
499 | util.pathto(self.getcwd(), fn), short(node))) | |
500 | else: |
|
500 | else: | |
501 | for src, fn in self.dirstate.walk(files, match): |
|
501 | for src, fn in self.dirstate.walk(files, match, badmatch=badmatch): | |
502 | yield src, fn |
|
502 | yield src, fn | |
503 |
|
503 | |||
504 | def changes(self, node1=None, node2=None, files=[], match=util.always, |
|
504 | def changes(self, node1=None, node2=None, files=[], match=util.always, |
@@ -2,8 +2,8 b'' | |||||
2 | A b |
|
2 | A b | |
3 | R a |
|
3 | R a | |
4 | reverting... |
|
4 | reverting... | |
|
5 | undeleting a | |||
5 | forgetting b |
|
6 | forgetting b | |
6 | undeleting a |
|
|||
7 | %%% should show b unknown and a back to normal |
|
7 | %%% should show b unknown and a back to normal | |
8 | ? b |
|
8 | ? b | |
9 | ? b.orig |
|
9 | ? b.orig | |
@@ -15,8 +15,8 b' A b' | |||||
15 | R a |
|
15 | R a | |
16 | ? b.orig |
|
16 | ? b.orig | |
17 | reverting... |
|
17 | reverting... | |
|
18 | undeleting a | |||
18 | forgetting b |
|
19 | forgetting b | |
19 | undeleting a |
|
|||
20 | %%% should show b unknown and a marked modified (merged) |
|
20 | %%% should show b unknown and a marked modified (merged) | |
21 | ? b |
|
21 | ? b | |
22 | ? b.orig |
|
22 | ? b.orig |
@@ -37,7 +37,21 b' hg revert a' | |||||
37 | echo %% should say file not managed |
|
37 | echo %% should say file not managed | |
38 | echo q > q |
|
38 | echo q > q | |
39 | hg revert q |
|
39 | hg revert q | |
|
40 | rm q | |||
40 | echo %% should say file not found |
|
41 | echo %% should say file not found | |
41 | hg revert notfound |
|
42 | hg revert notfound | |
|
43 | hg rm a | |||
|
44 | hg commit -m "second" -d "1000000 0" | |||
|
45 | echo z > z | |||
|
46 | hg add z | |||
|
47 | hg st | |||
|
48 | echo %% should add a, forget z | |||
|
49 | hg revert -r0 | |||
|
50 | echo %% should forget a | |||
|
51 | hg revert -rtip | |||
|
52 | rm -f a *.orig | |||
|
53 | echo %% should silently add a | |||
|
54 | hg revert -r0 a | |||
|
55 | hg st a | |||
42 |
|
56 | |||
43 | true |
|
57 | true |
@@ -1,5 +1,6 b'' | |||||
1 | %% Should show unknown |
|
1 | %% Should show unknown | |
2 | ? unknown |
|
2 | ? unknown | |
|
3 | removing b | |||
3 | %% Should show unknown and b removed |
|
4 | %% Should show unknown and b removed | |
4 | R b |
|
5 | R b | |
5 | ? unknown |
|
6 | ? unknown |
@@ -37,4 +37,15 b' no changes needed to a' | |||||
37 | %% should say file not managed |
|
37 | %% should say file not managed | |
38 | file not managed: q |
|
38 | file not managed: q | |
39 | %% should say file not found |
|
39 | %% should say file not found | |
40 |
notfound: No such file |
|
40 | notfound: No such file in rev 095eacd0c0d7 | |
|
41 | A z | |||
|
42 | ? b | |||
|
43 | ? b.orig | |||
|
44 | ? e.orig | |||
|
45 | %% should add a, forget z | |||
|
46 | adding a | |||
|
47 | forgetting z | |||
|
48 | %% should forget a | |||
|
49 | forgetting a | |||
|
50 | %% should silently add a | |||
|
51 | A a |
General Comments 0
You need to be logged in to leave comments.
Login now