mercurial/commands.py
changeset 4671 150afe6becf6
parent 4667 c7a81e3ae80f
child 4673 d8442fc0da8d
equal deleted inserted replaced
4670:850950e59b52 4671:150afe6becf6
  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, num=None, id=None, branch=None, tags=None):
  1435 def identify(ui, repo, source=None,
       
  1436              rev=None, num=None, id=None, branch=None, tags=None):
  1436     """identify the working copy or specified revision
  1437     """identify the working copy or specified revision
  1437 
  1438 
  1438     With no argument, print a summary of the current state of the repo.
  1439     With no revision, print a summary of the current state of the repo.
       
  1440 
       
  1441     With a path, do a lookup in another repository.
  1439 
  1442 
  1440     This summary identifies the repository state using one or two parent
  1443     This summary identifies the repository state using one or two parent
  1441     hash identifiers, followed by a "+" if there are uncommitted changes
  1444     hash identifiers, followed by a "+" if there are uncommitted changes
  1442     in the working directory, a list of tags for this revision and a branch
  1445     in the working directory, a list of tags for this revision and a branch
  1443     name for non-default branches.
  1446     name for non-default branches.
  1445 
  1448 
  1446     hexfunc = ui.debugflag and hex or short
  1449     hexfunc = ui.debugflag and hex or short
  1447     default = not (num or id or branch or tags)
  1450     default = not (num or id or branch or tags)
  1448     output = []
  1451     output = []
  1449 
  1452 
  1450     if not repo.local():
  1453     if source:
       
  1454         source, revs = cmdutil.parseurl(ui.expandpath(source), [])
       
  1455         srepo = hg.repository(ui, source)
       
  1456         if not rev and revs:
       
  1457             rev = revs[0]
  1451         if not rev:
  1458         if not rev:
  1452             rev = "tip"
  1459             rev = "tip"
  1453         if num or branch or tags:
  1460         if num or branch or tags:
  1454             raise util.Abort(
  1461             raise util.Abort(
  1455                 "can't query remote revision number, branch, or tags")
  1462                 "can't query remote revision number, branch, or tags")
  1456         output = [hexfunc(repo.lookup(rev))]
  1463         output = [hexfunc(srepo.lookup(rev))]
  1457     elif not rev:
  1464     elif not rev:
  1458         ctx = repo.workingctx()
  1465         ctx = repo.workingctx()
  1459         parents = ctx.parents()
  1466         parents = ctx.parents()
  1460         changed = False
  1467         changed = False
  1461         if default or id or num:
  1468         if default or id or num:
  1471         if default or id:
  1478         if default or id:
  1472             output = [hexfunc(ctx.node())]
  1479             output = [hexfunc(ctx.node())]
  1473         if num:
  1480         if num:
  1474             output.append(str(ctx.rev()))
  1481             output.append(str(ctx.rev()))
  1475 
  1482 
  1476     if repo.local() and default and not ui.quiet:
  1483     if not source and default and not ui.quiet:
  1477         b = util.tolocal(ctx.branch())
  1484         b = util.tolocal(ctx.branch())
  1478         if b != 'default':
  1485         if b != 'default':
  1479             output.append("(%s)" % b)
  1486             output.append("(%s)" % b)
  1480 
  1487 
  1481         # multiple tags for a single parent separated by '/'
  1488         # multiple tags for a single parent separated by '/'
  2854          [('r', 'rev', '', _('identify the specified rev')),
  2861          [('r', 'rev', '', _('identify the specified rev')),
  2855           ('n', 'num', None, _('show local revision number')),
  2862           ('n', 'num', None, _('show local revision number')),
  2856           ('i', 'id', None, _('show global revision id')),
  2863           ('i', 'id', None, _('show global revision id')),
  2857           ('b', 'branch', None, _('show branch')),
  2864           ('b', 'branch', None, _('show branch')),
  2858           ('t', 'tags', None, _('show tags'))],
  2865           ('t', 'tags', None, _('show tags'))],
  2859          _('hg identify [-nibt] [-r REV]')),
  2866          _('hg identify [-nibt] [-r REV] [SOURCE]')),
  2860     "import|patch":
  2867     "import|patch":
  2861         (import_,
  2868         (import_,
  2862          [('p', 'strip', 1,
  2869          [('p', 'strip', 1,
  2863            _('directory strip option for patch. This has the same\n'
  2870            _('directory strip option for patch. This has the same\n'
  2864              'meaning as the corresponding patch option')),
  2871              'meaning as the corresponding patch option')),
  3061 }
  3068 }
  3062 
  3069 
  3063 norepo = ("clone init version help debugancestor debugcomplete debugdata"
  3070 norepo = ("clone init version help debugancestor debugcomplete debugdata"
  3064           " debugindex debugindexdot debugdate debuginstall")
  3071           " debugindex debugindexdot debugdate debuginstall")
  3065 optionalrepo = ("paths serve showconfig")
  3072 optionalrepo = ("paths serve showconfig")
  3066 remoterepo = ("identify")
       
  3067 
  3073 
  3068 def dispatch(args):
  3074 def dispatch(args):
  3069     try:
  3075     try:
  3070         u = ui.ui(traceback='--traceback' in args)
  3076         u = ui.ui(traceback='--traceback' in args)
  3071     except util.Abort, inst:
  3077     except util.Abort, inst: