hgext/mq.py
changeset 19813 76796fe65bad
parent 19812 5d6cfdc38a3d
child 19814 4495c6a272e0
equal deleted inserted replaced
19812:5d6cfdc38a3d 19813:76796fe65bad
   943             if repo.dirstate.p1() != top:
   943             if repo.dirstate.p1() != top:
   944                 raise util.Abort(_("working directory revision is not qtip"))
   944                 raise util.Abort(_("working directory revision is not qtip"))
   945             return top, patch
   945             return top, patch
   946         return None, None
   946         return None, None
   947 
   947 
   948     def checksubstate(self, repo, baserev=None):
       
   949         '''return list of subrepos at a different revision than substate.
       
   950         Abort if any subrepos have uncommitted changes.'''
       
   951         inclsubs = []
       
   952         wctx = repo[None]
       
   953         if baserev:
       
   954             bctx = repo[baserev]
       
   955         else:
       
   956             bctx = wctx.parents()[0]
       
   957         for s in sorted(wctx.substate):
       
   958             if wctx.sub(s).dirty(True):
       
   959                 raise util.Abort(
       
   960                     _("uncommitted changes in subrepository %s") % s)
       
   961             elif s not in bctx.substate or bctx.sub(s).dirty():
       
   962                 inclsubs.append(s)
       
   963         return inclsubs
       
   964 
       
   965     def putsubstate2changes(self, substatestate, changes):
   948     def putsubstate2changes(self, substatestate, changes):
   966         for files in changes[:3]:
   949         for files in changes[:3]:
   967             if '.hgsubstate' in files:
   950             if '.hgsubstate' in files:
   968                 return # already listed up
   951                 return # already listed up
   969         # not yet listed up
   952         # not yet listed up
   985         m, a, r, d = repo.status()[:4]
   968         m, a, r, d = repo.status()[:4]
   986         if not force:
   969         if not force:
   987             if (m or a or r or d):
   970             if (m or a or r or d):
   988                 _("local changes found") # i18n tool detection
   971                 _("local changes found") # i18n tool detection
   989                 raise util.Abort(_("local changes found" + excsuffix))
   972                 raise util.Abort(_("local changes found" + excsuffix))
   990             if self.checksubstate(repo):
   973             if checksubstate(repo):
   991                 _("local changed subrepos found") # i18n tool detection
   974                 _("local changed subrepos found") # i18n tool detection
   992                 raise util.Abort(_("local changed subrepos found" + excsuffix))
   975                 raise util.Abort(_("local changed subrepos found" + excsuffix))
   993         return m, a, r, d
   976         return m, a, r, d
   994 
   977 
   995     _reserved = ('series', 'status', 'guards', '.', '..')
   978     _reserved = ('series', 'status', 'guards', '.', '..')
  1029         if date:
  1012         if date:
  1030             date = util.parsedate(date)
  1013             date = util.parsedate(date)
  1031         diffopts = self.diffopts({'git': opts.get('git')})
  1014         diffopts = self.diffopts({'git': opts.get('git')})
  1032         if opts.get('checkname', True):
  1015         if opts.get('checkname', True):
  1033             self.checkpatchname(patchfn)
  1016             self.checkpatchname(patchfn)
  1034         inclsubs = self.checksubstate(repo)
  1017         inclsubs = checksubstate(repo)
  1035         if inclsubs:
  1018         if inclsubs:
  1036             inclsubs.append('.hgsubstate')
  1019             inclsubs.append('.hgsubstate')
  1037             substatestate = repo.dirstate['.hgsubstate']
  1020             substatestate = repo.dirstate['.hgsubstate']
  1038         if opts.get('include') or opts.get('exclude') or pats:
  1021         if opts.get('include') or opts.get('exclude') or pats:
  1039             if inclsubs:
  1022             if inclsubs:
  1503                                  hint=_('see "hg help phases" for details'))
  1486                                  hint=_('see "hg help phases" for details'))
  1504 
  1487 
  1505             cparents = repo.changelog.parents(top)
  1488             cparents = repo.changelog.parents(top)
  1506             patchparent = self.qparents(repo, top)
  1489             patchparent = self.qparents(repo, top)
  1507 
  1490 
  1508             inclsubs = self.checksubstate(repo, hex(patchparent))
  1491             inclsubs = checksubstate(repo, hex(patchparent))
  1509             if inclsubs:
  1492             if inclsubs:
  1510                 inclsubs.append('.hgsubstate')
  1493                 inclsubs.append('.hgsubstate')
  1511                 substatestate = repo.dirstate['.hgsubstate']
  1494                 substatestate = repo.dirstate['.hgsubstate']
  1512 
  1495 
  1513             ph = patchheader(self.join(patchfn), self.plainmode)
  1496             ph = patchheader(self.join(patchfn), self.plainmode)
  2928     if opts.get('empty'):
  2911     if opts.get('empty'):
  2929         del q.applied[:]
  2912         del q.applied[:]
  2930         q.applieddirty = True
  2913         q.applieddirty = True
  2931         q.savedirty()
  2914         q.savedirty()
  2932     return 0
  2915     return 0
       
  2916 
       
  2917 def checksubstate(repo, baserev=None):
       
  2918     '''return list of subrepos at a different revision than substate.
       
  2919     Abort if any subrepos have uncommitted changes.'''
       
  2920     inclsubs = []
       
  2921     wctx = repo[None]
       
  2922     if baserev:
       
  2923         bctx = repo[baserev]
       
  2924     else:
       
  2925         bctx = wctx.parents()[0]
       
  2926     for s in sorted(wctx.substate):
       
  2927         if wctx.sub(s).dirty(True):
       
  2928             raise util.Abort(
       
  2929                 _("uncommitted changes in subrepository %s") % s)
       
  2930         elif s not in bctx.substate or bctx.sub(s).dirty():
       
  2931             inclsubs.append(s)
       
  2932     return inclsubs
       
  2933 
  2933 
  2934 
  2934 @command("strip",
  2935 @command("strip",
  2935          [
  2936          [
  2936           ('r', 'rev', [], _('strip specified revision (optional, '
  2937           ('r', 'rev', [], _('strip specified revision (optional, '
  2937                                'can specify revisions without this '
  2938                                'can specify revisions without this '