mercurial/commands.py
changeset 4666 48c94bffdb28
parent 4665 091c9e54d306
child 4667 c7a81e3ae80f
equal deleted inserted replaced
4665:091c9e54d306 4666:48c94bffdb28
  1430             if second:
  1430             if second:
  1431                 ui.write(" %-*s  %s\n" % (opts_len, first, second))
  1431                 ui.write(" %-*s  %s\n" % (opts_len, first, second))
  1432             else:
  1432             else:
  1433                 ui.write("%s\n" % first)
  1433                 ui.write("%s\n" % first)
  1434 
  1434 
  1435 def identify(ui, repo, rev=None):
  1435 def identify(ui, repo, rev=None, num=None, id=None, branch=None, tags=None):
  1436     """identify the working copy or specified revision
  1436     """identify the working copy or specified revision
  1437 
  1437 
  1438     With no argument, print a summary of the current state of the repo.
  1438     With no argument, print a summary of the current state of the repo.
  1439 
  1439 
  1440     This summary identifies the repository state using one or two parent
  1440     This summary identifies the repository state using one or two parent
  1442     in the working directory, a list of tags for this revision and a branch
  1442     in the working directory, a list of tags for this revision and a branch
  1443     name for non-default branches.
  1443     name for non-default branches.
  1444     """
  1444     """
  1445 
  1445 
  1446     hexfunc = ui.debugflag and hex or short
  1446     hexfunc = ui.debugflag and hex or short
       
  1447     default = not (num or id or branch or tags)
       
  1448     output = []
  1447 
  1449 
  1448     if not rev:
  1450     if not rev:
  1449         ctx = repo.workingctx()
  1451         ctx = repo.workingctx()
  1450         parents = ctx.parents()
  1452         parents = ctx.parents()
  1451         changed = ctx.files() + ctx.deleted()
  1453         changed = False
  1452         output = ["%s%s" % ('+'.join([hexfunc(p.node()) for p in parents]),
  1454         if default or id or num:
  1453                             (changed) and "+" or "")]
  1455             changed = ctx.files() + ctx.deleted()
       
  1456         if default or id:
       
  1457             output = ["%s%s" % ('+'.join([hexfunc(p.node()) for p in parents]),
       
  1458                                 (changed) and "+" or "")]
       
  1459         if num:
       
  1460             output.append("%s%s" % ('+'.join([str(p.rev()) for p in parents]),
       
  1461                                     (changed) and "+" or ""))
  1454     else:
  1462     else:
  1455         ctx = repo.changectx(rev)
  1463         ctx = repo.changectx(rev)
  1456         output = [hexfunc(ctx.node())]
  1464         if default or id:
  1457 
  1465             output = [hexfunc(ctx.node())]
  1458     if not ui.quiet:
  1466         if num:
  1459         branch = util.tolocal(ctx.branch())
  1467             output.append(str(ctx.rev()))
  1460         if branch != 'default':
  1468 
  1461             output.append("(%s)" % branch)
  1469     if default and not ui.quiet:
       
  1470         b = util.tolocal(ctx.branch())
       
  1471         if b != 'default':
       
  1472             output.append("(%s)" % b)
  1462 
  1473 
  1463         # multiple tags for a single parent separated by '/'
  1474         # multiple tags for a single parent separated by '/'
  1464         tags = "/".join(ctx.tags())
  1475         t = "/".join(ctx.tags())
  1465         if tags:
  1476         if t:
  1466             output.append(tags)
  1477             output.append(t)
       
  1478 
       
  1479     if branch:
       
  1480         output.append(util.tolocal(ctx.branch()))
       
  1481 
       
  1482     if tags:
       
  1483         output.extend(ctx.tags())
  1467 
  1484 
  1468     ui.write("%s\n" % ' '.join(output))
  1485     ui.write("%s\n" % ' '.join(output))
  1469 
  1486 
  1470 def import_(ui, repo, patch1, *patches, **opts):
  1487 def import_(ui, repo, patch1, *patches, **opts):
  1471     """import an ordered set of patches
  1488     """import an ordered set of patches
  2825           ('', 'template', '', _('display with template'))],
  2842           ('', 'template', '', _('display with template'))],
  2826          _('hg heads [-r REV] [REV]...')),
  2843          _('hg heads [-r REV] [REV]...')),
  2827     "help": (help_, [], _('hg help [COMMAND]')),
  2844     "help": (help_, [], _('hg help [COMMAND]')),
  2828     "identify|id":
  2845     "identify|id":
  2829         (identify,
  2846         (identify,
  2830          [('r', 'rev', '', _('identify the specified rev'))],
  2847          [('r', 'rev', '', _('identify the specified rev')),
  2831          _('hg identify [-r REV]')),
  2848           ('n', 'num', None, _('show local revision number')),
       
  2849           ('i', 'id', None, _('show global revision id')),
       
  2850           ('b', 'branch', None, _('show branch')),
       
  2851           ('t', 'tags', None, _('show tags'))],
       
  2852          _('hg identify [-nibt] [-r REV]')),
  2832     "import|patch":
  2853     "import|patch":
  2833         (import_,
  2854         (import_,
  2834          [('p', 'strip', 1,
  2855          [('p', 'strip', 1,
  2835            _('directory strip option for patch. This has the same\n'
  2856            _('directory strip option for patch. This has the same\n'
  2836              'meaning as the corresponding patch option')),
  2857              'meaning as the corresponding patch option')),