comparison mercurial/subrepo.py @ 14481:b2ee161328e0

merge with stable
author Matt Mackall <mpm@selenic.com>
date Tue, 31 May 2011 15:28:23 -0500
parents 6fe6defdc924 2fdea636f254
children 278a4e0fdfed
comparison
equal deleted inserted replaced
14480:a21246c7e7d7 14481:b2ee161328e0
822 raise util.Abort(_("revision %s does not exist in subrepo %s\n") % 822 raise util.Abort(_("revision %s does not exist in subrepo %s\n") %
823 (revision, self._relpath)) 823 (revision, self._relpath))
824 824
825 def dirty(self, ignoreupdate=False): 825 def dirty(self, ignoreupdate=False):
826 if self._gitmissing(): 826 if self._gitmissing():
827 return True 827 return self._state[1] != ''
828 if self._gitisbare(): 828 if self._gitisbare():
829 return True 829 return True
830 if not ignoreupdate and self._state[1] != self._gitstate(): 830 if not ignoreupdate and self._state[1] != self._gitstate():
831 # different version checked out 831 # different version checked out
832 return True 832 return True
834 out, code = self._gitdir(['diff-index', '--quiet', 'HEAD']) 834 out, code = self._gitdir(['diff-index', '--quiet', 'HEAD'])
835 return code == 1 835 return code == 1
836 836
837 def get(self, state, overwrite=False): 837 def get(self, state, overwrite=False):
838 source, revision, kind = state 838 source, revision, kind = state
839 if not revision:
840 self.remove()
841 return
839 self._fetch(source, revision) 842 self._fetch(source, revision)
840 # if the repo was set to be bare, unbare it 843 # if the repo was set to be bare, unbare it
841 if self._gitisbare(): 844 if self._gitisbare():
842 self._gitcommand(['config', 'core.bare', 'false']) 845 self._gitcommand(['config', 'core.bare', 'false'])
843 if self._gitstate() == revision: 846 if self._gitstate() == revision:
951 mergefunc() 954 mergefunc()
952 else: 955 else:
953 mergefunc() 956 mergefunc()
954 957
955 def push(self, force): 958 def push(self, force):
959 if not self._state[1]:
960 return True
956 if self._gitmissing(): 961 if self._gitmissing():
957 raise util.Abort(_("subrepo %s is missing") % self._relpath) 962 raise util.Abort(_("subrepo %s is missing") % self._relpath)
958 # if a branch in origin contains the revision, nothing to do 963 # if a branch in origin contains the revision, nothing to do
959 branch2rev, rev2branch = self._gitbranchmap() 964 branch2rev, rev2branch = self._gitbranchmap()
960 if self._state[1] in rev2branch: 965 if self._state[1] in rev2branch:
1007 else: 1012 else:
1008 os.remove(path) 1013 os.remove(path)
1009 1014
1010 def archive(self, ui, archiver, prefix): 1015 def archive(self, ui, archiver, prefix):
1011 source, revision = self._state 1016 source, revision = self._state
1017 if not revision:
1018 return
1012 self._fetch(source, revision) 1019 self._fetch(source, revision)
1013 1020
1014 # Parse git's native archive command. 1021 # Parse git's native archive command.
1015 # This should be much faster than manually traversing the trees 1022 # This should be much faster than manually traversing the trees
1016 # and objects with many subprocess calls. 1023 # and objects with many subprocess calls.
1031 unit=_('files')) 1038 unit=_('files'))
1032 ui.progress(_('archiving (%s)') % relpath, None) 1039 ui.progress(_('archiving (%s)') % relpath, None)
1033 1040
1034 1041
1035 def status(self, rev2, **opts): 1042 def status(self, rev2, **opts):
1036 if self._gitmissing(): 1043 rev1 = self._state[1]
1044 if self._gitmissing() or not rev1:
1037 # if the repo is missing, return no results 1045 # if the repo is missing, return no results
1038 return [], [], [], [], [], [], [] 1046 return [], [], [], [], [], [], []
1039 rev1 = self._state[1]
1040 modified, added, removed = [], [], [] 1047 modified, added, removed = [], [], []
1041 if rev2: 1048 if rev2:
1042 command = ['diff-tree', rev1, rev2] 1049 command = ['diff-tree', rev1, rev2]
1043 else: 1050 else:
1044 command = ['diff-index', rev1] 1051 command = ['diff-index', rev1]