Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/subrepo.py @ 18940:798bdb7f1517
subrepo: do not push mercurial subrepos whose store is clean
This patch stops mercurial from pushing unmodified subrepos. An unmodified
subrepo is one whose store is "clean" versus a given target subrepo.
Note that subrepos may have a clean store versus a target repo but not versus another. This patch handles this scenario by individually keeping track of the state of the store versus all push targets.
Tests will be added on the following revision.
author | Angel Ezquerra <angel.ezquerra@gmail.com> |
---|---|
date | Sat, 16 Feb 2013 01:21:40 +0100 |
parents | aab0c14c20d0 |
children | 27e8dfc2c338 |
comparison
equal
deleted
inserted
replaced
18939:aab0c14c20d0 | 18940:798bdb7f1517 |
---|---|
12 hg = None | 12 hg = None |
13 propertycache = util.propertycache | 13 propertycache = util.propertycache |
14 | 14 |
15 nullstate = ('', '', 'empty') | 15 nullstate = ('', '', 'empty') |
16 | 16 |
17 def _expandedabspath(path): | |
18 ''' | |
19 get a path or url and if it is a path expand it and return an absolute path | |
20 ''' | |
21 expandedpath = util.urllocalpath(util.expandpath(path)) | |
22 u = util.url(expandedpath) | |
23 if not u.scheme: | |
24 path = util.normpath(os.path.abspath(u.path)) | |
25 return path | |
17 | 26 |
18 def _getstorehashcachename(remotepath): | 27 def _getstorehashcachename(remotepath): |
19 '''get a unique filename for the store hash cache of a remote repository''' | 28 '''get a unique filename for the store hash cache of a remote repository''' |
20 return util.sha1(remotepath).hexdigest()[0:12] | 29 return util.sha1(_expandedabspath(remotepath)).hexdigest()[0:12] |
21 | 30 |
22 def _calcfilehash(filename): | 31 def _calcfilehash(filename): |
23 data = '' | 32 data = '' |
24 if os.path.exists(filename): | 33 if os.path.exists(filename): |
25 fd = open(filename) | 34 fd = open(filename) |
473 | 482 |
474 This method is used to to detect when there are changes that may | 483 This method is used to to detect when there are changes that may |
475 require a push to a given remote path.''' | 484 require a push to a given remote path.''' |
476 # sort the files that will be hashed in increasing (likely) file size | 485 # sort the files that will be hashed in increasing (likely) file size |
477 filelist = ('bookmarks', 'store/phaseroots', 'store/00changelog.i') | 486 filelist = ('bookmarks', 'store/phaseroots', 'store/00changelog.i') |
478 yield '# %s\n' % remotepath | 487 yield '# %s\n' % _expandedabspath(remotepath) |
479 for relname in filelist: | 488 for relname in filelist: |
480 absname = os.path.normpath(self._repo.join(relname)) | 489 absname = os.path.normpath(self._repo.join(relname)) |
481 yield '%s = %s\n' % (absname, _calcfilehash(absname)) | 490 yield '%s = %s\n' % (relname, _calcfilehash(absname)) |
482 | 491 |
483 def _getstorehashcachepath(self, remotepath): | 492 def _getstorehashcachepath(self, remotepath): |
484 '''get a unique path for the store hash cache''' | 493 '''get a unique path for the store hash cache''' |
485 return self._repo.join(os.path.join( | 494 return self._repo.join(os.path.join( |
486 'cache', 'storehash', _getstorehashcachename(remotepath))) | 495 'cache', 'storehash', _getstorehashcachename(remotepath))) |
689 for s in sorted(subs): | 698 for s in sorted(subs): |
690 if c.sub(s).push(opts) == 0: | 699 if c.sub(s).push(opts) == 0: |
691 return False | 700 return False |
692 | 701 |
693 dsturl = _abssource(self._repo, True) | 702 dsturl = _abssource(self._repo, True) |
703 if not force: | |
704 if self.storeclean(dsturl): | |
705 self._repo.ui.status( | |
706 _('no changes made to subrepo %s since last push to %s\n') | |
707 % (subrelpath(self), dsturl)) | |
708 return None | |
694 self._repo.ui.status(_('pushing subrepo %s to %s\n') % | 709 self._repo.ui.status(_('pushing subrepo %s to %s\n') % |
695 (subrelpath(self), dsturl)) | 710 (subrelpath(self), dsturl)) |
696 other = hg.peer(self._repo, {'ssh': ssh}, dsturl) | 711 other = hg.peer(self._repo, {'ssh': ssh}, dsturl) |
697 res = self._repo.push(other, force, newbranch=newbranch) | 712 res = self._repo.push(other, force, newbranch=newbranch) |
698 | 713 |