comparison hgext/evolve.py @ 1505:53a6dbc33e36

evolve: indentation change for making next patch more legible In the next patch: "evolve: use repo._bookmarks.recordchange instead of repo._bookmarks.write" we need to add a transaction in the rewrite function. To do so adds an indentation level and makes the patch harder to review. This patch makes the indentation change so that the next patch is easier to review.
author Laurent Charignon <lcharignon@fb.com>
date Wed, 16 Sep 2015 17:12:38 -0700
parents 415a51ac07a7
children a55c691f4cc0
comparison
equal deleted inserted replaced
1504:415a51ac07a7 1505:53a6dbc33e36
803 """Return (nodeid, created) where nodeid is the identifier of the 803 """Return (nodeid, created) where nodeid is the identifier of the
804 changeset generated by the rewrite process, and created is True if 804 changeset generated by the rewrite process, and created is True if
805 nodeid was actually created. If created is False, nodeid 805 nodeid was actually created. If created is False, nodeid
806 references a changeset existing before the rewrite call. 806 references a changeset existing before the rewrite call.
807 """ 807 """
808 if len(old.parents()) > 1: #XXX remove this unecessary limitation. 808 if True:
809 raise error.Abort(_('cannot amend merge changesets')) 809 if len(old.parents()) > 1: #XXX remove this unecessary limitation.
810 base = old.p1() 810 raise error.Abort(_('cannot amend merge changesets'))
811 updatebookmarks = _bookmarksupdater(repo, old.node()) 811 base = old.p1()
812 812 updatebookmarks = _bookmarksupdater(repo, old.node())
813 # commit a new version of the old changeset, including the update 813
814 # collect all files which might be affected 814 # commit a new version of the old changeset, including the update
815 files = set(old.files()) 815 # collect all files which might be affected
816 for u in updates: 816 files = set(old.files())
817 files.update(u.files()) 817 for u in updates:
818 818 files.update(u.files())
819 # Recompute copies (avoid recording a -> b -> a) 819
820 copied = copies.pathcopies(base, head) 820 # Recompute copies (avoid recording a -> b -> a)
821 821 copied = copies.pathcopies(base, head)
822 822
823 # prune files which were reverted by the updates 823
824 def samefile(f): 824 # prune files which were reverted by the updates
825 if f in head.manifest(): 825 def samefile(f):
826 a = head.filectx(f) 826 if f in head.manifest():
827 if f in base.manifest(): 827 a = head.filectx(f)
828 b = base.filectx(f) 828 if f in base.manifest():
829 return (a.data() == b.data() 829 b = base.filectx(f)
830 and a.flags() == b.flags()) 830 return (a.data() == b.data()
831 and a.flags() == b.flags())
832 else:
833 return False
831 else: 834 else:
832 return False 835 return f not in base.manifest()
833 else: 836 files = [f for f in files if not samefile(f)]
834 return f not in base.manifest() 837 # commit version of these files as defined by head
835 files = [f for f in files if not samefile(f)] 838 headmf = head.manifest()
836 # commit version of these files as defined by head 839 def filectxfn(repo, ctx, path):
837 headmf = head.manifest() 840 if path in headmf:
838 def filectxfn(repo, ctx, path): 841 fctx = head[path]
839 if path in headmf: 842 flags = fctx.flags()
840 fctx = head[path] 843 mctx = memfilectx(repo, fctx.path(), fctx.data(),
841 flags = fctx.flags() 844 islink='l' in flags,
842 mctx = memfilectx(repo, fctx.path(), fctx.data(), 845 isexec='x' in flags,
843 islink='l' in flags, 846 copied=copied.get(path))
844 isexec='x' in flags, 847 return mctx
845 copied=copied.get(path)) 848 return None
846 return mctx 849
847 return None 850 message = cmdutil.logmessage(repo.ui, commitopts)
848 851 if not message:
849 message = cmdutil.logmessage(repo.ui, commitopts) 852 message = old.description()
850 if not message: 853
851 message = old.description() 854 user = commitopts.get('user') or old.user()
852 855 date = commitopts.get('date') or None # old.date()
853 user = commitopts.get('user') or old.user() 856 extra = dict(commitopts.get('extra', {}))
854 date = commitopts.get('date') or None # old.date() 857 extra['branch'] = head.branch()
855 extra = dict(commitopts.get('extra', {})) 858
856 extra['branch'] = head.branch() 859 new = context.memctx(repo,
857 860 parents=newbases,
858 new = context.memctx(repo, 861 text=message,
859 parents=newbases, 862 files=files,
860 text=message, 863 filectxfn=filectxfn,
861 files=files, 864 user=user,
862 filectxfn=filectxfn, 865 date=date,
863 user=user, 866 extra=extra)
864 date=date, 867
865 extra=extra) 868 if commitopts.get('edit'):
866 869 new._text = cmdutil.commitforceeditor(repo, new, [])
867 if commitopts.get('edit'): 870 revcount = len(repo)
868 new._text = cmdutil.commitforceeditor(repo, new, []) 871 newid = repo.commitctx(new)
869 revcount = len(repo) 872 new = repo[newid]
870 newid = repo.commitctx(new) 873 created = len(repo) != revcount
871 new = repo[newid] 874 updatebookmarks(newid)
872 created = len(repo) != revcount 875
873 updatebookmarks(newid) 876 return newid, created
874
875 return newid, created
876 877
877 class MergeFailure(util.Abort): 878 class MergeFailure(util.Abort):
878 pass 879 pass
879 880
880 def relocate(repo, orig, dest, keepbranch=False): 881 def relocate(repo, orig, dest, keepbranch=False):