changeset 4671:150afe6becf6

identify: take a path to a remote repo Rather than using -R, we take a path as an argument. This lets us use url#branch syntaxes that may be in hgrc.
author Matt Mackall <mpm@selenic.com>
date Thu, 21 Jun 2007 13:09:01 -0500
parents 850950e59b52
children d8442fc0da8d
files mercurial/cmdutil.py mercurial/commands.py
diffstat 2 files changed, 14 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/cmdutil.py	Thu Jun 21 13:09:00 2007 -0500
+++ b/mercurial/cmdutil.py	Thu Jun 21 13:09:01 2007 -0500
@@ -321,7 +321,7 @@
         try:
             repo = hg.repository(ui, path=path)
             ui = repo.ui
-            if not repo.local() and cmd not in commands.remoterepo.split():
+            if not repo.local():
                 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 13:09:00 2007 -0500
+++ b/mercurial/commands.py	Thu Jun 21 13:09:01 2007 -0500
@@ -1432,10 +1432,13 @@
             else:
                 ui.write("%s\n" % first)
 
-def identify(ui, repo, rev=None, num=None, id=None, branch=None, tags=None):
+def identify(ui, repo, source=None,
+             rev=None, num=None, id=None, branch=None, tags=None):
     """identify the working copy or specified revision
 
-    With no argument, print a summary of the current state of the repo.
+    With no revision, print a summary of the current state of the repo.
+
+    With a path, do a lookup in another repository.
 
     This summary identifies the repository state using one or two parent
     hash identifiers, followed by a "+" if there are uncommitted changes
@@ -1447,13 +1450,17 @@
     default = not (num or id or branch or tags)
     output = []
 
-    if not repo.local():
+    if source:
+        source, revs = cmdutil.parseurl(ui.expandpath(source), [])
+        srepo = hg.repository(ui, source)
+        if not rev and revs:
+            rev = revs[0]
         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))]
+        output = [hexfunc(srepo.lookup(rev))]
     elif not rev:
         ctx = repo.workingctx()
         parents = ctx.parents()
@@ -1473,7 +1480,7 @@
         if num:
             output.append(str(ctx.rev()))
 
-    if repo.local() and default and not ui.quiet:
+    if not source and default and not ui.quiet:
         b = util.tolocal(ctx.branch())
         if b != 'default':
             output.append("(%s)" % b)
@@ -2856,7 +2863,7 @@
           ('i', 'id', None, _('show global revision id')),
           ('b', 'branch', None, _('show branch')),
           ('t', 'tags', None, _('show tags'))],
-         _('hg identify [-nibt] [-r REV]')),
+         _('hg identify [-nibt] [-r REV] [SOURCE]')),
     "import|patch":
         (import_,
          [('p', 'strip', 1,
@@ -3063,7 +3070,6 @@
 norepo = ("clone init version help debugancestor debugcomplete debugdata"
           " debugindex debugindexdot debugdate debuginstall")
 optionalrepo = ("paths serve showconfig")
-remoterepo = ("identify")
 
 def dispatch(args):
     try: