identify: work with remote repos
authorMatt Mackall <mpm@selenic.com>
Thu, 21 Jun 2007 11:54:16 -0500
changeset 4667 c7a81e3ae80f
parent 4666 48c94bffdb28
child 4668 e241598e956f
child 4675 6858a7477a5e
identify: work with remote repos
mercurial/cmdutil.py
mercurial/commands.py
--- a/mercurial/cmdutil.py	Thu Jun 21 11:54:13 2007 -0500
+++ b/mercurial/cmdutil.py	Thu Jun 21 11:54:16 2007 -0500
@@ -316,7 +316,7 @@
         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	Thu Jun 21 11:54:13 2007 -0500
+++ b/mercurial/commands.py	Thu Jun 21 11:54:16 2007 -0500
@@ -1447,7 +1447,14 @@
     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 @@
         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 @@
 norepo = ("clone init version help debugancestor debugcomplete debugdata"
           " debugindex debugindexdot debugdate debuginstall")
 optionalrepo = ("paths serve showconfig")
+remoterepo = ("identify")
 
 def dispatch(args):
     try: