comparison mercurial/localrepo.py @ 22909:4545c5b53013

commit: use separate variable for p1 manifest and new manifest In localrepo.commitctx(), p1's manifest is copied and used as the basis for the manifest that is about to be committed. The way the copy is updated makes it safe to use it where the original p1's manifest is wanted. For readability, though, a separate variable for each purpose would be clearer. Make it so.
author Martin von Zweigbergk <martinvonz@gmail.com>
date Mon, 13 Oct 2014 14:11:47 -0700
parents 71570f310417
children 4f2a5c7cdf78
comparison
equal deleted inserted replaced
22908:71570f310417 22909:4545c5b53013
1385 try: 1385 try:
1386 tr = self.transaction("commit") 1386 tr = self.transaction("commit")
1387 trp = weakref.proxy(tr) 1387 trp = weakref.proxy(tr)
1388 1388
1389 if ctx.files(): 1389 if ctx.files():
1390 m1 = p1.manifest().copy() 1390 m1 = p1.manifest()
1391 m2 = p2.manifest() 1391 m2 = p2.manifest()
1392 m = m1.copy()
1392 1393
1393 # check in files 1394 # check in files
1394 new = {} 1395 new = {}
1395 changed = [] 1396 changed = []
1396 removed = list(ctx.removed()) 1397 removed = list(ctx.removed())
1402 if fctx is None: 1403 if fctx is None:
1403 removed.append(f) 1404 removed.append(f)
1404 else: 1405 else:
1405 new[f] = self._filecommit(fctx, m1, m2, linkrev, 1406 new[f] = self._filecommit(fctx, m1, m2, linkrev,
1406 trp, changed) 1407 trp, changed)
1407 m1.set(f, fctx.flags()) 1408 m.set(f, fctx.flags())
1408 except OSError, inst: 1409 except OSError, inst:
1409 self.ui.warn(_("trouble committing %s!\n") % f) 1410 self.ui.warn(_("trouble committing %s!\n") % f)
1410 raise 1411 raise
1411 except IOError, inst: 1412 except IOError, inst:
1412 errcode = getattr(inst, 'errno', errno.ENOENT) 1413 errcode = getattr(inst, 'errno', errno.ENOENT)
1413 if error or errcode and errcode != errno.ENOENT: 1414 if error or errcode and errcode != errno.ENOENT:
1414 self.ui.warn(_("trouble committing %s!\n") % f) 1415 self.ui.warn(_("trouble committing %s!\n") % f)
1415 raise 1416 raise
1416 1417
1417 # update manifest 1418 # update manifest
1418 m1.update(new) 1419 m.update(new)
1419 removed = [f for f in sorted(removed) if f in m1 or f in m2] 1420 removed = [f for f in sorted(removed) if f in m1 or f in m2]
1420 drop = [f for f in removed if f in m1] 1421 drop = [f for f in removed if f in m]
1421 for f in drop: 1422 for f in drop:
1422 del m1[f] 1423 del m[f]
1423 mn = self.manifest.add(m1, trp, linkrev, p1.manifestnode(), 1424 mn = self.manifest.add(m, trp, linkrev,
1424 p2.manifestnode(), new, drop) 1425 p1.manifestnode(), p2.manifestnode(),
1426 new, drop)
1425 files = changed + removed 1427 files = changed + removed
1426 else: 1428 else:
1427 mn = p1.manifestnode() 1429 mn = p1.manifestnode()
1428 files = [] 1430 files = []
1429 1431