Mercurial > hg
comparison hgext/record.py @ 22921:75e7d4a0f135
record: access status fields by name rather than index
It is safe to pass the full status to patch.diff() since it does its
own slicing.
author | Martin von Zweigbergk <martinvonz@gmail.com> |
---|---|
date | Fri, 03 Oct 2014 10:44:07 -0700 |
parents | 23f3241406ff |
children | 41c03b7592ed |
comparison
equal
deleted
inserted
replaced
22920:e049338d1a7b | 22921:75e7d4a0f135 |
---|---|
517 merge = len(repo[None].parents()) > 1 | 517 merge = len(repo[None].parents()) > 1 |
518 if merge: | 518 if merge: |
519 raise util.Abort(_('cannot partially commit a merge ' | 519 raise util.Abort(_('cannot partially commit a merge ' |
520 '(use "hg commit" instead)')) | 520 '(use "hg commit" instead)')) |
521 | 521 |
522 changes = repo.status(match=match)[:3] | 522 status = repo.status(match=match) |
523 diffopts = opts.copy() | 523 diffopts = opts.copy() |
524 diffopts['nodates'] = True | 524 diffopts['nodates'] = True |
525 diffopts['git'] = True | 525 diffopts['git'] = True |
526 diffopts = patch.diffopts(ui, opts=diffopts) | 526 diffopts = patch.diffopts(ui, opts=diffopts) |
527 chunks = patch.diff(repo, changes=changes, opts=diffopts) | 527 chunks = patch.diff(repo, changes=status, opts=diffopts) |
528 fp = cStringIO.StringIO() | 528 fp = cStringIO.StringIO() |
529 fp.write(''.join(chunks)) | 529 fp.write(''.join(chunks)) |
530 fp.seek(0) | 530 fp.seek(0) |
531 | 531 |
532 # 1. filter patch, so we have intending-to apply subset of it | 532 # 1. filter patch, so we have intending-to apply subset of it |
542 try: | 542 try: |
543 contenders.update(set(h.files())) | 543 contenders.update(set(h.files())) |
544 except AttributeError: | 544 except AttributeError: |
545 pass | 545 pass |
546 | 546 |
547 changed = changes[0] + changes[1] + changes[2] | 547 changed = status.modified + status.added + status.removed |
548 newfiles = [f for f in changed if f in contenders] | 548 newfiles = [f for f in changed if f in contenders] |
549 if not newfiles: | 549 if not newfiles: |
550 ui.status(_('no changes to record\n')) | 550 ui.status(_('no changes to record\n')) |
551 return 0 | 551 return 0 |
552 | 552 |
553 modified = set(changes[0]) | 553 modified = set(status.modified) |
554 | 554 |
555 # 2. backup changed files, so we can restore them in the end | 555 # 2. backup changed files, so we can restore them in the end |
556 if backupall: | 556 if backupall: |
557 tobackup = changed | 557 tobackup = changed |
558 else: | 558 else: |