Show More
@@ -374,7 +374,7 b' def record(ui, repo, *pats, **opts):' | |||||
374 |
|
374 | |||
375 | This command is not available when committing a merge.''' |
|
375 | This command is not available when committing a merge.''' | |
376 |
|
376 | |||
377 | dorecord(ui, repo, commands.commit, 'commit', *pats, **opts) |
|
377 | dorecord(ui, repo, commands.commit, 'commit', False, *pats, **opts) | |
378 |
|
378 | |||
379 |
|
379 | |||
380 | def qrecord(ui, repo, patch, *pats, **opts): |
|
380 | def qrecord(ui, repo, patch, *pats, **opts): | |
@@ -395,10 +395,9 b' def qrecord(ui, repo, patch, *pats, **op' | |||||
395 | opts['checkname'] = False |
|
395 | opts['checkname'] = False | |
396 | mq.new(ui, repo, patch, *pats, **opts) |
|
396 | mq.new(ui, repo, patch, *pats, **opts) | |
397 |
|
397 | |||
398 | dorecord(ui, repo, committomq, 'qnew', *pats, **opts) |
|
398 | dorecord(ui, repo, committomq, 'qnew', False, *pats, **opts) | |
399 |
|
399 | |||
400 |
|
400 | def dorecord(ui, repo, commitfunc, cmdsuggest, backupall, *pats, **opts): | ||
401 | def dorecord(ui, repo, commitfunc, cmdsuggest, *pats, **opts): |
|
|||
402 | if not ui.interactive(): |
|
401 | if not ui.interactive(): | |
403 | raise util.Abort(_('running non-interactively, use %s instead') % |
|
402 | raise util.Abort(_('running non-interactively, use %s instead') % | |
404 | cmdsuggest) |
|
403 | cmdsuggest) | |
@@ -450,7 +449,13 b' def dorecord(ui, repo, commitfunc, cmdsu' | |||||
450 | modified = set(changes[0]) |
|
449 | modified = set(changes[0]) | |
451 |
|
450 | |||
452 | # 2. backup changed files, so we can restore them in the end |
|
451 | # 2. backup changed files, so we can restore them in the end | |
|
452 | if backupall: | |||
|
453 | tobackup = changed | |||
|
454 | else: | |||
|
455 | tobackup = [f for f in newfiles if f in modified] | |||
|
456 | ||||
453 | backups = {} |
|
457 | backups = {} | |
|
458 | if tobackup: | |||
454 | backupdir = repo.join('record-backups') |
|
459 | backupdir = repo.join('record-backups') | |
455 | try: |
|
460 | try: | |
456 | os.mkdir(backupdir) |
|
461 | os.mkdir(backupdir) | |
@@ -459,9 +464,7 b' def dorecord(ui, repo, commitfunc, cmdsu' | |||||
459 | raise |
|
464 | raise | |
460 | try: |
|
465 | try: | |
461 | # backup continues |
|
466 | # backup continues | |
462 |
for f in |
|
467 | for f in tobackup: | |
463 | if f not in modified: |
|
|||
464 | continue |
|
|||
465 | fd, tmpname = tempfile.mkstemp(prefix=f.replace('/', '_')+'.', |
|
468 | fd, tmpname = tempfile.mkstemp(prefix=f.replace('/', '_')+'.', | |
466 | dir=backupdir) |
|
469 | dir=backupdir) | |
467 | os.close(fd) |
|
470 | os.close(fd) | |
@@ -522,6 +525,7 b' def dorecord(ui, repo, commitfunc, cmdsu' | |||||
522 | # writing it. |
|
525 | # writing it. | |
523 | shutil.copystat(tmpname, repo.wjoin(realname)) |
|
526 | shutil.copystat(tmpname, repo.wjoin(realname)) | |
524 | os.unlink(tmpname) |
|
527 | os.unlink(tmpname) | |
|
528 | if tobackup: | |||
525 | os.rmdir(backupdir) |
|
529 | os.rmdir(backupdir) | |
526 | except OSError: |
|
530 | except OSError: | |
527 | pass |
|
531 | pass |
General Comments 0
You need to be logged in to leave comments.
Login now