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,18 +449,22 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 = {} | |
454 | backupdir = repo.join('record-backups') |
|
458 | if tobackup: | |
455 | try: |
|
459 | backupdir = repo.join('record-backups') | |
456 | os.mkdir(backupdir) |
|
460 | try: | |
457 | except OSError, err: |
|
461 | os.mkdir(backupdir) | |
458 | if err.errno != errno.EEXIST: |
|
462 | except OSError, err: | |
459 | raise |
|
463 | if err.errno != errno.EEXIST: | |
|
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,7 +525,8 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) | |
525 |
o |
|
528 | if tobackup: | |
|
529 | os.rmdir(backupdir) | |||
526 | except OSError: |
|
530 | except OSError: | |
527 | pass |
|
531 | pass | |
528 |
|
532 |
General Comments 0
You need to be logged in to leave comments.
Login now