Show More
@@ -640,7 +640,7 b' class queue:' | |||
|
640 | 640 | raise util.Abort(_('"%s" cannot be used as the name of a patch') |
|
641 | 641 | % name) |
|
642 | 642 | |
|
643 | def new(self, repo, patch, *pats, **opts): | |
|
643 | def new(self, repo, patchfn, *pats, **opts): | |
|
644 | 644 | """options: |
|
645 | 645 | msg: a string or a no-argument function returning a string |
|
646 | 646 | """ |
@@ -650,9 +650,9 b' class queue:' | |||
|
650 | 650 | date = opts.get('date') |
|
651 | 651 | if date: |
|
652 | 652 | date = util.parsedate(date) |
|
653 | self.check_reserved_name(patch) | |
|
654 | if os.path.exists(self.join(patch)): | |
|
655 | raise util.Abort(_('patch "%s" already exists') % patch) | |
|
653 | self.check_reserved_name(patchfn) | |
|
654 | if os.path.exists(self.join(patchfn)): | |
|
655 | raise util.Abort(_('patch "%s" already exists') % patchfn) | |
|
656 | 656 | if opts.get('include') or opts.get('exclude') or pats: |
|
657 | 657 | match = cmdutil.match(repo, pats, opts) |
|
658 | 658 | # detect missing files in pats |
@@ -665,39 +665,55 b' class queue:' | |||
|
665 | 665 | match = cmdutil.match(repo, m + a + r) |
|
666 | 666 | commitfiles = m + a + r |
|
667 | 667 | self.check_toppatch(repo) |
|
668 | insert = self.full_series_end() | |
|
668 | 669 | wlock = repo.wlock() |
|
669 | 670 | try: |
|
670 | insert = self.full_series_end() | |
|
671 | if callable(msg): | |
|
672 | msg = msg() | |
|
673 | commitmsg = msg and msg or ("[mq]: %s" % patch) | |
|
674 | n = repo.commit(commitfiles, commitmsg, user, date, match=match, force=True) | |
|
675 |
if |
|
|
676 | raise util.Abort(_("repo commit failed")) | |
|
677 | self.full_series[insert:insert] = [patch] | |
|
678 | self.applied.append(statusentry(revlog.hex(n), patch)) | |
|
679 | self.parse_series() | |
|
680 | self.series_dirty = 1 | |
|
681 | self.applied_dirty = 1 | |
|
682 | p = self.opener(patch, "w") | |
|
683 | if date: | |
|
684 | p.write("# HG changeset patch\n") | |
|
685 |
if |
|
|
686 | p.write("# User " + user + "\n") | |
|
687 | p.write("# Date %d %d\n" % date) | |
|
688 | p.write("\n") | |
|
689 | elif user: | |
|
690 | p.write("From: " + user + "\n") | |
|
691 | p.write("\n") | |
|
692 | if msg: | |
|
693 |
|
|
|
694 | p.write(msg) | |
|
695 | p.close() | |
|
696 | wlock = None | |
|
697 | r = self.qrepo() | |
|
698 | if r: r.add([patch]) | |
|
699 | if commitfiles: | |
|
700 | self.refresh(repo, short=True, git=opts.get('git')) | |
|
671 | # if patch file write fails, abort early | |
|
672 | p = self.opener(patchfn, "w") | |
|
673 | try: | |
|
674 | if date: | |
|
675 | p.write("# HG changeset patch\n") | |
|
676 | if user: | |
|
677 | p.write("# User " + user + "\n") | |
|
678 | p.write("# Date %d %d\n\n" % date) | |
|
679 | elif user: | |
|
680 | p.write("From: " + user + "\n\n") | |
|
681 | ||
|
682 | if callable(msg): | |
|
683 | msg = msg() | |
|
684 | commitmsg = msg and msg or ("[mq]: %s" % patchfn) | |
|
685 | n = repo.commit(commitfiles, commitmsg, user, date, match=match, force=True) | |
|
686 | if n == None: | |
|
687 | raise util.Abort(_("repo commit failed")) | |
|
688 | try: | |
|
689 | self.full_series[insert:insert] = [patchfn] | |
|
690 | self.applied.append(statusentry(revlog.hex(n), patchfn)) | |
|
691 | self.parse_series() | |
|
692 | self.series_dirty = 1 | |
|
693 | self.applied_dirty = 1 | |
|
694 | if msg: | |
|
695 | msg = msg + "\n" | |
|
696 | p.write(msg) | |
|
697 | if commitfiles: | |
|
698 | diffopts = self.diffopts() | |
|
699 | if opts.get('git'): diffopts.git = True | |
|
700 | parent = self.qparents(repo, n) | |
|
701 | patch.diff(repo, node1=parent, node2=n, fp=p, | |
|
702 | match=match, opts=diffopts) | |
|
703 | p.close() | |
|
704 | wlock = None | |
|
705 | r = self.qrepo() | |
|
706 | if r: r.add([patchfn]) | |
|
707 | except: | |
|
708 | repo.rollback() | |
|
709 | raise | |
|
710 | except Exception, inst: | |
|
711 | patchpath = self.join(patchfn) | |
|
712 | try: | |
|
713 | os.unlink(patchpath) | |
|
714 | except: | |
|
715 | self.ui.warn(_('error unlinking %s\n') % patchpath) | |
|
716 | raise | |
|
701 | 717 | self.removeundo(repo) |
|
702 | 718 | finally: |
|
703 | 719 | del wlock |
General Comments 0
You need to be logged in to leave comments.
Login now