Mercurial > public > mercurial-scm > hg
diff 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 |
line wrap: on
line diff
--- a/mercurial/localrepo.py Thu Dec 16 07:45:22 2010 -0600 +++ b/mercurial/localrepo.py Mon Nov 29 09:37:23 2010 +0100 @@ -949,6 +949,7 @@ # commit subs if subs or removedsubs: + pstate = subrepo.substate(self['.']) state = wctx.substate.copy() for s in sorted(subs): sub = wctx.sub(s) @@ -956,7 +957,19 @@ subrepo.subrelpath(sub)) sr = sub.commit(cctx._text, user, date) state[s] = (state[s][0], sr) - subrepo.writestate(self, state) + + changed = False + if len(pstate) != len(state): + changed = True + if not changed: + for newstate in state: + if state[newstate][1] != pstate[newstate]: + changed = True + if changed: + subrepo.writestate(self, state) + elif (changes[0] == ['.hgsubstate'] and changes[1] == [] and + changes[2] == []): + return None # Save commit message in case this transaction gets rolled back # (e.g. by a pretxncommit hook). Leave the content alone on