##// END OF EJS Templates
record: add an option to backup all wc modifications...
Idan Kamara -
r14425:e8953450 default
parent child Browse files
Show More
@@ -374,7 +374,7 b' def record(ui, repo, *pats, **opts):'
374 374
375 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 380 def qrecord(ui, repo, patch, *pats, **opts):
@@ -395,10 +395,9 b' def qrecord(ui, repo, patch, *pats, **op'
395 395 opts['checkname'] = False
396 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
401 def dorecord(ui, repo, commitfunc, cmdsuggest, *pats, **opts):
400 def dorecord(ui, repo, commitfunc, cmdsuggest, backupall, *pats, **opts):
402 401 if not ui.interactive():
403 402 raise util.Abort(_('running non-interactively, use %s instead') %
404 403 cmdsuggest)
@@ -450,18 +449,22 b' def dorecord(ui, repo, commitfunc, cmdsu'
450 449 modified = set(changes[0])
451 450
452 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 457 backups = {}
454 backupdir = repo.join('record-backups')
455 try:
456 os.mkdir(backupdir)
457 except OSError, err:
458 if err.errno != errno.EEXIST:
459 raise
458 if tobackup:
459 backupdir = repo.join('record-backups')
460 try:
461 os.mkdir(backupdir)
462 except OSError, err:
463 if err.errno != errno.EEXIST:
464 raise
460 465 try:
461 466 # backup continues
462 for f in newfiles:
463 if f not in modified:
464 continue
467 for f in tobackup:
465 468 fd, tmpname = tempfile.mkstemp(prefix=f.replace('/', '_')+'.',
466 469 dir=backupdir)
467 470 os.close(fd)
@@ -522,7 +525,8 b' def dorecord(ui, repo, commitfunc, cmdsu'
522 525 # writing it.
523 526 shutil.copystat(tmpname, repo.wjoin(realname))
524 527 os.unlink(tmpname)
525 os.rmdir(backupdir)
528 if tobackup:
529 os.rmdir(backupdir)
526 530 except OSError:
527 531 pass
528 532
General Comments 0
You need to be logged in to leave comments. Login now