annotate 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
rev   line source
706
c27e501ed0c3 use own command for hg subrepos
eugene.petrenko@jetbrains.com
parents:
diff changeset
1 #!/usr/bin/env python
c27e501ed0c3 use own command for hg subrepos
eugene.petrenko@jetbrains.com
parents:
diff changeset
2 '''
c27e501ed0c3 use own command for hg subrepos
eugene.petrenko@jetbrains.com
parents:
diff changeset
3 load-substates-command
c27e501ed0c3 use own command for hg subrepos
eugene.petrenko@jetbrains.com
parents:
diff changeset
4
c27e501ed0c3 use own command for hg subrepos
eugene.petrenko@jetbrains.com
parents:
diff changeset
5 Copyright 2014 JetBrains <eugene.petrenko@jetbrains.com>
c27e501ed0c3 use own command for hg subrepos
eugene.petrenko@jetbrains.com
parents:
diff changeset
6 Mercurial extension commands for JetBrains' Mercurial integration
c27e501ed0c3 use own command for hg subrepos
eugene.petrenko@jetbrains.com
parents:
diff changeset
7 '''
c27e501ed0c3 use own command for hg subrepos
eugene.petrenko@jetbrains.com
parents:
diff changeset
8
c27e501ed0c3 use own command for hg subrepos
eugene.petrenko@jetbrains.com
parents:
diff changeset
9 import base64
c27e501ed0c3 use own command for hg subrepos
eugene.petrenko@jetbrains.com
parents:
diff changeset
10 from mercurial import util, node, scmutil, subrepo
c27e501ed0c3 use own command for hg subrepos
eugene.petrenko@jetbrains.com
parents:
diff changeset
11 from mercurial.i18n import _
c27e501ed0c3 use own command for hg subrepos
eugene.petrenko@jetbrains.com
parents:
diff changeset
12 from os import path, makedirs
c27e501ed0c3 use own command for hg subrepos
eugene.petrenko@jetbrains.com
parents:
diff changeset
13
c27e501ed0c3 use own command for hg subrepos
eugene.petrenko@jetbrains.com
parents:
diff changeset
14
c27e501ed0c3 use own command for hg subrepos
eugene.petrenko@jetbrains.com
parents:
diff changeset
15 def load_substates_command(ui, repo, outputFile, **opts):
c27e501ed0c3 use own command for hg subrepos
eugene.petrenko@jetbrains.com
parents:
diff changeset
16 """Tons of docs"""
c27e501ed0c3 use own command for hg subrepos
eugene.petrenko@jetbrains.com
parents:
diff changeset
17
c27e501ed0c3 use own command for hg subrepos
eugene.petrenko@jetbrains.com
parents:
diff changeset
18 ui.write("Searching for mappings...\n")
c27e501ed0c3 use own command for hg subrepos
eugene.petrenko@jetbrains.com
parents:
diff changeset
19
c27e501ed0c3 use own command for hg subrepos
eugene.petrenko@jetbrains.com
parents:
diff changeset
20 with open(outputFile, "w", 5 * 1024 * 1024) as result:
c27e501ed0c3 use own command for hg subrepos
eugene.petrenko@jetbrains.com
parents:
diff changeset
21 result.write("format: prefix commitID base64(.hgsub) base64(.hgsubstate) \n")
c27e501ed0c3 use own command for hg subrepos
eugene.petrenko@jetbrains.com
parents:
diff changeset
22 result.flush()
c27e501ed0c3 use own command for hg subrepos
eugene.petrenko@jetbrains.com
parents:
diff changeset
23
c27e501ed0c3 use own command for hg subrepos
eugene.petrenko@jetbrains.com
parents:
diff changeset
24 for r in repo.changelog:
c27e501ed0c3 use own command for hg subrepos
eugene.petrenko@jetbrains.com
parents:
diff changeset
25 ctx = repo[r]
c27e501ed0c3 use own command for hg subrepos
eugene.petrenko@jetbrains.com
parents:
diff changeset
26
c27e501ed0c3 use own command for hg subrepos
eugene.petrenko@jetbrains.com
parents:
diff changeset
27 if '.hgsubstate' in ctx and '.hgsub' in ctx:
c27e501ed0c3 use own command for hg subrepos
eugene.petrenko@jetbrains.com
parents:
diff changeset
28 commitId = node.hex(ctx.node())
c27e501ed0c3 use own command for hg subrepos
eugene.petrenko@jetbrains.com
parents:
diff changeset
29 result.write("$$@@@@ " + commitId + " " + base64.b64encode(ctx['.hgsub'].data()) + " " + base64.b64encode(ctx['.hgsubstate'].data()) + "\n")
c27e501ed0c3 use own command for hg subrepos
eugene.petrenko@jetbrains.com
parents:
diff changeset
30
c27e501ed0c3 use own command for hg subrepos
eugene.petrenko@jetbrains.com
parents:
diff changeset
31
c27e501ed0c3 use own command for hg subrepos
eugene.petrenko@jetbrains.com
parents:
diff changeset
32 ui.write("\n##Completed##\n")
c27e501ed0c3 use own command for hg subrepos
eugene.petrenko@jetbrains.com
parents:
diff changeset
33
c27e501ed0c3 use own command for hg subrepos
eugene.petrenko@jetbrains.com
parents:
diff changeset
34
c27e501ed0c3 use own command for hg subrepos
eugene.petrenko@jetbrains.com
parents:
diff changeset
35 #so here goes command registration and options
c27e501ed0c3 use own command for hg subrepos
eugene.petrenko@jetbrains.com
parents:
diff changeset
36 cmdtable = {
c27e501ed0c3 use own command for hg subrepos
eugene.petrenko@jetbrains.com
parents:
diff changeset
37 "load-substates-command": (load_substates_command, [ ], " [options] OUTPUT_FILE")
c27e501ed0c3 use own command for hg subrepos
eugene.petrenko@jetbrains.com
parents:
diff changeset
38 }
c27e501ed0c3 use own command for hg subrepos
eugene.petrenko@jetbrains.com
parents:
diff changeset
39
c27e501ed0c3 use own command for hg subrepos
eugene.petrenko@jetbrains.com
parents:
diff changeset
40 testedwith = '2.2.2'
c27e501ed0c3 use own command for hg subrepos
eugene.petrenko@jetbrains.com
parents:
diff changeset
41 buglink = "@jonnyzzz"
c27e501ed0c3 use own command for hg subrepos
eugene.petrenko@jetbrains.com
parents:
diff changeset
42