mercurial/subrepo.py
branchstable
changeset 14469 2fdea636f254
parent 14205 7b627923739f
child 14481 b2ee161328e0
child 14505 90ef40bf97e3
equal deleted inserted replaced
14379:bd23d5f28bbb 14469:2fdea636f254
   806             raise util.Abort(_("revision %s does not exist in subrepo %s\n") %
   806             raise util.Abort(_("revision %s does not exist in subrepo %s\n") %
   807                                (revision, self._relpath))
   807                                (revision, self._relpath))
   808 
   808 
   809     def dirty(self, ignoreupdate=False):
   809     def dirty(self, ignoreupdate=False):
   810         if self._gitmissing():
   810         if self._gitmissing():
   811             return True
   811             return self._state[1] != ''
   812         if not ignoreupdate and self._state[1] != self._gitstate():
   812         if not ignoreupdate and self._state[1] != self._gitstate():
   813             # different version checked out
   813             # different version checked out
   814             return True
   814             return True
   815         # check for staged changes or modified files; ignore untracked files
   815         # check for staged changes or modified files; ignore untracked files
   816         out, code = self._gitdir(['diff-index', '--quiet', 'HEAD'])
   816         out, code = self._gitdir(['diff-index', '--quiet', 'HEAD'])
   817         return code == 1
   817         return code == 1
   818 
   818 
   819     def get(self, state, overwrite=False):
   819     def get(self, state, overwrite=False):
   820         source, revision, kind = state
   820         source, revision, kind = state
       
   821         if not revision:
       
   822             self.remove()
       
   823             return
   821         self._fetch(source, revision)
   824         self._fetch(source, revision)
   822         # if the repo was set to be bare, unbare it
   825         # if the repo was set to be bare, unbare it
   823         if self._gitcommand(['config', '--bool', 'core.bare']) == 'true':
   826         if self._gitcommand(['config', '--bool', 'core.bare']) == 'true':
   824             self._gitcommand(['config', 'core.bare', 'false'])
   827             self._gitcommand(['config', 'core.bare', 'false'])
   825             if self._gitstate() == revision:
   828             if self._gitstate() == revision:
   933                     mergefunc()
   936                     mergefunc()
   934         else:
   937         else:
   935             mergefunc()
   938             mergefunc()
   936 
   939 
   937     def push(self, force):
   940     def push(self, force):
       
   941         if not self._state[1]:
       
   942             return True
   938         if self._gitmissing():
   943         if self._gitmissing():
   939             raise util.Abort(_("subrepo %s is missing") % self._relpath)
   944             raise util.Abort(_("subrepo %s is missing") % self._relpath)
   940         # if a branch in origin contains the revision, nothing to do
   945         # if a branch in origin contains the revision, nothing to do
   941         branch2rev, rev2branch = self._gitbranchmap()
   946         branch2rev, rev2branch = self._gitbranchmap()
   942         if self._state[1] in rev2branch:
   947         if self._state[1] in rev2branch:
   989             else:
   994             else:
   990                 os.remove(path)
   995                 os.remove(path)
   991 
   996 
   992     def archive(self, ui, archiver, prefix):
   997     def archive(self, ui, archiver, prefix):
   993         source, revision = self._state
   998         source, revision = self._state
       
   999         if not revision:
       
  1000             return
   994         self._fetch(source, revision)
  1001         self._fetch(source, revision)
   995 
  1002 
   996         # Parse git's native archive command.
  1003         # Parse git's native archive command.
   997         # This should be much faster than manually traversing the trees
  1004         # This should be much faster than manually traversing the trees
   998         # and objects with many subprocess calls.
  1005         # and objects with many subprocess calls.
  1013                         unit=_('files'))
  1020                         unit=_('files'))
  1014         ui.progress(_('archiving (%s)') % relpath, None)
  1021         ui.progress(_('archiving (%s)') % relpath, None)
  1015 
  1022 
  1016 
  1023 
  1017     def status(self, rev2, **opts):
  1024     def status(self, rev2, **opts):
  1018         if self._gitmissing():
  1025         rev1 = self._state[1]
       
  1026         if self._gitmissing() or not rev1:
  1019             # if the repo is missing, return no results
  1027             # if the repo is missing, return no results
  1020             return [], [], [], [], [], [], []
  1028             return [], [], [], [], [], [], []
  1021         rev1 = self._state[1]
       
  1022         modified, added, removed = [], [], []
  1029         modified, added, removed = [], [], []
  1023         if rev2:
  1030         if rev2:
  1024             command = ['diff-tree', rev1, rev2]
  1031             command = ['diff-tree', rev1, rev2]
  1025         else:
  1032         else:
  1026             command = ['diff-index', rev1]
  1033             command = ['diff-index', rev1]