comparison mercurial/localrepo.py @ 13155:f02d7a562a21

subrepo: avoids empty commit when .hgsubstate is dirty (issue2403) This patch avoids empty commit when .hgsubstate is dirty. Empty commit was caused by .hgsubstate being updated back to the state of the working copy parent when committing, if a user had changed it manually and not made any changes in subrepositories. The subrepository state from the working copies parent is compared with the state calculated as a result of trying to commit the subrepositories. If the two states are the same, then return None otherwise the commit is just done. The line: "committing subrepository x" will be written if there is nothing committed, but .hgsubstate is dirty for x subrepository.
author Erik Zielke <ez@aragost.com>
date Mon, 29 Nov 2010 09:37:23 +0100
parents 6320101a638c
children 84cec5895d01
comparison
equal deleted inserted replaced
13154:e11c14f14491 13155:f02d7a562a21
947 cctx._text = editor(self, cctx, subs) 947 cctx._text = editor(self, cctx, subs)
948 edited = (text != cctx._text) 948 edited = (text != cctx._text)
949 949
950 # commit subs 950 # commit subs
951 if subs or removedsubs: 951 if subs or removedsubs:
952 pstate = subrepo.substate(self['.'])
952 state = wctx.substate.copy() 953 state = wctx.substate.copy()
953 for s in sorted(subs): 954 for s in sorted(subs):
954 sub = wctx.sub(s) 955 sub = wctx.sub(s)
955 self.ui.status(_('committing subrepository %s\n') % 956 self.ui.status(_('committing subrepository %s\n') %
956 subrepo.subrelpath(sub)) 957 subrepo.subrelpath(sub))
957 sr = sub.commit(cctx._text, user, date) 958 sr = sub.commit(cctx._text, user, date)
958 state[s] = (state[s][0], sr) 959 state[s] = (state[s][0], sr)
959 subrepo.writestate(self, state) 960
961 changed = False
962 if len(pstate) != len(state):
963 changed = True
964 if not changed:
965 for newstate in state:
966 if state[newstate][1] != pstate[newstate]:
967 changed = True
968 if changed:
969 subrepo.writestate(self, state)
970 elif (changes[0] == ['.hgsubstate'] and changes[1] == [] and
971 changes[2] == []):
972 return None
960 973
961 # Save commit message in case this transaction gets rolled back 974 # Save commit message in case this transaction gets rolled back
962 # (e.g. by a pretxncommit hook). Leave the content alone on 975 # (e.g. by a pretxncommit hook). Leave the content alone on
963 # the assumption that the user will use the same editor again. 976 # the assumption that the user will use the same editor again.
964 msgfile = self.opener('last-message.txt', 'wb') 977 msgfile = self.opener('last-message.txt', 'wb')