comparison mercurial/scmutil.py @ 48315:a44bb185f6bd stable 6.0rc0

merge with default
author Pulkit Goyal <7895pulkit@gmail.com>
date Tue, 09 Nov 2021 21:56:04 +0530
parents 1c447fb82232 207df24a31f6
children 0b8e076e878c
comparison
equal deleted inserted replaced
48314:6f43569729d4 48315:a44bb185f6bd
687 if not revspec and revspec != 0: 687 if not revspec and revspec != 0:
688 return repo[default] 688 return repo[default]
689 689
690 l = revrange(repo, [revspec], localalias=localalias) 690 l = revrange(repo, [revspec], localalias=localalias)
691 if not l: 691 if not l:
692 raise error.Abort(_(b'empty revision set')) 692 raise error.InputError(_(b'empty revision set'))
693 return repo[l.last()] 693 return repo[l.last()]
694 694
695 695
696 def _pairspec(revspec): 696 def _pairspec(revspec):
697 tree = revsetlang.parse(revspec) 697 tree = revsetlang.parse(revspec)
708 return repo[b'.'], repo[None] 708 return repo[b'.'], repo[None]
709 709
710 l = revrange(repo, revs) 710 l = revrange(repo, revs)
711 711
712 if not l: 712 if not l:
713 raise error.Abort(_(b'empty revision range')) 713 raise error.InputError(_(b'empty revision range'))
714 714
715 first = l.first() 715 first = l.first()
716 second = l.last() 716 second = l.last()
717 717
718 if ( 718 if (
719 first == second 719 first == second
720 and len(revs) >= 2 720 and len(revs) >= 2
721 and not all(revrange(repo, [r]) for r in revs) 721 and not all(revrange(repo, [r]) for r in revs)
722 ): 722 ):
723 raise error.Abort(_(b'empty revision on one side of range')) 723 raise error.InputError(_(b'empty revision on one side of range'))
724 724
725 # if top-level is range expression, the result must always be a pair 725 # if top-level is range expression, the result must always be a pair
726 if first == second and len(revs) == 1 and not _pairspec(revs[0]): 726 if first == second and len(revs) == 1 and not _pairspec(revs[0]):
727 return repo[first], repo[None] 727 return repo[first], repo[None]
728 728
1209 m = matcher 1209 m = matcher
1210 dry_run = opts.get(b'dry_run') 1210 dry_run = opts.get(b'dry_run')
1211 try: 1211 try:
1212 similarity = float(opts.get(b'similarity') or 0) 1212 similarity = float(opts.get(b'similarity') or 0)
1213 except ValueError: 1213 except ValueError:
1214 raise error.Abort(_(b'similarity must be a number')) 1214 raise error.InputError(_(b'similarity must be a number'))
1215 if similarity < 0 or similarity > 100: 1215 if similarity < 0 or similarity > 100:
1216 raise error.Abort(_(b'similarity must be between 0 and 100')) 1216 raise error.InputError(_(b'similarity must be between 0 and 100'))
1217 similarity /= 100.0 1217 similarity /= 100.0
1218 1218
1219 ret = 0 1219 ret = 0
1220 1220
1221 wctx = repo[None] 1221 wctx = repo[None]
1325 unknown=True, 1325 unknown=True,
1326 ignored=False, 1326 ignored=False,
1327 full=False, 1327 full=False,
1328 ) 1328 )
1329 for abs, st in pycompat.iteritems(walkresults): 1329 for abs, st in pycompat.iteritems(walkresults):
1330 dstate = dirstate[abs] 1330 entry = dirstate.get_entry(abs)
1331 if dstate == b'?' and audit_path.check(abs): 1331 if (not entry.any_tracked) and audit_path.check(abs):
1332 unknown.append(abs) 1332 unknown.append(abs)
1333 elif dstate != b'r' and not st: 1333 elif (not entry.removed) and not st:
1334 deleted.append(abs) 1334 deleted.append(abs)
1335 elif dstate == b'r' and st: 1335 elif entry.removed and st:
1336 forgotten.append(abs) 1336 forgotten.append(abs)
1337 # for finding renames 1337 # for finding renames
1338 elif dstate == b'r' and not st: 1338 elif entry.removed and not st:
1339 removed.append(abs) 1339 removed.append(abs)
1340 elif dstate == b'a': 1340 elif entry.added:
1341 added.append(abs) 1341 added.append(abs)
1342 1342
1343 return added, unknown, deleted, removed, forgotten 1343 return added, unknown, deleted, removed, forgotten
1344 1344
1345 1345
1453 """Update the dirstate to reflect the intent of copying src to dst. For 1453 """Update the dirstate to reflect the intent of copying src to dst. For
1454 different reasons it might not end with dst being marked as copied from src. 1454 different reasons it might not end with dst being marked as copied from src.
1455 """ 1455 """
1456 origsrc = repo.dirstate.copied(src) or src 1456 origsrc = repo.dirstate.copied(src) or src
1457 if dst == origsrc: # copying back a copy? 1457 if dst == origsrc: # copying back a copy?
1458 if repo.dirstate[dst] not in b'mn' and not dryrun: 1458 entry = repo.dirstate.get_entry(dst)
1459 if (entry.added or not entry.tracked) and not dryrun:
1459 repo.dirstate.set_tracked(dst) 1460 repo.dirstate.set_tracked(dst)
1460 else: 1461 else:
1461 if repo.dirstate[origsrc] == b'a' and origsrc == src: 1462 if repo.dirstate.get_entry(origsrc).added and origsrc == src:
1462 if not ui.quiet: 1463 if not ui.quiet:
1463 ui.warn( 1464 ui.warn(
1464 _( 1465 _(
1465 b"%s has not been committed yet, so no copy " 1466 b"%s has not been committed yet, so no copy "
1466 b"data will be stored for %s.\n" 1467 b"data will be stored for %s.\n"
1467 ) 1468 )
1468 % (repo.pathto(origsrc, cwd), repo.pathto(dst, cwd)) 1469 % (repo.pathto(origsrc, cwd), repo.pathto(dst, cwd))
1469 ) 1470 )
1470 if repo.dirstate[dst] in b'?r' and not dryrun: 1471 if not repo.dirstate.get_entry(dst).tracked and not dryrun:
1471 wctx.add([dst]) 1472 wctx.add([dst])
1472 elif not dryrun: 1473 elif not dryrun:
1473 wctx.copy(origsrc, dst) 1474 wctx.copy(origsrc, dst)
1474 1475
1475 1476
1502 dst: oldcopies.get(src, src) 1503 dst: oldcopies.get(src, src)
1503 for dst, src in pycompat.iteritems(oldcopies) 1504 for dst, src in pycompat.iteritems(oldcopies)
1504 } 1505 }
1505 # Adjust the dirstate copies 1506 # Adjust the dirstate copies
1506 for dst, src in pycompat.iteritems(copies): 1507 for dst, src in pycompat.iteritems(copies):
1507 if src not in newctx or dst in newctx or ds[dst] != b'a': 1508 if src not in newctx or dst in newctx or not ds.get_entry(dst).added:
1508 src = None 1509 src = None
1509 ds.copy(src, dst) 1510 ds.copy(src, dst)
1510 repo._quick_access_changeid_invalidate() 1511 repo._quick_access_changeid_invalidate()
1511 1512
1512 1513