Mercurial > public > mercurial-scm > hg-stable
diff mercurial/subrepo.py @ 13287:d0e0d3d43e14 stable
subrepo: compare svn subrepo state to last committed revision
A subversion project revisions are a subset of the repository revisions, you
can ask subversion to update a working directory from one revision to another
without changing anything. Unfortunately, Mercurial will think the
subrepository has changed and will commit it again. To avoid useless commits,
we compare the subrepository state to its actual "parent" revision. To ensure
ascending compatibility with existing subrepositories which might reference
fake revisions, we also keep comparing with the subrepo working directory
revision.
NOTE: not sure if this should go in stable or not.
author | Patrick Mezard <pmezard@gmail.com> |
---|---|
date | Sat, 22 Jan 2011 16:15:40 +0100 |
parents | 594ed85b6a3f |
children | 9c3bfba3f48d c19b9282d3a7 |
line wrap: on
line diff
--- a/mercurial/subrepo.py Fri Jan 21 14:42:15 2011 -0600 +++ b/mercurial/subrepo.py Sat Jan 22 16:15:40 2011 +0100 @@ -499,13 +499,23 @@ raise util.Abort(stderr) return stdout - def _wcrev(self): + def _wcrevs(self): + # Get the working directory revision as well as the last + # commit revision so we can compare the subrepo state with + # both. We used to store the working directory one. output = self._svncommand(['info', '--xml']) doc = xml.dom.minidom.parseString(output) entries = doc.getElementsByTagName('entry') - if not entries: - return '0' - return str(entries[0].getAttribute('revision')) or '0' + lastrev, rev = '0', '0' + if entries: + rev = str(entries[0].getAttribute('revision')) or '0' + commits = entries[0].getElementsByTagName('commit') + if commits: + lastrev = str(commits[0].getAttribute('revision')) or '0' + return (lastrev, rev) + + def _wcrev(self): + return self._wcrevs()[0] def _wcchanged(self): """Return (changes, extchanges) where changes is True @@ -534,7 +544,7 @@ return bool(changes), False def dirty(self): - if self._wcrev() == self._state[1] and not self._wcchanged()[0]: + if self._state[1] in self._wcrevs() and not self._wcchanged()[0]: return False return True