diff mercurial-common/src/python/load-substates-command.py @ 706:c27e501ed0c3

use own command for hg subrepos
author eugene.petrenko@jetbrains.com
date Wed, 08 Jan 2014 18:32:42 +0100
parents
children 7d9e79de81e6
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mercurial-common/src/python/load-substates-command.py	Wed Jan 08 18:32:42 2014 +0100
@@ -0,0 +1,42 @@
+#!/usr/bin/env python
+'''
+load-substates-command
+
+Copyright 2014 JetBrains <eugene.petrenko@jetbrains.com>
+Mercurial extension commands for JetBrains' Mercurial integration
+'''
+
+import base64
+from mercurial import util, node, scmutil, subrepo
+from mercurial.i18n import _
+from os import path, makedirs
+
+
+def load_substates_command(ui, repo, outputFile, **opts):
+    """Tons of docs"""
+
+    ui.write("Searching for mappings...\n")
+
+    with open(outputFile, "w", 5 * 1024 * 1024) as result:
+      result.write("format: prefix commitID base64(.hgsub) base64(.hgsubstate) \n")
+      result.flush()
+
+      for r in repo.changelog:
+          ctx = repo[r]
+
+          if '.hgsubstate' in ctx and '.hgsub' in ctx:
+               commitId = node.hex(ctx.node())
+               result.write("$$@@@@ " + commitId + " " + base64.b64encode(ctx['.hgsub'].data()) + " " + base64.b64encode(ctx['.hgsubstate'].data()) + "\n")
+
+
+    ui.write("\n##Completed##\n")
+
+
+#so here goes command registration and options
+cmdtable = {
+    "load-substates-command": (load_substates_command, [ ], " [options] OUTPUT_FILE")
+}
+
+testedwith = '2.2.2'
+buglink = "@jonnyzzz"
+