Mercurial > public > mercurial-scm > hg
comparison mercurial/subrepo.py @ 13558:f854b775c386
merge with stable
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Mon, 07 Mar 2011 15:46:46 -0600 |
parents | d4c2f2ac3ff7 dea6efdd7ec4 |
children | a2734c8322ac |
comparison
equal
deleted
inserted
replaced
13555:970150ddaaf8 | 13558:f854b775c386 |
---|---|
701 raise util.Abort('git %s error %d in %s' % | 701 raise util.Abort('git %s error %d in %s' % |
702 (command, p.returncode, self._relpath)) | 702 (command, p.returncode, self._relpath)) |
703 | 703 |
704 return retdata, p.returncode | 704 return retdata, p.returncode |
705 | 705 |
706 def _gitmissing(self): | |
707 return not os.path.exists(os.path.join(self._abspath, '.git')) | |
708 | |
706 def _gitstate(self): | 709 def _gitstate(self): |
707 return self._gitcommand(['rev-parse', 'HEAD']) | 710 return self._gitcommand(['rev-parse', 'HEAD']) |
708 | 711 |
709 def _gitcurrentbranch(self): | 712 def _gitcurrentbranch(self): |
710 current, err = self._gitdir(['symbolic-ref', 'HEAD', '--quiet']) | 713 current, err = self._gitdir(['symbolic-ref', 'HEAD', '--quiet']) |
757 def _abssource(self, source): | 760 def _abssource(self, source): |
758 self._subsource = source | 761 self._subsource = source |
759 return _abssource(self) | 762 return _abssource(self) |
760 | 763 |
761 def _fetch(self, source, revision): | 764 def _fetch(self, source, revision): |
762 if not os.path.exists(os.path.join(self._abspath, '.git')): | 765 if self._gitmissing(): |
763 source = self._abssource(source) | 766 source = self._abssource(source) |
764 self._ui.status(_('cloning subrepo %s from %s\n') % | 767 self._ui.status(_('cloning subrepo %s from %s\n') % |
765 (self._relpath, source)) | 768 (self._relpath, source)) |
766 self._gitnodir(['clone', source, self._abspath]) | 769 self._gitnodir(['clone', source, self._abspath]) |
767 if self._githavelocally(revision): | 770 if self._githavelocally(revision): |
772 if not self._githavelocally(revision): | 775 if not self._githavelocally(revision): |
773 raise util.Abort(_("revision %s does not exist in subrepo %s\n") % | 776 raise util.Abort(_("revision %s does not exist in subrepo %s\n") % |
774 (revision, self._relpath)) | 777 (revision, self._relpath)) |
775 | 778 |
776 def dirty(self, ignoreupdate=False): | 779 def dirty(self, ignoreupdate=False): |
780 if self._gitmissing(): | |
781 return True | |
777 if not ignoreupdate and self._state[1] != self._gitstate(): | 782 if not ignoreupdate and self._state[1] != self._gitstate(): |
778 # different version checked out | 783 # different version checked out |
779 return True | 784 return True |
780 # check for staged changes or modified files; ignore untracked files | 785 # check for staged changes or modified files; ignore untracked files |
781 out, code = self._gitdir(['diff-index', '--quiet', 'HEAD']) | 786 out, code = self._gitdir(['diff-index', '--quiet', 'HEAD']) |
860 else: | 865 else: |
861 # a real merge would be required, just checkout the revision | 866 # a real merge would be required, just checkout the revision |
862 rawcheckout() | 867 rawcheckout() |
863 | 868 |
864 def commit(self, text, user, date): | 869 def commit(self, text, user, date): |
870 if self._gitmissing(): | |
871 raise util.Abort(_("subrepo %s is missing") % self._relpath) | |
865 cmd = ['commit', '-a', '-m', text] | 872 cmd = ['commit', '-a', '-m', text] |
866 env = os.environ.copy() | 873 env = os.environ.copy() |
867 if user: | 874 if user: |
868 cmd += ['--author', user] | 875 cmd += ['--author', user] |
869 if date: | 876 if date: |
896 mergefunc() | 903 mergefunc() |
897 else: | 904 else: |
898 mergefunc() | 905 mergefunc() |
899 | 906 |
900 def push(self, force): | 907 def push(self, force): |
908 if self._gitmissing(): | |
909 raise util.Abort(_("subrepo %s is missing") % self._relpath) | |
901 # if a branch in origin contains the revision, nothing to do | 910 # if a branch in origin contains the revision, nothing to do |
902 branch2rev, rev2branch = self._gitbranchmap() | 911 branch2rev, rev2branch = self._gitbranchmap() |
903 if self._state[1] in rev2branch: | 912 if self._state[1] in rev2branch: |
904 for b in rev2branch[self._state[1]]: | 913 for b in rev2branch[self._state[1]]: |
905 if b.startswith('refs/remotes/origin/'): | 914 if b.startswith('refs/remotes/origin/'): |
929 'cannot push revision %s') % | 938 'cannot push revision %s') % |
930 (self._relpath, self._state[1])) | 939 (self._relpath, self._state[1])) |
931 return False | 940 return False |
932 | 941 |
933 def remove(self): | 942 def remove(self): |
943 if self._gitmissing(): | |
944 return | |
934 if self.dirty(): | 945 if self.dirty(): |
935 self._ui.warn(_('not removing repo %s because ' | 946 self._ui.warn(_('not removing repo %s because ' |
936 'it has changes.\n') % self._relpath) | 947 'it has changes.\n') % self._relpath) |
937 return | 948 return |
938 # we can't fully delete the repository as it may contain | 949 # we can't fully delete the repository as it may contain |
972 unit=_('files')) | 983 unit=_('files')) |
973 ui.progress(_('archiving (%s)') % relpath, None) | 984 ui.progress(_('archiving (%s)') % relpath, None) |
974 | 985 |
975 | 986 |
976 def status(self, rev2, **opts): | 987 def status(self, rev2, **opts): |
988 if self._gitmissing(): | |
989 # if the repo is missing, return no results | |
990 return [], [], [], [], [], [], [] | |
977 rev1 = self._state[1] | 991 rev1 = self._state[1] |
978 modified, added, removed = [], [], [] | 992 modified, added, removed = [], [], [] |
979 if rev2: | 993 if rev2: |
980 command = ['diff-tree', rev1, rev2] | 994 command = ['diff-tree', rev1, rev2] |
981 else: | 995 else: |