changeset 4667:c7a81e3ae80f

identify: work with remote repos
author Matt Mackall <mpm@selenic.com>
date Thu, 21 Jun 2007 11:54:16 -0500
parents 48c94bffdb28
children e241598e956f 6858a7477a5e
files mercurial/cmdutil.py mercurial/commands.py
diffstat 2 files changed, 11 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -316,7 +316,7 @@ def dispatch(ui, args):
         try:
             repo = hg.repository(ui, path=path)
             ui = repo.ui
-            if not repo.local():
+            if not repo.local() and cmd not in commands.remoterepo.split():
                 raise util.Abort(_("repository '%s' is not local") % path)
         except hg.RepoError:
             if cmd not in commands.optionalrepo.split():
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -1447,7 +1447,14 @@ def identify(ui, repo, rev=None, num=Non
     default = not (num or id or branch or tags)
     output = []
 
-    if not rev:
+    if not repo.local():
+        if not rev:
+            rev = "tip"
+        if num or branch or tags:
+            raise util.Abort(
+                "can't query remote revision number, branch, or tags")
+        output = [hexfunc(repo.lookup(rev))]
+    elif not rev:
         ctx = repo.workingctx()
         parents = ctx.parents()
         changed = False
@@ -1466,7 +1473,7 @@ def identify(ui, repo, rev=None, num=Non
         if num:
             output.append(str(ctx.rev()))
 
-    if default and not ui.quiet:
+    if repo.local() and default and not ui.quiet:
         b = util.tolocal(ctx.branch())
         if b != 'default':
             output.append("(%s)" % b)
@@ -3056,6 +3063,7 @@ table = {
 norepo = ("clone init version help debugancestor debugcomplete debugdata"
           " debugindex debugindexdot debugdate debuginstall")
 optionalrepo = ("paths serve showconfig")
+remoterepo = ("identify")
 
 def dispatch(args):
     try: