comparison mercurial/localrepo.py @ 14162:301725c3df9a

localrepo: reuse parent manifest in commitctx if no files have changed This speeds up the in-memory version of debugbuilddag that I'm working on considerably for the case where we want to build just a 00changelog.i (for discovery tests, for instance). There are a couple of test changes because node ids in tests have changed. The changes to the patch names in test-mq-qdelete.t were required because they could collide with nodeid abbreviations and newly actually do (patch "c" collides with id "cafe..." for patch "b").
author Peter Arrenbrecht <peter.arrenbrecht@gmail.com>
date Mon, 02 May 2011 19:20:29 +0200
parents 921683f14ad7
children 135e244776f0
comparison
equal deleted inserted replaced
14161:8a0fca925992 14162:301725c3df9a
1041 """ 1041 """
1042 1042
1043 tr = lock = None 1043 tr = lock = None
1044 removed = list(ctx.removed()) 1044 removed = list(ctx.removed())
1045 p1, p2 = ctx.p1(), ctx.p2() 1045 p1, p2 = ctx.p1(), ctx.p2()
1046 m1 = p1.manifest().copy()
1047 m2 = p2.manifest()
1048 user = ctx.user() 1046 user = ctx.user()
1049 1047
1050 lock = self.lock() 1048 lock = self.lock()
1051 try: 1049 try:
1052 tr = self.transaction("commit") 1050 tr = self.transaction("commit")
1053 trp = weakref.proxy(tr) 1051 trp = weakref.proxy(tr)
1054 1052
1055 # check in files 1053 if ctx.files():
1056 new = {} 1054 m1 = p1.manifest().copy()
1057 changed = [] 1055 m2 = p2.manifest()
1058 linkrev = len(self) 1056
1059 for f in sorted(ctx.modified() + ctx.added()): 1057 # check in files
1060 self.ui.note(f + "\n") 1058 new = {}
1061 try: 1059 changed = []
1062 fctx = ctx[f] 1060 linkrev = len(self)
1063 new[f] = self._filecommit(fctx, m1, m2, linkrev, trp, 1061 for f in sorted(ctx.modified() + ctx.added()):
1064 changed) 1062 self.ui.note(f + "\n")
1065 m1.set(f, fctx.flags()) 1063 try:
1066 except OSError, inst: 1064 fctx = ctx[f]
1067 self.ui.warn(_("trouble committing %s!\n") % f) 1065 new[f] = self._filecommit(fctx, m1, m2, linkrev, trp,
1068 raise 1066 changed)
1069 except IOError, inst: 1067 m1.set(f, fctx.flags())
1070 errcode = getattr(inst, 'errno', errno.ENOENT) 1068 except OSError, inst:
1071 if error or errcode and errcode != errno.ENOENT:
1072 self.ui.warn(_("trouble committing %s!\n") % f) 1069 self.ui.warn(_("trouble committing %s!\n") % f)
1073 raise 1070 raise
1074 else: 1071 except IOError, inst:
1075 removed.append(f) 1072 errcode = getattr(inst, 'errno', errno.ENOENT)
1076 1073 if error or errcode and errcode != errno.ENOENT:
1077 # update manifest 1074 self.ui.warn(_("trouble committing %s!\n") % f)
1078 m1.update(new) 1075 raise
1079 removed = [f for f in sorted(removed) if f in m1 or f in m2] 1076 else:
1080 drop = [f for f in removed if f in m1] 1077 removed.append(f)
1081 for f in drop: 1078
1082 del m1[f] 1079 # update manifest
1083 mn = self.manifest.add(m1, trp, linkrev, p1.manifestnode(), 1080 m1.update(new)
1084 p2.manifestnode(), (new, drop)) 1081 removed = [f for f in sorted(removed) if f in m1 or f in m2]
1082 drop = [f for f in removed if f in m1]
1083 for f in drop:
1084 del m1[f]
1085 mn = self.manifest.add(m1, trp, linkrev, p1.manifestnode(),
1086 p2.manifestnode(), (new, drop))
1087 files = changed + removed
1088 else:
1089 mn = p1.manifestnode()
1090 files = []
1085 1091
1086 # update changelog 1092 # update changelog
1087 self.changelog.delayupdate() 1093 self.changelog.delayupdate()
1088 n = self.changelog.add(mn, changed + removed, ctx.description(), 1094 n = self.changelog.add(mn, files, ctx.description(),
1089 trp, p1.node(), p2.node(), 1095 trp, p1.node(), p2.node(),
1090 user, ctx.date(), ctx.extra().copy()) 1096 user, ctx.date(), ctx.extra().copy())
1091 p = lambda: self.changelog.writepending() and self.root or "" 1097 p = lambda: self.changelog.writepending() and self.root or ""
1092 xp1, xp2 = p1.hex(), p2 and p2.hex() or '' 1098 xp1, xp2 = p1.hex(), p2 and p2.hex() or ''
1093 self.hook('pretxncommit', throw=True, node=hex(n), parent1=xp1, 1099 self.hook('pretxncommit', throw=True, node=hex(n), parent1=xp1,