mercurial/commands.py
changeset 24126 b4d21bbc2589
parent 24125 18af6ebd4001
child 24127 4cb8002658d6
equal deleted inserted replaced
24125:18af6ebd4001 24126:b4d21bbc2589
  5275         raise util.Abort(_("can't specify --all and patterns"))
  5275         raise util.Abort(_("can't specify --all and patterns"))
  5276     if not (all or pats or show or mark or unmark):
  5276     if not (all or pats or show or mark or unmark):
  5277         raise util.Abort(_('no files or directories specified'),
  5277         raise util.Abort(_('no files or directories specified'),
  5278                          hint=('use --all to remerge all files'))
  5278                          hint=('use --all to remerge all files'))
  5279 
  5279 
       
  5280     if show:
       
  5281         ms = mergemod.mergestate(repo)
       
  5282         m = scmutil.match(repo[None], pats, opts)
       
  5283         for f in ms:
       
  5284             if not m(f):
       
  5285                 continue
       
  5286             if nostatus:
       
  5287                 ui.write("%s\n" % f)
       
  5288             else:
       
  5289                 ui.write("%s %s\n" % (ms[f].upper(), f),
       
  5290                          label='resolve.' +
       
  5291                          {'u': 'unresolved', 'r': 'resolved'}[ms[f]])
       
  5292         return 0
       
  5293 
  5280     wlock = repo.wlock()
  5294     wlock = repo.wlock()
  5281     try:
  5295     try:
  5282         ms = mergemod.mergestate(repo)
  5296         ms = mergemod.mergestate(repo)
  5283 
  5297 
  5284         if not (ms.active() or repo.dirstate.p2() != nullid) and not show:
  5298         if not (ms.active() or repo.dirstate.p2() != nullid):
  5285             raise util.Abort(
  5299             raise util.Abort(
  5286                 _('resolve command not applicable when not merging'))
  5300                 _('resolve command not applicable when not merging'))
  5287 
  5301 
  5288         m = scmutil.match(repo[None], pats, opts)
  5302         m = scmutil.match(repo[None], pats, opts)
  5289         ret = 0
  5303         ret = 0
  5293             if not m(f):
  5307             if not m(f):
  5294                 continue
  5308                 continue
  5295 
  5309 
  5296             didwork = True
  5310             didwork = True
  5297 
  5311 
  5298             if show:
  5312             if mark:
  5299                 if nostatus:
       
  5300                     ui.write("%s\n" % f)
       
  5301                 else:
       
  5302                     ui.write("%s %s\n" % (ms[f].upper(), f),
       
  5303                              label='resolve.' +
       
  5304                              {'u': 'unresolved', 'r': 'resolved'}[ms[f]])
       
  5305             elif mark:
       
  5306                 ms.mark(f, "r")
  5313                 ms.mark(f, "r")
  5307             elif unmark:
  5314             elif unmark:
  5308                 ms.mark(f, "u")
  5315                 ms.mark(f, "u")
  5309             else:
  5316             else:
  5310                 wctx = repo[None]
  5317                 wctx = repo[None]
  5326                 # replace filemerge's .orig file with our resolve file
  5333                 # replace filemerge's .orig file with our resolve file
  5327                 util.rename(a + ".resolve", a + ".orig")
  5334                 util.rename(a + ".resolve", a + ".orig")
  5328 
  5335 
  5329         ms.commit()
  5336         ms.commit()
  5330 
  5337 
  5331         if not didwork and pats and not show:
  5338         if not didwork and pats:
  5332             ui.warn(_("arguments do not match paths that need resolving\n"))
  5339             ui.warn(_("arguments do not match paths that need resolving\n"))
  5333 
  5340 
  5334     finally:
  5341     finally:
  5335         wlock.release()
  5342         wlock.release()
  5336 
  5343 
  5337     # Nudge users into finishing an unfinished operation. We don't print
  5344     # Nudge users into finishing an unfinished operation
  5338     # this with the list/show operation because we want list/show to remain
  5345     if not list(ms.unresolved()):
  5339     # machine readable.
       
  5340     if not list(ms.unresolved()) and not show:
       
  5341         ui.status(_('(no more unresolved files)\n'))
  5346         ui.status(_('(no more unresolved files)\n'))
  5342 
  5347 
  5343     return ret
  5348     return ret
  5344 
  5349 
  5345 @command('revert',
  5350 @command('revert',