Show More
@@ -574,82 +574,61 b' class localrepository(repo.repository):' | |||||
574 | return fl.add(t, meta, transaction, linkrev, fp1, fp2) |
|
574 | return fl.add(t, meta, transaction, linkrev, fp1, fp2) | |
575 |
|
575 | |||
576 | def rawcommit(self, files, text, user, date, p1=None, p2=None, wlock=None): |
|
576 | def rawcommit(self, files, text, user, date, p1=None, p2=None, wlock=None): | |
577 | orig_parent = self.dirstate.parents()[0] or nullid |
|
577 | if p1 is None: | |
578 |
p1 = |
|
578 | p1, p2 = self.dirstate.parents() | |
579 | p2 = p2 or self.dirstate.parents()[1] or nullid |
|
579 | return self.commit(files=files, text=text, user=user, date=date, | |
580 | c1 = self.changelog.read(p1) |
|
580 | p1=p1, p2=p2, wlock=wlock) | |
581 | c2 = self.changelog.read(p2) |
|
|||
582 | m1 = self.manifest.read(c1[0]).copy() |
|
|||
583 | m2 = self.manifest.read(c2[0]) |
|
|||
584 | changed = [] |
|
|||
585 | removed = [] |
|
|||
586 |
|
||||
587 | if orig_parent == p1: |
|
|||
588 | update_dirstate = 1 |
|
|||
589 | else: |
|
|||
590 | update_dirstate = 0 |
|
|||
591 |
|
||||
592 | if not wlock: |
|
|||
593 | wlock = self.wlock() |
|
|||
594 | l = self.lock() |
|
|||
595 | tr = self.transaction() |
|
|||
596 | linkrev = self.changelog.count() |
|
|||
597 | for f in files: |
|
|||
598 | try: |
|
|||
599 | m1[f] = self.filecommit(f, m1, m2, linkrev, tr, changed) |
|
|||
600 | m1.set(f, util.is_exec(self.wjoin(f), m1.execf(f))) |
|
|||
601 | except IOError: |
|
|||
602 | try: |
|
|||
603 | del m1[f] |
|
|||
604 | if update_dirstate: |
|
|||
605 | self.dirstate.forget([f]) |
|
|||
606 | removed.append(f) |
|
|||
607 | except: |
|
|||
608 | # deleted from p2? |
|
|||
609 | pass |
|
|||
610 |
|
||||
611 | mnode = self.manifest.add(m1, tr, linkrev, c1[0], c2[0]) |
|
|||
612 | user = user or self.ui.username() |
|
|||
613 | n = self.changelog.add(mnode, changed + removed, text, |
|
|||
614 | tr, p1, p2, user, date) |
|
|||
615 | tr.close() |
|
|||
616 | if update_dirstate: |
|
|||
617 | self.dirstate.setparents(n, nullid) |
|
|||
618 |
|
581 | |||
619 | def commit(self, files=None, text="", user=None, date=None, |
|
582 | def commit(self, files=None, text="", user=None, date=None, | |
620 | match=util.always, force=False, lock=None, wlock=None, |
|
583 | match=util.always, force=False, lock=None, wlock=None, | |
621 | force_editor=False): |
|
584 | force_editor=False, p1=None, p2=None): | |
|
585 | ||||
622 | commit = [] |
|
586 | commit = [] | |
623 | remove = [] |
|
587 | remove = [] | |
624 | changed = [] |
|
588 | changed = [] | |
|
589 | use_dirstate = (p1 is None) # not rawcommit | |||
625 |
|
590 | |||
626 |
if |
|
591 | if use_dirstate: | |
627 |
|
|
592 | if files: | |
628 | s = self.dirstate.state(f) |
|
593 | for f in files: | |
629 | if s in 'nmai': |
|
594 | s = self.dirstate.state(f) | |
630 |
|
|
595 | if s in 'nmai': | |
631 | elif s == 'r': |
|
596 | commit.append(f) | |
632 |
|
|
597 | elif s == 'r': | |
633 | else: |
|
598 | remove.append(f) | |
634 | self.ui.warn(_("%s not tracked!\n") % f) |
|
599 | else: | |
|
600 | self.ui.warn(_("%s not tracked!\n") % f) | |||
|
601 | else: | |||
|
602 | changes = self.status(match=match)[:5] | |||
|
603 | modified, added, removed, deleted, unknown = changes | |||
|
604 | commit = modified + added | |||
|
605 | remove = removed | |||
635 | else: |
|
606 | else: | |
636 | modified, added, removed, deleted, unknown = self.status(match=match)[:5] |
|
607 | commit = files | |
637 | commit = modified + added |
|
|||
638 | remove = removed |
|
|||
639 |
|
608 | |||
640 | p1, p2 = self.dirstate.parents() |
|
609 | if use_dirstate: | |
|
610 | p1, p2 = self.dirstate.parents() | |||
|
611 | update_dirstate = True | |||
|
612 | else: | |||
|
613 | p1, p2 = p1, p2 or nullid | |||
|
614 | update_dirstate = (self.dirstate.parents()[0] == p1) | |||
|
615 | ||||
641 | c1 = self.changelog.read(p1) |
|
616 | c1 = self.changelog.read(p1) | |
642 | c2 = self.changelog.read(p2) |
|
617 | c2 = self.changelog.read(p2) | |
643 | m1 = self.manifest.read(c1[0]).copy() |
|
618 | m1 = self.manifest.read(c1[0]).copy() | |
644 | m2 = self.manifest.read(c2[0]) |
|
619 | m2 = self.manifest.read(c2[0]) | |
645 |
|
620 | |||
646 | branchname = self.workingctx().branch() |
|
621 | if use_dirstate: | |
647 | oldname = c1[5].get("branch", "") |
|
622 | branchname = self.workingctx().branch() | |
|
623 | else: | |||
|
624 | branchname = "" | |||
648 |
|
625 | |||
649 | if not commit and not remove and not force and p2 == nullid and \ |
|
626 | if use_dirstate: | |
650 | branchname == oldname: |
|
627 | oldname = c1[5].get("branch", "") | |
651 | self.ui.status(_("nothing changed\n")) |
|
628 | if not commit and not remove and not force and p2 == nullid and \ | |
652 | return None |
|
629 | branchname == oldname: | |
|
630 | self.ui.status(_("nothing changed\n")) | |||
|
631 | return None | |||
653 |
|
632 | |||
654 | xp1 = hex(p1) |
|
633 | xp1 = hex(p1) | |
655 | if p2 == nullid: xp2 = '' |
|
634 | if p2 == nullid: xp2 = '' | |
@@ -674,8 +653,11 b' class localrepository(repo.repository):' | |||||
674 | m1.set(f, util.is_exec(self.wjoin(f), m1.execf(f))) |
|
653 | m1.set(f, util.is_exec(self.wjoin(f), m1.execf(f))) | |
675 | new.append(f) |
|
654 | new.append(f) | |
676 | except IOError: |
|
655 | except IOError: | |
677 | self.ui.warn(_("trouble committing %s!\n") % f) |
|
656 | if use_dirstate: | |
678 | raise |
|
657 | self.ui.warn(_("trouble committing %s!\n") % f) | |
|
658 | raise | |||
|
659 | else: | |||
|
660 | remove.append(f) | |||
679 |
|
661 | |||
680 | # update manifest |
|
662 | # update manifest | |
681 | remove.sort() |
|
663 | remove.sort() | |
@@ -720,9 +702,11 b' class localrepository(repo.repository):' | |||||
720 | parent2=xp2) |
|
702 | parent2=xp2) | |
721 | tr.close() |
|
703 | tr.close() | |
722 |
|
704 | |||
723 | self.dirstate.setparents(n) |
|
705 | if use_dirstate or update_dirstate: | |
724 |
self.dirstate. |
|
706 | self.dirstate.setparents(n) | |
725 | self.dirstate.forget(remove) |
|
707 | if use_dirstate: | |
|
708 | self.dirstate.update(new, "n") | |||
|
709 | self.dirstate.forget(remove) | |||
726 |
|
710 | |||
727 | self.hook("commit", node=hex(n), parent1=xp1, parent2=xp2) |
|
711 | self.hook("commit", node=hex(n), parent1=xp1, parent2=xp2) | |
728 | return n |
|
712 | return n |
General Comments 0
You need to be logged in to leave comments.
Login now