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): |
1435 def identify(ui, repo, rev=None): |
1436 """print information about the working copy |
1436 """identify the working copy or specified revision |
1437 |
1437 |
1438 Print a short 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 |
1441 hash identifiers, followed by a "+" if there are uncommitted changes |
1441 hash identifiers, followed by a "+" if there are uncommitted changes |
1442 in the working directory, followed by a list of tags for this revision. |
1442 in the working directory, a list of tags for this revision and a branch |
|
1443 name for non-default branches. |
1443 """ |
1444 """ |
1444 |
1445 |
1445 hexfunc = ui.debugflag and hex or short |
1446 hexfunc = ui.debugflag and hex or short |
1446 |
1447 |
1447 wctx = repo.workingctx() |
1448 if not rev: |
1448 parents = wctx.parents() |
1449 ctx = repo.workingctx() |
1449 changed = wctx.files() + wctx.deleted() |
1450 parents = ctx.parents() |
1450 |
1451 changed = ctx.files() + ctx.deleted() |
1451 output = ["%s%s" % ('+'.join([hexfunc(p.node()) for p in parents]), |
1452 output = ["%s%s" % ('+'.join([hexfunc(p.node()) for p in parents]), |
1452 (changed) and "+" or "")] |
1453 (changed) and "+" or "")] |
|
1454 else: |
|
1455 ctx = repo.changectx(rev) |
|
1456 output = [hexfunc(ctx.node())] |
1453 |
1457 |
1454 if not ui.quiet: |
1458 if not ui.quiet: |
1455 branch = util.tolocal(wctx.branch()) |
1459 branch = util.tolocal(ctx.branch()) |
1456 if branch != 'default': |
1460 if branch != 'default': |
1457 output.append("(%s)" % branch) |
1461 output.append("(%s)" % branch) |
1458 |
1462 |
1459 # multiple tags for a single parent separated by '/' |
1463 # multiple tags for a single parent separated by '/' |
1460 tags = "/".join(wctx.tags()) |
1464 tags = "/".join(ctx.tags()) |
1461 if tags: |
1465 if tags: |
1462 output.append(tags) |
1466 output.append(tags) |
1463 |
1467 |
1464 ui.write("%s\n" % ' '.join(output)) |
1468 ui.write("%s\n" % ' '.join(output)) |
1465 |
1469 |
2819 [('', 'style', '', _('display using template map file')), |
2823 [('', 'style', '', _('display using template map file')), |
2820 ('r', 'rev', '', _('show only heads which are descendants of rev')), |
2824 ('r', 'rev', '', _('show only heads which are descendants of rev')), |
2821 ('', 'template', '', _('display with template'))], |
2825 ('', 'template', '', _('display with template'))], |
2822 _('hg heads [-r REV] [REV]...')), |
2826 _('hg heads [-r REV] [REV]...')), |
2823 "help": (help_, [], _('hg help [COMMAND]')), |
2827 "help": (help_, [], _('hg help [COMMAND]')), |
2824 "identify|id": (identify, [], _('hg identify')), |
2828 "identify|id": |
|
2829 (identify, |
|
2830 [('r', 'rev', '', _('identify the specified rev'))], |
|
2831 _('hg identify [-r REV]')), |
2825 "import|patch": |
2832 "import|patch": |
2826 (import_, |
2833 (import_, |
2827 [('p', 'strip', 1, |
2834 [('p', 'strip', 1, |
2828 _('directory strip option for patch. This has the same\n' |
2835 _('directory strip option for patch. This has the same\n' |
2829 'meaning as the corresponding patch option')), |
2836 'meaning as the corresponding patch option')), |