diff util.py @ 196:77812f98e250

Add a naive hg svn version command that works as long as hgsubversion is run from a checkout.
author Augie Fackler <durin42@gmail.com>
date Tue, 10 Feb 2009 14:52:26 -0600
parents 906d3f302b45
children df4611050286
line wrap: on
line diff
--- a/util.py
+++ b/util.py
@@ -1,16 +1,30 @@
 import os
 import shutil
 
+from mercurial import hg
 from mercurial import node
 
 svn_subcommands = { }
-
 def register_subcommand(name):
     def inner(fn):
         svn_subcommands[name] = fn
         return fn
     return inner
 
+svn_commands_nourl = set()
+def command_needs_no_url(fn):
+    svn_commands_nourl.add(fn)
+    return fn
+
+
+def version(ui):
+    """Guess the version of hgsubversion.
+    """
+    # TODO make this say something other than "unknown" for installed hgsubversion
+    repo = hg.repository(ui, os.path.dirname(__file__))
+    ver = repo.dirstate.parents()[0]
+    return node.hex(ver)[:12]
+
 
 def generate_help():
     ret = ['hg svn ...', '',