comparison mercurial/cmdutil.py @ 39414:1cbe19eb496d

revert: stabilize status message of chunks selected interactively Unfortunately, patch.filterpatch() doesn't preserve the order of the input files. We have to sort them manually.
author Yuya Nishihara <yuya@tcha.org>
date Mon, 03 Sep 2018 23:03:19 +0900
parents cb70501d8b71
children fd805a44b89d
comparison
equal deleted inserted replaced
39413:babad5ebaf0a 39414:1cbe19eb496d
3150 newlyaddedandmodifiedfiles = newandmodified(chunks, originalchunks) 3150 newlyaddedandmodifiedfiles = newandmodified(chunks, originalchunks)
3151 if tobackup is None: 3151 if tobackup is None:
3152 tobackup = set() 3152 tobackup = set()
3153 # Apply changes 3153 # Apply changes
3154 fp = stringio() 3154 fp = stringio()
3155 # `fnames` keeps track of filenames for which we have initiated changes, 3155 # chunks are serialized per file, but files aren't sorted
3156 # to make sure that we print status msg only once per file. 3156 for f in sorted(set(c.header.filename() for c in chunks if ishunk(c))):
3157 fnames = set() 3157 prntstatusmsg('revert', f)
3158 for c in chunks: 3158 for c in chunks:
3159 if ishunk(c): 3159 if ishunk(c):
3160 abs = c.header.filename() 3160 abs = c.header.filename()
3161 if abs not in fnames:
3162 fnames.add(abs)
3163 prntstatusmsg('revert', abs)
3164 # Create a backup file only if this hunk should be backed up 3161 # Create a backup file only if this hunk should be backed up
3165 if c.header.filename() in tobackup: 3162 if c.header.filename() in tobackup:
3166 target = repo.wjoin(abs) 3163 target = repo.wjoin(abs)
3167 bakname = scmutil.origpath(repo.ui, repo, m.rel(abs)) 3164 bakname = scmutil.origpath(repo.ui, repo, m.rel(abs))
3168 util.copyfile(target, bakname) 3165 util.copyfile(target, bakname)