comparison hgext3rd/evolve/__init__.py @ 2758:684feae20be5

rewriteutil: move 'foldcheck' to the new module
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Sun, 23 Jul 2017 04:54:42 +0200
parents 2878c8a686ab
children 3137185b1bfe
comparison
equal deleted inserted replaced
2757:2878c8a686ab 2758:684feae20be5
2749 wlock = lock = None 2749 wlock = lock = None
2750 try: 2750 try:
2751 wlock = repo.wlock() 2751 wlock = repo.wlock()
2752 lock = repo.lock() 2752 lock = repo.lock()
2753 2753
2754 root, head = _foldcheck(repo, revs) 2754 root, head = rewriteutil.foldcheck(repo, revs)
2755 2755
2756 tr = repo.transaction('fold') 2756 tr = repo.transaction('fold')
2757 try: 2757 try:
2758 commitopts = opts.copy() 2758 commitopts = opts.copy()
2759 allctx = [repo[r] for r in revs] 2759 allctx = [repo[r] for r in revs]
2843 # revisions in topological order. 2843 # revisions in topological order.
2844 raise error.Abort(_('editing multiple revisions without --fold is ' 2844 raise error.Abort(_('editing multiple revisions without --fold is '
2845 'not currently supported')) 2845 'not currently supported'))
2846 2846
2847 if opts['fold']: 2847 if opts['fold']:
2848 root, head = _foldcheck(repo, revs) 2848 root, head = rewriteutil.foldcheck(repo, revs)
2849 else: 2849 else:
2850 if repo.revs("%ld and public()", revs): 2850 if repo.revs("%ld and public()", revs):
2851 raise error.Abort(_('cannot edit commit information for public ' 2851 raise error.Abort(_('cannot edit commit information for public '
2852 'revisions')) 2852 'revisions'))
2853 newunstable = rewriteutil.disallowednewunstable(repo, revs) 2853 newunstable = rewriteutil.disallowednewunstable(repo, revs)
2903 ui.status('%i changesets folded\n' % len(revs)) 2903 ui.status('%i changesets folded\n' % len(revs))
2904 if newp1 is not None: 2904 if newp1 is not None:
2905 hg.update(repo, newp1) 2905 hg.update(repo, newp1)
2906 finally: 2906 finally:
2907 lockmod.release(lock, wlock) 2907 lockmod.release(lock, wlock)
2908
2909 def _foldcheck(repo, revs):
2910 roots = repo.revs('roots(%ld)', revs)
2911 if len(roots) > 1:
2912 raise error.Abort(_("cannot fold non-linear revisions "
2913 "(multiple roots given)"))
2914 root = repo[roots.first()]
2915 if root.phase() <= phases.public:
2916 raise error.Abort(_("cannot fold public revisions"))
2917 heads = repo.revs('heads(%ld)', revs)
2918 if len(heads) > 1:
2919 raise error.Abort(_("cannot fold non-linear revisions "
2920 "(multiple heads given)"))
2921 head = repo[heads.first()]
2922 if rewriteutil.disallowednewunstable(repo, revs):
2923 msg = _("cannot fold chain not ending with a head or with branching")
2924 hint = _("new unstable changesets are not allowed")
2925 raise error.Abort(msg, hint=hint)
2926 return root, head
2927 2908
2928 @eh.wrapcommand('graft') 2909 @eh.wrapcommand('graft')
2929 def graftwrapper(orig, ui, repo, *revs, **kwargs): 2910 def graftwrapper(orig, ui, repo, *revs, **kwargs):
2930 kwargs = dict(kwargs) 2911 kwargs = dict(kwargs)
2931 revs = list(revs) + kwargs.get('rev', []) 2912 revs = list(revs) + kwargs.get('rev', [])