comparison hgext/evolve.py @ 1017:186b72e41294

evolve: drop useless wlock in rewrite
author Pierre-Yves David <pierre-yves.david@fb.com>
date Wed, 06 Aug 2014 17:37:28 -0700
parents facb5efa8ea4
children 30262465b932
comparison
equal deleted inserted replaced
1016:facb5efa8ea4 1017:186b72e41294
765 if len(old.parents()) > 1: #XXX remove this unecessary limitation. 765 if len(old.parents()) > 1: #XXX remove this unecessary limitation.
766 raise error.Abort(_('cannot amend merge changesets')) 766 raise error.Abort(_('cannot amend merge changesets'))
767 base = old.p1() 767 base = old.p1()
768 updatebookmarks = _bookmarksupdater(repo, old.node()) 768 updatebookmarks = _bookmarksupdater(repo, old.node())
769 769
770 wlock = repo.wlock() 770 # commit a new version of the old changeset, including the update
771 try: 771 # collect all files which might be affected
772 772 files = set(old.files())
773 # commit a new version of the old changeset, including the update 773 for u in updates:
774 # collect all files which might be affected 774 files.update(u.files())
775 files = set(old.files()) 775
776 for u in updates: 776 # Recompute copies (avoid recording a -> b -> a)
777 files.update(u.files()) 777 copied = copies.pathcopies(base, head)
778 778
779 # Recompute copies (avoid recording a -> b -> a) 779
780 copied = copies.pathcopies(base, head) 780 # prune files which were reverted by the updates
781 781 def samefile(f):
782 782 if f in head.manifest():
783 # prune files which were reverted by the updates 783 a = head.filectx(f)
784 def samefile(f): 784 if f in base.manifest():
785 if f in head.manifest(): 785 b = base.filectx(f)
786 a = head.filectx(f) 786 return (a.data() == b.data()
787 if f in base.manifest(): 787 and a.flags() == b.flags())
788 b = base.filectx(f)
789 return (a.data() == b.data()
790 and a.flags() == b.flags())
791 else:
792 return False
793 else: 788 else:
794 return f not in base.manifest() 789 return False
795 files = [f for f in files if not samefile(f)] 790 else:
796 # commit version of these files as defined by head 791 return f not in base.manifest()
797 headmf = head.manifest() 792 files = [f for f in files if not samefile(f)]
798 def filectxfn(repo, ctx, path): 793 # commit version of these files as defined by head
799 if path in headmf: 794 headmf = head.manifest()
800 fctx = head[path] 795 def filectxfn(repo, ctx, path):
801 flags = fctx.flags() 796 if path in headmf:
802 mctx = memfilectx(repo, fctx.path(), fctx.data(), 797 fctx = head[path]
803 islink='l' in flags, 798 flags = fctx.flags()
804 isexec='x' in flags, 799 mctx = memfilectx(repo, fctx.path(), fctx.data(),
805 copied=copied.get(path)) 800 islink='l' in flags,
806 return mctx 801 isexec='x' in flags,
807 raise IOError() 802 copied=copied.get(path))
808 803 return mctx
809 message = cmdutil.logmessage(repo.ui, commitopts) 804 raise IOError()
810 if not message: 805
811 message = old.description() 806 message = cmdutil.logmessage(repo.ui, commitopts)
812 807 if not message:
813 user = commitopts.get('user') or old.user() 808 message = old.description()
814 date = commitopts.get('date') or None # old.date() 809
815 extra = dict(commitopts.get('extra', {})) 810 user = commitopts.get('user') or old.user()
816 extra['branch'] = head.branch() 811 date = commitopts.get('date') or None # old.date()
817 812 extra = dict(commitopts.get('extra', {}))
818 new = context.memctx(repo, 813 extra['branch'] = head.branch()
819 parents=newbases, 814
820 text=message, 815 new = context.memctx(repo,
821 files=files, 816 parents=newbases,
822 filectxfn=filectxfn, 817 text=message,
823 user=user, 818 files=files,
824 date=date, 819 filectxfn=filectxfn,
825 extra=extra) 820 user=user,
826 821 date=date,
827 if commitopts.get('edit'): 822 extra=extra)
828 new._text = cmdutil.commitforceeditor(repo, new, []) 823
829 revcount = len(repo) 824 if commitopts.get('edit'):
830 newid = repo.commitctx(new) 825 new._text = cmdutil.commitforceeditor(repo, new, [])
831 new = repo[newid] 826 revcount = len(repo)
832 created = len(repo) != revcount 827 newid = repo.commitctx(new)
833 updatebookmarks(newid) 828 new = repo[newid]
834 finally: 829 created = len(repo) != revcount
835 wlock.release() 830 updatebookmarks(newid)
836 831
837 return newid, created 832 return newid, created
838 833
839 class MergeFailure(util.Abort): 834 class MergeFailure(util.Abort):
840 pass 835 pass