Mercurial > public > mercurial-scm > hg
comparison mercurial/subrepo.py @ 10273:e898bc7810ad
subrepo: handle svn externals and meta changes (issue1982)
- Detect changes to meta on regular and external entries
- Do not try to commit external entries
author | Patrick Mezard <pmezard@gmail.com> |
---|---|
date | Thu, 21 Jan 2010 13:26:26 +0100 |
parents | 886858b834da |
children | e768941f14c1 |
comparison
equal
deleted
inserted
replaced
10272:886858b834da | 10273:e898bc7810ad |
---|---|
280 entries = doc.getElementsByTagName('entry') | 280 entries = doc.getElementsByTagName('entry') |
281 if not entries: | 281 if not entries: |
282 return 0 | 282 return 0 |
283 return int(entries[0].getAttribute('revision') or 0) | 283 return int(entries[0].getAttribute('revision') or 0) |
284 | 284 |
285 def _wcclean(self): | 285 def _wcchanged(self): |
286 """Return (changes, extchanges) where changes is True | |
287 if the working directory was changed, and extchanges is | |
288 True if any of these changes concern an external entry. | |
289 """ | |
286 output = self._svncommand(['status', '--xml']) | 290 output = self._svncommand(['status', '--xml']) |
291 externals, changes = [], [] | |
287 doc = xml.dom.minidom.parseString(output) | 292 doc = xml.dom.minidom.parseString(output) |
288 for s in doc.getElementsByTagName('wc-status'): | 293 for e in doc.getElementsByTagName('entry'): |
289 st = s.getAttribute('item') | 294 s = e.getElementsByTagName('wc-status') |
290 if st and st != 'unversioned': | 295 if not s: |
291 return False | 296 continue |
292 props = s.getAttribute('props') | 297 item = s[0].getAttribute('item') |
293 if props and props != 'none': | 298 props = s[0].getAttribute('props') |
294 return False | 299 path = e.getAttribute('path') |
295 return True | 300 if item == 'external': |
301 externals.append(path) | |
302 if (item not in ('', 'normal', 'unversioned', 'external') | |
303 or props not in ('', 'none')): | |
304 changes.append(path) | |
305 for path in changes: | |
306 for ext in externals: | |
307 if path == ext or path.startswith(ext + os.sep): | |
308 return True, True | |
309 return bool(changes), False | |
296 | 310 |
297 def dirty(self): | 311 def dirty(self): |
298 if self._wcrev() == self._state[1] and self._wcclean(): | 312 if self._wcrev() == self._state[1] and not self._wcchanged()[0]: |
299 return False | 313 return False |
300 return True | 314 return True |
301 | 315 |
302 def commit(self, text, user, date): | 316 def commit(self, text, user, date): |
303 # user and date are out of our hands since svn is centralized | 317 # user and date are out of our hands since svn is centralized |
304 if self._wcclean(): | 318 changed, extchanged = self._wcchanged() |
319 if not changed: | |
305 return self._wcrev() | 320 return self._wcrev() |
321 if extchanged: | |
322 # Do not try to commit externals | |
323 raise util.Abort(_('cannot commit svn externals')) | |
306 commitinfo = self._svncommand(['commit', '-m', text]) | 324 commitinfo = self._svncommand(['commit', '-m', text]) |
307 self._ui.status(commitinfo) | 325 self._ui.status(commitinfo) |
308 newrev = re.search('Committed revision ([\d]+).', commitinfo) | 326 newrev = re.search('Committed revision ([\d]+).', commitinfo) |
309 if not newrev: | 327 if not newrev: |
310 raise util.Abort(commitinfo.splitlines()[-1]) | 328 raise util.Abort(commitinfo.splitlines()[-1]) |