mercurial/subrepo.py
branchstable
changeset 13322 c19b9282d3a7
parent 13287 d0e0d3d43e14
child 13323 d8d478f9ee0f
child 13332 927e3940bfc3
equal deleted inserted replaced
13314:8dc488dfcdb4 13322:c19b9282d3a7
    80     """rewrite .hgsubstate in (outer) repo with these subrepo states"""
    80     """rewrite .hgsubstate in (outer) repo with these subrepo states"""
    81     repo.wwrite('.hgsubstate',
    81     repo.wwrite('.hgsubstate',
    82                 ''.join(['%s %s\n' % (state[s][1], s)
    82                 ''.join(['%s %s\n' % (state[s][1], s)
    83                          for s in sorted(state)]), '')
    83                          for s in sorted(state)]), '')
    84 
    84 
    85 def submerge(repo, wctx, mctx, actx):
    85 def submerge(repo, wctx, mctx, actx, overwrite):
    86     """delegated from merge.applyupdates: merging of .hgsubstate file
    86     """delegated from merge.applyupdates: merging of .hgsubstate file
    87     in working context, merging context and ancestor context"""
    87     in working context, merging context and ancestor context"""
    88     if mctx == actx: # backwards?
    88     if mctx == actx: # backwards?
    89         actx = wctx.p1()
    89         actx = wctx.p1()
    90     s1 = wctx.substate
    90     s1 = wctx.substate
   112             if ld == r or r == a: # no change or local is newer
   112             if ld == r or r == a: # no change or local is newer
   113                 sm[s] = l
   113                 sm[s] = l
   114                 continue
   114                 continue
   115             elif ld == a: # other side changed
   115             elif ld == a: # other side changed
   116                 debug(s, "other changed, get", r)
   116                 debug(s, "other changed, get", r)
   117                 wctx.sub(s).get(r)
   117                 wctx.sub(s).get(r, overwrite)
   118                 sm[s] = r
   118                 sm[s] = r
   119             elif ld[0] != r[0]: # sources differ
   119             elif ld[0] != r[0]: # sources differ
   120                 if repo.ui.promptchoice(
   120                 if repo.ui.promptchoice(
   121                     _(' subrepository sources for %s differ\n'
   121                     _(' subrepository sources for %s differ\n'
   122                       'use (l)ocal source (%s) or (r)emote source (%s)?')
   122                       'use (l)ocal source (%s) or (r)emote source (%s)?')
   123                       % (s, l[0], r[0]),
   123                       % (s, l[0], r[0]),
   124                       (_('&Local'), _('&Remote')), 0):
   124                       (_('&Local'), _('&Remote')), 0):
   125                     debug(s, "prompt changed, get", r)
   125                     debug(s, "prompt changed, get", r)
   126                     wctx.sub(s).get(r)
   126                     wctx.sub(s).get(r, overwrite)
   127                     sm[s] = r
   127                     sm[s] = r
   128             elif ld[1] == a[1]: # local side is unchanged
   128             elif ld[1] == a[1]: # local side is unchanged
   129                 debug(s, "other side changed, get", r)
   129                 debug(s, "other side changed, get", r)
   130                 wctx.sub(s).get(r)
   130                 wctx.sub(s).get(r, overwrite)
   131                 sm[s] = r
   131                 sm[s] = r
   132             else:
   132             else:
   133                 debug(s, "both sides changed, merge with", r)
   133                 debug(s, "both sides changed, merge with", r)
   134                 wctx.sub(s).merge(r)
   134                 wctx.sub(s).merge(r)
   135                 sm[s] = l
   135                 sm[s] = l
   258 
   258 
   259         (should verify the dirstate is not dirty first)
   259         (should verify the dirstate is not dirty first)
   260         """
   260         """
   261         raise NotImplementedError
   261         raise NotImplementedError
   262 
   262 
   263     def get(self, state):
   263     def get(self, state, overwrite=False):
   264         """run whatever commands are needed to put the subrepo into
   264         """run whatever commands are needed to put the subrepo into
   265         this state
   265         this state
   266         """
   266         """
   267         raise NotImplementedError
   267         raise NotImplementedError
   268 
   268 
   269     def merge(self, state):
   269     def merge(self, state, overwrite=False):
   270         """merge currently-saved state with the new state."""
   270         """merge currently-saved state with the new state."""
   271         raise NotImplementedError
   271         raise NotImplementedError
   272 
   272 
   273     def push(self, force):
   273     def push(self, force):
   274         """perform whatever action is analogous to 'hg push'
   274         """perform whatever action is analogous to 'hg push'
   417             self._repo.ui.status(_('pulling subrepo %s from %s\n')
   417             self._repo.ui.status(_('pulling subrepo %s from %s\n')
   418                                  % (subrelpath(self), srcurl))
   418                                  % (subrelpath(self), srcurl))
   419             other = hg.repository(self._repo.ui, srcurl)
   419             other = hg.repository(self._repo.ui, srcurl)
   420             self._repo.pull(other)
   420             self._repo.pull(other)
   421 
   421 
   422     def get(self, state):
   422     def get(self, state, overwrite=False):
   423         self._get(state)
   423         self._get(state)
   424         source, revision, kind = state
   424         source, revision, kind = state
   425         self._repo.ui.debug("getting subrepo %s\n" % self._path)
   425         self._repo.ui.debug("getting subrepo %s\n" % self._path)
   426         hg.clean(self._repo, revision, False)
   426         hg.clean(self._repo, revision, False)
   427 
   427 
   587         try:
   587         try:
   588             os.removedirs(os.path.dirname(path))
   588             os.removedirs(os.path.dirname(path))
   589         except OSError:
   589         except OSError:
   590             pass
   590             pass
   591 
   591 
   592     def get(self, state):
   592     def get(self, state, overwrite=False):
       
   593         if overwrite:
       
   594             self._svncommand(['revert', '--recursive', self._path])
   593         status = self._svncommand(['checkout', state[0], '--revision', state[1]])
   595         status = self._svncommand(['checkout', state[0], '--revision', state[1]])
   594         if not re.search('Checked out revision [0-9]+.', status):
   596         if not re.search('Checked out revision [0-9]+.', status):
   595             raise util.Abort(status.splitlines()[-1])
   597             raise util.Abort(status.splitlines()[-1])
   596         self._ui.status(status)
   598         self._ui.status(status)
   597 
   599