comparison 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
comparison
equal deleted inserted replaced
13285:2ef915184ff2 13287:d0e0d3d43e14
497 stderr = stderr.strip() 497 stderr = stderr.strip()
498 if stderr: 498 if stderr:
499 raise util.Abort(stderr) 499 raise util.Abort(stderr)
500 return stdout 500 return stdout
501 501
502 def _wcrev(self): 502 def _wcrevs(self):
503 # Get the working directory revision as well as the last
504 # commit revision so we can compare the subrepo state with
505 # both. We used to store the working directory one.
503 output = self._svncommand(['info', '--xml']) 506 output = self._svncommand(['info', '--xml'])
504 doc = xml.dom.minidom.parseString(output) 507 doc = xml.dom.minidom.parseString(output)
505 entries = doc.getElementsByTagName('entry') 508 entries = doc.getElementsByTagName('entry')
506 if not entries: 509 lastrev, rev = '0', '0'
507 return '0' 510 if entries:
508 return str(entries[0].getAttribute('revision')) or '0' 511 rev = str(entries[0].getAttribute('revision')) or '0'
512 commits = entries[0].getElementsByTagName('commit')
513 if commits:
514 lastrev = str(commits[0].getAttribute('revision')) or '0'
515 return (lastrev, rev)
516
517 def _wcrev(self):
518 return self._wcrevs()[0]
509 519
510 def _wcchanged(self): 520 def _wcchanged(self):
511 """Return (changes, extchanges) where changes is True 521 """Return (changes, extchanges) where changes is True
512 if the working directory was changed, and extchanges is 522 if the working directory was changed, and extchanges is
513 True if any of these changes concern an external entry. 523 True if any of these changes concern an external entry.
532 if path == ext or path.startswith(ext + os.sep): 542 if path == ext or path.startswith(ext + os.sep):
533 return True, True 543 return True, True
534 return bool(changes), False 544 return bool(changes), False
535 545
536 def dirty(self): 546 def dirty(self):
537 if self._wcrev() == self._state[1] and not self._wcchanged()[0]: 547 if self._state[1] in self._wcrevs() and not self._wcchanged()[0]:
538 return False 548 return False
539 return True 549 return True
540 550
541 def commit(self, text, user, date): 551 def commit(self, text, user, date):
542 # user and date are out of our hands since svn is centralized 552 # user and date are out of our hands since svn is centralized