Mercurial > hg
comparison mercurial/subrepo.py @ 13174:be7e8e9bc5e5
mq: update .hgsubstate if subrepos are clean (issue2499)
This patch prevents MQ from creating an inconsistent subrepo state. If
the .hgsub file has been changed, and none of the subrepos have
uncommitted changes, creating or updating a patch (using qnew, qrefresh,
or qrecord) will update .hgsubstate accordingly.
If any subrepos _do_ have uncommitted changes, qnew/qrefresh/qrecord
will abort.
Thanks to pmezard for proposing this solution.
author | Kevin Bullock <kbullock@ringworld.org> |
---|---|
date | Tue, 07 Dec 2010 22:14:43 -0600 |
parents | 84cec5895d01 |
children | c4d857f5405d |
comparison
equal
deleted
inserted
replaced
13173:9b46dd253052 | 13174:be7e8e9bc5e5 |
---|---|
234 | 234 |
235 # subrepo classes need to implement the following abstract class: | 235 # subrepo classes need to implement the following abstract class: |
236 | 236 |
237 class abstractsubrepo(object): | 237 class abstractsubrepo(object): |
238 | 238 |
239 def dirty(self): | 239 def dirty(self, ignoreupdate=False): |
240 """returns true if the dirstate of the subrepo does not match | 240 """returns true if the dirstate of the subrepo is dirty or does not |
241 current stored state | 241 match current stored state. If ignoreupdate is true, only check |
242 whether the subrepo has uncommitted changes in its dirstate. | |
242 """ | 243 """ |
243 raise NotImplementedError | 244 raise NotImplementedError |
244 | 245 |
245 def checknested(self, path): | 246 def checknested(self, path): |
246 """check if path is a subrepository within this repository""" | 247 """check if path is a subrepository within this repository""" |
388 ctx = self._repo[rev] | 389 ctx = self._repo[rev] |
389 for subpath in ctx.substate: | 390 for subpath in ctx.substate: |
390 s = subrepo(ctx, subpath) | 391 s = subrepo(ctx, subpath) |
391 s.archive(ui, archiver, os.path.join(prefix, self._path)) | 392 s.archive(ui, archiver, os.path.join(prefix, self._path)) |
392 | 393 |
393 def dirty(self): | 394 def dirty(self, ignoreupdate=False): |
394 r = self._state[1] | 395 r = self._state[1] |
395 if r == '': | 396 if r == '' and not ignoreupdate: # no state recorded |
396 return True | 397 return True |
397 w = self._repo[None] | 398 w = self._repo[None] |
398 if w.p1() != self._repo[r]: # version checked out change | 399 # version checked out changed? |
400 if w.p1() != self._repo[r] and not ignoreupdate: | |
399 return True | 401 return True |
400 return w.dirty() # working directory changed | 402 return w.dirty() # working directory changed |
401 | 403 |
402 def checknested(self, path): | 404 def checknested(self, path): |
403 return self._repo._checknested(self._repo.wjoin(path)) | 405 return self._repo._checknested(self._repo.wjoin(path)) |
536 for ext in externals: | 538 for ext in externals: |
537 if path == ext or path.startswith(ext + os.sep): | 539 if path == ext or path.startswith(ext + os.sep): |
538 return True, True | 540 return True, True |
539 return bool(changes), False | 541 return bool(changes), False |
540 | 542 |
541 def dirty(self): | 543 def dirty(self, ignoreupdate=False): |
542 if self._wcrev() == self._state[1] and not self._wcchanged()[0]: | 544 if not self._wcchanged()[0]: |
543 return False | 545 if self._wcrev() == self._state[1] and not ignoreupdate: |
546 return False | |
544 return True | 547 return True |
545 | 548 |
546 def commit(self, text, user, date): | 549 def commit(self, text, user, date): |
547 # user and date are out of our hands since svn is centralized | 550 # user and date are out of our hands since svn is centralized |
548 changed, extchanged = self._wcchanged() | 551 changed, extchanged = self._wcchanged() |