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-----
This commit is contained in:
mpm@selenic.com 2005-06-23 13:28:47 -08:00
parent 0ef8f163ee
commit 4b67f9b493

View File

@ -477,19 +477,24 @@ class localrepository:
raise inst raise inst
def rawcommit(self, files, text, user, date, p1=None, p2=None): def rawcommit(self, files, text, user, date, p1=None, p2=None):
p1 = p1 or self.dirstate.parents()[0] or nullid orig_parent = self.dirstate.parents()[0] or nullid
p2 = p2 or self.dirstate.parents()[1] or nullid p1 = (p1 and self.lookup(p1)) or self.dirstate.parents()[0] or nullid
p2 = (p2 and self.lookup(p2)) or self.dirstate.parents()[1] or nullid
c1 = self.changelog.read(p1) c1 = self.changelog.read(p1)
c2 = self.changelog.read(p2) c2 = self.changelog.read(p2)
m1 = self.manifest.read(c1[0]) m1 = self.manifest.read(c1[0])
mf1 = self.manifest.readflags(c1[0]) mf1 = self.manifest.readflags(c1[0])
m2 = self.manifest.read(c2[0]) m2 = self.manifest.read(c2[0])
if orig_parent == p1:
update_dirstate = 1
else:
update_dirstate = 0
tr = self.transaction() tr = self.transaction()
mm = m1.copy() mm = m1.copy()
mfm = mf1.copy() mfm = mf1.copy()
linkrev = self.changelog.count() linkrev = self.changelog.count()
self.dirstate.setparents(p1, p2)
for f in files: for f in files:
try: try:
t = self.wfile(f).read() t = self.wfile(f).read()
@ -498,11 +503,13 @@ class localrepository:
mfm[f] = tm mfm[f] = tm
mm[f] = r.add(t, {}, tr, linkrev, mm[f] = r.add(t, {}, tr, linkrev,
m1.get(f, nullid), m2.get(f, nullid)) m1.get(f, nullid), m2.get(f, nullid))
if update_dirstate:
self.dirstate.update([f], "n") self.dirstate.update([f], "n")
except IOError: except IOError:
try: try:
del mm[f] del mm[f]
del mfm[f] del mfm[f]
if update_dirstate:
self.dirstate.forget([f]) self.dirstate.forget([f])
except: except:
# deleted from p2? # deleted from p2?
@ -511,6 +518,8 @@ class localrepository:
mnode = self.manifest.add(mm, mfm, tr, linkrev, c1[0], c2[0]) mnode = self.manifest.add(mm, mfm, tr, linkrev, c1[0], c2[0])
n = self.changelog.add(mnode, files, text, tr, p1, p2, user, date) n = self.changelog.add(mnode, files, text, tr, p1, p2, user, date)
tr.close() tr.close()
if update_dirstate:
self.dirstate.setparents(n, nullid)
def commit(self, files = None, text = "", user = None, date = None): def commit(self, files = None, text = "", user = None, date = None):
commit = [] commit = []