comparison mercurial/hg.py @ 442:3e2aee6c5500

rawcommit dirstate tweak -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 rawcommit dirstate tweak Before this patch, rawcommit can mess up the dirstate unless it is committing against the current parent. This patch changes rawcommit, such that when adding a child to some node other than the current parent, rawcommit does not attempt update the current dirstate. This seems easily debatable; it creates an asymmetric behavior for rawcommit. It means that when doing a rawcommit against the current parent, there's effectively an implied "hg update" to the newly created node. When doing a rawcommit against any other node, no such "hg update" occurs. The other obvious alternates would be: 1) rawcommit never update the dirstate 2) rawcommit always does an "hg update"... This patch also includes a test for various uses of rawcommit... Michael Fetterman manifest hash: 428517d82a02501f14b0d8fac064411980780e91 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.0 (GNU/Linux) iD8DBQFCuymPywK+sNU5EO8RAvdvAKCxW1QZtyOviNfuwO592IaKApwvEACfdrYD 83m/o8oJvRKu3yGvNGHtwfk= =KbmU -----END PGP SIGNATURE-----
author mpm@selenic.com
date Thu, 23 Jun 2005 13:28:47 -0800
parents e8af362cfb01
children a1e91c24dab5
comparison
equal deleted inserted replaced
441:e8af362cfb01 442:3e2aee6c5500
475 self.ui.warn("waiting for lock held by %s\n" % inst.args[0]) 475 self.ui.warn("waiting for lock held by %s\n" % inst.args[0])
476 return lock.lock(self.join("lock"), wait) 476 return lock.lock(self.join("lock"), wait)
477 raise inst 477 raise inst
478 478
479 def rawcommit(self, files, text, user, date, p1=None, p2=None): 479 def rawcommit(self, files, text, user, date, p1=None, p2=None):
480 p1 = p1 or self.dirstate.parents()[0] or nullid 480 orig_parent = self.dirstate.parents()[0] or nullid
481 p2 = p2 or self.dirstate.parents()[1] or nullid 481 p1 = (p1 and self.lookup(p1)) or self.dirstate.parents()[0] or nullid
482 p2 = (p2 and self.lookup(p2)) or self.dirstate.parents()[1] or nullid
482 c1 = self.changelog.read(p1) 483 c1 = self.changelog.read(p1)
483 c2 = self.changelog.read(p2) 484 c2 = self.changelog.read(p2)
484 m1 = self.manifest.read(c1[0]) 485 m1 = self.manifest.read(c1[0])
485 mf1 = self.manifest.readflags(c1[0]) 486 mf1 = self.manifest.readflags(c1[0])
486 m2 = self.manifest.read(c2[0]) 487 m2 = self.manifest.read(c2[0])
487 488
489 if orig_parent == p1:
490 update_dirstate = 1
491 else:
492 update_dirstate = 0
493
488 tr = self.transaction() 494 tr = self.transaction()
489 mm = m1.copy() 495 mm = m1.copy()
490 mfm = mf1.copy() 496 mfm = mf1.copy()
491 linkrev = self.changelog.count() 497 linkrev = self.changelog.count()
492 self.dirstate.setparents(p1, p2)
493 for f in files: 498 for f in files:
494 try: 499 try:
495 t = self.wfile(f).read() 500 t = self.wfile(f).read()
496 tm = util.is_exec(self.wjoin(f), mfm.get(f, False)) 501 tm = util.is_exec(self.wjoin(f), mfm.get(f, False))
497 r = self.file(f) 502 r = self.file(f)
498 mfm[f] = tm 503 mfm[f] = tm
499 mm[f] = r.add(t, {}, tr, linkrev, 504 mm[f] = r.add(t, {}, tr, linkrev,
500 m1.get(f, nullid), m2.get(f, nullid)) 505 m1.get(f, nullid), m2.get(f, nullid))
501 self.dirstate.update([f], "n") 506 if update_dirstate:
507 self.dirstate.update([f], "n")
502 except IOError: 508 except IOError:
503 try: 509 try:
504 del mm[f] 510 del mm[f]
505 del mfm[f] 511 del mfm[f]
506 self.dirstate.forget([f]) 512 if update_dirstate:
513 self.dirstate.forget([f])
507 except: 514 except:
508 # deleted from p2? 515 # deleted from p2?
509 pass 516 pass
510 517
511 mnode = self.manifest.add(mm, mfm, tr, linkrev, c1[0], c2[0]) 518 mnode = self.manifest.add(mm, mfm, tr, linkrev, c1[0], c2[0])
512 n = self.changelog.add(mnode, files, text, tr, p1, p2, user, date) 519 n = self.changelog.add(mnode, files, text, tr, p1, p2, user, date)
513 tr.close() 520 tr.close()
521 if update_dirstate:
522 self.dirstate.setparents(n, nullid)
514 523
515 def commit(self, files = None, text = "", user = None, date = None): 524 def commit(self, files = None, text = "", user = None, date = None):
516 commit = [] 525 commit = []
517 remove = [] 526 remove = []
518 if files: 527 if files: