2290 hexfunc = ui.debugflag and hex or short |
2290 hexfunc = ui.debugflag and hex or short |
2291 default = not (num or id or branch or tags or bookmarks) |
2291 default = not (num or id or branch or tags or bookmarks) |
2292 output = [] |
2292 output = [] |
2293 |
2293 |
2294 revs = [] |
2294 revs = [] |
|
2295 bms = [] |
2295 if source: |
2296 if source: |
2296 source, branches = hg.parseurl(ui.expandpath(source)) |
2297 source, branches = hg.parseurl(ui.expandpath(source)) |
2297 repo = hg.repository(ui, source) |
2298 repo = hg.repository(ui, source) |
2298 revs, checkout = hg.addbranchrevs(repo, repo, branches, None) |
2299 revs, checkout = hg.addbranchrevs(repo, repo, branches, None) |
2299 |
2300 |
2300 if not repo.local(): |
2301 if not repo.local(): |
2301 if not rev and revs: |
2302 if not rev and revs: |
2302 rev = revs[0] |
2303 rev = revs[0] |
2303 if not rev: |
2304 if not rev: |
2304 rev = "tip" |
2305 rev = "tip" |
2305 if num or branch or tags or bookmarks: |
2306 if num or branch or tags: |
2306 raise util.Abort(_("can't query remote revision number," |
2307 raise util.Abort( |
2307 " branch, tags, or bookmarks")) |
2308 _("can't query remote revision number, branch, or tags")) |
2308 output = [hexfunc(repo.lookup(rev))] |
2309 |
|
2310 remoterev = repo.lookup(rev) |
|
2311 if default or id: |
|
2312 output = [hexfunc(remoterev)] |
|
2313 |
|
2314 if 'bookmarks' in repo.listkeys('namespaces'): |
|
2315 hexremoterev = hex(remoterev) |
|
2316 bms = [bm for bm, bmrev in repo.listkeys('bookmarks').iteritems() |
|
2317 if bmrev == hexremoterev] |
|
2318 |
2309 elif not rev: |
2319 elif not rev: |
2310 ctx = repo[None] |
2320 ctx = repo[None] |
2311 parents = ctx.parents() |
2321 parents = ctx.parents() |
2312 changed = False |
2322 changed = False |
2313 if default or id or num: |
2323 if default or id or num: |
2323 if default or id: |
2333 if default or id: |
2324 output = [hexfunc(ctx.node())] |
2334 output = [hexfunc(ctx.node())] |
2325 if num: |
2335 if num: |
2326 output.append(str(ctx.rev())) |
2336 output.append(str(ctx.rev())) |
2327 |
2337 |
|
2338 if repo.local(): |
|
2339 bms = ctx.bookmarks() |
|
2340 |
2328 if repo.local() and default and not ui.quiet: |
2341 if repo.local() and default and not ui.quiet: |
2329 b = ctx.branch() |
2342 b = ctx.branch() |
2330 if b != 'default': |
2343 if b != 'default': |
2331 output.append("(%s)" % b) |
2344 output.append("(%s)" % b) |
2332 |
2345 |
2333 # multiple tags for a single parent separated by '/' |
2346 # multiple tags for a single parent separated by '/' |
2334 t = "/".join(ctx.tags()) |
2347 t = "/".join(ctx.tags()) |
2335 if t: |
2348 if t: |
2336 output.append(t) |
2349 output.append(t) |
2337 |
2350 |
|
2351 if default and not ui.quiet: |
2338 # multiple bookmarks for a single parent separated by '/' |
2352 # multiple bookmarks for a single parent separated by '/' |
2339 bm = '/'.join(ctx.bookmarks()) |
2353 bm = '/'.join(bms) |
2340 if bm: |
2354 if bm: |
2341 output.append(bm) |
2355 output.append(bm) |
2342 |
2356 |
2343 if branch: |
2357 if branch: |
2344 output.append(ctx.branch()) |
2358 output.append(ctx.branch()) |
2345 |
2359 |
2346 if tags: |
2360 if tags: |
2347 output.extend(ctx.tags()) |
2361 output.extend(ctx.tags()) |
2348 |
2362 |
2349 if bookmarks: |
2363 if bookmarks: |
2350 output.extend(ctx.bookmarks()) |
2364 output.extend(bms) |
2351 |
2365 |
2352 ui.write("%s\n" % ' '.join(output)) |
2366 ui.write("%s\n" % ' '.join(output)) |
2353 |
2367 |
2354 def import_(ui, repo, patch1, *patches, **opts): |
2368 def import_(ui, repo, patch1, *patches, **opts): |
2355 """import an ordered set of patches |
2369 """import an ordered set of patches |