2363 "(.hg not found)")) |
2363 "(.hg not found)")) |
2364 |
2364 |
2365 hexfunc = ui.debugflag and hex or short |
2365 hexfunc = ui.debugflag and hex or short |
2366 default = not (num or id or branch or tags or bookmarks) |
2366 default = not (num or id or branch or tags or bookmarks) |
2367 output = [] |
2367 output = [] |
2368 |
|
2369 revs = [] |
2368 revs = [] |
2370 bms = [] |
2369 |
2371 if source: |
2370 if source: |
2372 source, branches = hg.parseurl(ui.expandpath(source)) |
2371 source, branches = hg.parseurl(ui.expandpath(source)) |
2373 repo = hg.repository(ui, source) |
2372 repo = hg.repository(ui, source) |
2374 revs, checkout = hg.addbranchrevs(repo, repo, branches, None) |
2373 revs, checkout = hg.addbranchrevs(repo, repo, branches, None) |
2375 |
2374 |
2376 if not repo.local(): |
2375 if not repo.local(): |
|
2376 if num or branch or tags: |
|
2377 raise util.Abort( |
|
2378 _("can't query remote revision number, branch, or tags")) |
2377 if not rev and revs: |
2379 if not rev and revs: |
2378 rev = revs[0] |
2380 rev = revs[0] |
2379 if not rev: |
2381 if not rev: |
2380 rev = "tip" |
2382 rev = "tip" |
2381 if num or branch or tags: |
|
2382 raise util.Abort( |
|
2383 _("can't query remote revision number, branch, or tags")) |
|
2384 |
2383 |
2385 remoterev = repo.lookup(rev) |
2384 remoterev = repo.lookup(rev) |
2386 if default or id: |
2385 if default or id: |
2387 output = [hexfunc(remoterev)] |
2386 output = [hexfunc(remoterev)] |
2388 |
2387 |
2389 if 'bookmarks' in repo.listkeys('namespaces'): |
2388 def getbms(): |
2390 hexremoterev = hex(remoterev) |
2389 bms = [] |
2391 bms = [bm for bm, bmrev in repo.listkeys('bookmarks').iteritems() |
2390 |
2392 if bmrev == hexremoterev] |
2391 if 'bookmarks' in repo.listkeys('namespaces'): |
2393 |
2392 hexremoterev = hex(remoterev) |
2394 elif not rev: |
2393 bms = [bm for bm, bmr in repo.listkeys('bookmarks').iteritems() |
2395 ctx = repo[None] |
2394 if bmr == hexremoterev] |
2396 parents = ctx.parents() |
2395 |
2397 changed = False |
2396 return bms |
2398 if default or id or num: |
2397 |
2399 changed = util.any(repo.status()) |
2398 if bookmarks: |
2400 if default or id: |
2399 output.extend(getbms()) |
2401 output = ["%s%s" % ('+'.join([hexfunc(p.node()) for p in parents]), |
2400 elif default and not ui.quiet: |
2402 (changed) and "+" or "")] |
2401 # multiple bookmarks for a single parent separated by '/' |
2403 if num: |
2402 bm = '/'.join(getbms()) |
2404 output.append("%s%s" % ('+'.join([str(p.rev()) for p in parents]), |
2403 if bm: |
2405 (changed) and "+" or "")) |
2404 output.append(bm) |
2406 else: |
2405 else: |
2407 ctx = cmdutil.revsingle(repo, rev) |
2406 if not rev: |
2408 if default or id: |
2407 ctx = repo[None] |
2409 output = [hexfunc(ctx.node())] |
2408 parents = ctx.parents() |
2410 if num: |
2409 changed = "" |
2411 output.append(str(ctx.rev())) |
2410 if default or id or num: |
2412 |
2411 changed = util.any(repo.status()) and "+" or "" |
2413 if repo.local(): |
2412 if default or id: |
2414 bms = ctx.bookmarks() |
2413 output = ["%s%s" % |
2415 |
2414 ('+'.join([hexfunc(p.node()) for p in parents]), changed)] |
2416 if repo.local() and default and not ui.quiet: |
2415 if num: |
2417 b = ctx.branch() |
2416 output.append("%s%s" % |
2418 if b != 'default': |
2417 ('+'.join([str(p.rev()) for p in parents]), changed)) |
2419 output.append("(%s)" % b) |
2418 else: |
2420 |
2419 ctx = cmdutil.revsingle(repo, rev) |
2421 # multiple tags for a single parent separated by '/' |
2420 if default or id: |
2422 t = "/".join(ctx.tags()) |
2421 output = [hexfunc(ctx.node())] |
2423 if t: |
2422 if num: |
2424 output.append(t) |
2423 output.append(str(ctx.rev())) |
2425 |
2424 |
2426 if default and not ui.quiet: |
2425 if default and not ui.quiet: |
2427 # multiple bookmarks for a single parent separated by '/' |
2426 b = ctx.branch() |
2428 bm = '/'.join(bms) |
2427 if b != 'default': |
2429 if bm: |
2428 output.append("(%s)" % b) |
2430 output.append(bm) |
2429 |
2431 |
2430 # multiple tags for a single parent separated by '/' |
2432 if branch: |
2431 t = '/'.join(ctx.tags()) |
2433 output.append(ctx.branch()) |
2432 if t: |
2434 |
2433 output.append(t) |
2435 if tags: |
2434 |
2436 output.extend(ctx.tags()) |
2435 # multiple bookmarks for a single parent separated by '/' |
2437 |
2436 bm = '/'.join(ctx.bookmarks()) |
2438 if bookmarks: |
2437 if bm: |
2439 output.extend(bms) |
2438 output.append(bm) |
|
2439 else: |
|
2440 if branch: |
|
2441 output.append(ctx.branch()) |
|
2442 |
|
2443 if tags: |
|
2444 output.extend(ctx.tags()) |
|
2445 |
|
2446 if bookmarks: |
|
2447 output.extend(ctx.bookmarks()) |
2440 |
2448 |
2441 ui.write("%s\n" % ' '.join(output)) |
2449 ui.write("%s\n" % ' '.join(output)) |
2442 |
2450 |
2443 def import_(ui, repo, patch1, *patches, **opts): |
2451 def import_(ui, repo, patch1, *patches, **opts): |
2444 """import an ordered set of patches |
2452 """import an ordered set of patches |