572 |
572 |
573 changelist.append(fn) |
573 changelist.append(fn) |
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 = p1 or self.dirstate.parents()[0] or nullid |
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 p1=p1, p2=p2, wlock=wlock) |
|
581 |
|
582 def commit(self, files=None, text="", user=None, date=None, |
|
583 match=util.always, force=False, lock=None, wlock=None, |
|
584 force_editor=False, p1=None, p2=None): |
|
585 |
|
586 commit = [] |
|
587 remove = [] |
|
588 changed = [] |
|
589 use_dirstate = (p1 is None) # not rawcommit |
|
590 |
|
591 if use_dirstate: |
|
592 if files: |
|
593 for f in files: |
|
594 s = self.dirstate.state(f) |
|
595 if s in 'nmai': |
|
596 commit.append(f) |
|
597 elif s == 'r': |
|
598 remove.append(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 |
|
606 else: |
|
607 commit = files |
|
608 |
|
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 |
580 c1 = self.changelog.read(p1) |
616 c1 = self.changelog.read(p1) |
581 c2 = self.changelog.read(p2) |
617 c2 = self.changelog.read(p2) |
582 m1 = self.manifest.read(c1[0]).copy() |
618 m1 = self.manifest.read(c1[0]).copy() |
583 m2 = self.manifest.read(c2[0]) |
619 m2 = self.manifest.read(c2[0]) |
584 changed = [] |
620 |
585 removed = [] |
621 if use_dirstate: |
586 |
622 branchname = self.workingctx().branch() |
587 if orig_parent == p1: |
|
588 update_dirstate = 1 |
|
589 else: |
623 else: |
590 update_dirstate = 0 |
624 branchname = "" |
591 |
625 |
592 if not wlock: |
626 if use_dirstate: |
593 wlock = self.wlock() |
627 oldname = c1[5].get("branch", "") |
594 l = self.lock() |
628 if not commit and not remove and not force and p2 == nullid and \ |
595 tr = self.transaction() |
629 branchname == oldname: |
596 linkrev = self.changelog.count() |
630 self.ui.status(_("nothing changed\n")) |
597 for f in files: |
631 return None |
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 |
|
619 def commit(self, files=None, text="", user=None, date=None, |
|
620 match=util.always, force=False, lock=None, wlock=None, |
|
621 force_editor=False): |
|
622 commit = [] |
|
623 remove = [] |
|
624 changed = [] |
|
625 |
|
626 if files: |
|
627 for f in files: |
|
628 s = self.dirstate.state(f) |
|
629 if s in 'nmai': |
|
630 commit.append(f) |
|
631 elif s == 'r': |
|
632 remove.append(f) |
|
633 else: |
|
634 self.ui.warn(_("%s not tracked!\n") % f) |
|
635 else: |
|
636 modified, added, removed, deleted, unknown = self.status(match=match)[:5] |
|
637 commit = modified + added |
|
638 remove = removed |
|
639 |
|
640 p1, p2 = self.dirstate.parents() |
|
641 c1 = self.changelog.read(p1) |
|
642 c2 = self.changelog.read(p2) |
|
643 m1 = self.manifest.read(c1[0]).copy() |
|
644 m2 = self.manifest.read(c2[0]) |
|
645 |
|
646 branchname = self.workingctx().branch() |
|
647 oldname = c1[5].get("branch", "") |
|
648 |
|
649 if not commit and not remove and not force and p2 == nullid and \ |
|
650 branchname == oldname: |
|
651 self.ui.status(_("nothing changed\n")) |
|
652 return None |
|
653 |
632 |
654 xp1 = hex(p1) |
633 xp1 = hex(p1) |
655 if p2 == nullid: xp2 = '' |
634 if p2 == nullid: xp2 = '' |
656 else: xp2 = hex(p2) |
635 else: xp2 = hex(p2) |
657 |
636 |
718 user, date, extra) |
700 user, date, extra) |
719 self.hook('pretxncommit', throw=True, node=hex(n), parent1=xp1, |
701 self.hook('pretxncommit', throw=True, node=hex(n), parent1=xp1, |
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.update(new, "n") |
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 |
729 |
713 |
730 def walk(self, node=None, files=[], match=util.always, badmatch=None): |
714 def walk(self, node=None, files=[], match=util.always, badmatch=None): |