comparison mercurial/subrepo.py @ 16072:bcb973abcc0b

subrepo: add basestate method This will allow us to sort out what's going on with state .hgsubstate files more precisely.
author Matt Mackall <mpm@selenic.com>
date Mon, 06 Feb 2012 15:00:08 -0600
parents 04604d1a9fc3
children 0196c437ca9f
comparison
equal deleted inserted replaced
16065:8af9e08a094f 16072:bcb973abcc0b
273 match current stored state. If ignoreupdate is true, only check 273 match current stored state. If ignoreupdate is true, only check
274 whether the subrepo has uncommitted changes in its dirstate. 274 whether the subrepo has uncommitted changes in its dirstate.
275 """ 275 """
276 raise NotImplementedError 276 raise NotImplementedError
277 277
278 def basestate(self):
279 """current working directory base state, disregarding .hgsubstate
280 state and working directory modifications"""
281 raise NotImplementedError
282
278 def checknested(self, path): 283 def checknested(self, path):
279 """check if path is a subrepository within this repository""" 284 """check if path is a subrepository within this repository"""
280 return False 285 return False
281 286
282 def commit(self, text, user, date): 287 def commit(self, text, user, date):
443 w = self._repo[None] 448 w = self._repo[None]
444 if r != w.p1().hex() and not ignoreupdate: 449 if r != w.p1().hex() and not ignoreupdate:
445 # different version checked out 450 # different version checked out
446 return True 451 return True
447 return w.dirty() # working directory changed 452 return w.dirty() # working directory changed
453
454 def basestate(self):
455 return self._repo['.'].hex()
448 456
449 def checknested(self, path): 457 def checknested(self, path):
450 return self._repo._checknested(self._repo.wjoin(path)) 458 return self._repo._checknested(self._repo.wjoin(path))
451 459
452 def commit(self, text, user, date): 460 def commit(self, text, user, date):
664 if not self._wcchanged()[0]: 672 if not self._wcchanged()[0]:
665 if self._state[1] in self._wcrevs() or ignoreupdate: 673 if self._state[1] in self._wcrevs() or ignoreupdate:
666 return False 674 return False
667 return True 675 return True
668 676
677 def basestate(self):
678 return self._wcrev()
679
669 def commit(self, text, user, date): 680 def commit(self, text, user, date):
670 # user and date are out of our hands since svn is centralized 681 # user and date are out of our hands since svn is centralized
671 changed, extchanged = self._wcchanged() 682 changed, extchanged = self._wcchanged()
672 if not changed: 683 if not changed:
673 return self._wcrev() 684 return self._wcrev()
904 return True 915 return True
905 # check for staged changes or modified files; ignore untracked files 916 # check for staged changes or modified files; ignore untracked files
906 self._gitupdatestat() 917 self._gitupdatestat()
907 out, code = self._gitdir(['diff-index', '--quiet', 'HEAD']) 918 out, code = self._gitdir(['diff-index', '--quiet', 'HEAD'])
908 return code == 1 919 return code == 1
920
921 def basestate(self):
922 return self._gitstate()
909 923
910 def get(self, state, overwrite=False): 924 def get(self, state, overwrite=False):
911 source, revision, kind = state 925 source, revision, kind = state
912 if not revision: 926 if not revision:
913 self.remove() 927 self.remove()