##// END OF EJS Templates
subrepo: introduce basic state parsing
Matt Mackall -
r8812:859f8419 default
parent child Browse files
Show More
@@ -0,0 +1,35 b''
1 # subrepo.py - sub-repository handling for Mercurial
2 #
3 # Copyright 2006, 2007 Matt Mackall <mpm@selenic.com>
4 #
5 # This software may be used and distributed according to the terms of the
6 # GNU General Public License version 2, incorporated herein by reference.
7
8 import config, util, errno
9
10 def state(ctx):
11 p = config.config()
12 def read(f, sections=None, remap=None):
13 if f in ctx:
14 try:
15 p.parse(f, ctx[f].data(), sections, remap)
16 except IOError, err:
17 if err.errno != errno.ENOENT:
18 raise
19 read('.hgsub')
20
21 rev = {}
22 if '.hgsubstate' in ctx:
23 try:
24 for l in ctx['.hgsubstate'].data().splitlines():
25 revision, path = l.split()
26 rev[path] = revision
27 except IOError, err:
28 if err.errno != errno.ENOENT:
29 raise
30
31 state = {}
32 for path, src in p[''].items():
33 state[path] = (src, rev.get(path, ''))
34
35 return state
@@ -857,6 +857,14 b' def debugstate(ui, repo, nodates=None):'
857 for f in repo.dirstate.copies():
857 for f in repo.dirstate.copies():
858 ui.write(_("copy: %s -> %s\n") % (repo.dirstate.copied(f), f))
858 ui.write(_("copy: %s -> %s\n") % (repo.dirstate.copied(f), f))
859
859
860 def debugsub(ui, repo, rev=None):
861 if rev == '':
862 rev = None
863 for k,v in sorted(repo[rev].substate.items()):
864 ui.write('path %s\n' % k)
865 ui.write(' source %s\n' % v[0])
866 ui.write(' revision %s\n' % v[1])
867
860 def debugdata(ui, file_, rev):
868 def debugdata(ui, file_, rev):
861 """dump the contents of a data file revision"""
869 """dump the contents of a data file revision"""
862 r = revlog.revlog(util.opener(os.getcwd(), audit=False), file_[:-2] + ".i")
870 r = revlog.revlog(util.opener(os.getcwd(), audit=False), file_[:-2] + ".i")
@@ -3228,6 +3236,10 b' table = {'
3228 (debugstate,
3236 (debugstate,
3229 [('', 'nodates', None, _('do not display the saved mtime'))],
3237 [('', 'nodates', None, _('do not display the saved mtime'))],
3230 _('[OPTION]...')),
3238 _('[OPTION]...')),
3239 "debugsub":
3240 (debugsub,
3241 [('r', 'rev', '', _('revision to check'))],
3242 _('[-r REV] [REV]')),
3231 "debugwalk": (debugwalk, walkopts, _('[OPTION]... [FILE]...')),
3243 "debugwalk": (debugwalk, walkopts, _('[OPTION]... [FILE]...')),
3232 "^diff":
3244 "^diff":
3233 (diff,
3245 (diff,
@@ -7,7 +7,7 b''
7
7
8 from node import nullid, nullrev, short, hex
8 from node import nullid, nullrev, short, hex
9 from i18n import _
9 from i18n import _
10 import ancestor, bdiff, error, util
10 import ancestor, bdiff, error, util, subrepo
11 import os, errno
11 import os, errno
12
12
13 propertycache = util.propertycache
13 propertycache = util.propertycache
@@ -73,6 +73,10 b' class changectx(object):'
73 p = p[:-1]
73 p = p[:-1]
74 return [changectx(self._repo, x) for x in p]
74 return [changectx(self._repo, x) for x in p]
75
75
76 @propertycache
77 def substate(self):
78 return subrepo.state(self)
79
76 def __contains__(self, key):
80 def __contains__(self, key):
77 return key in self._manifest
81 return key in self._manifest
78
82
@@ -73,6 +73,7 b' debugrebuildstate'
73 debugrename
73 debugrename
74 debugsetparents
74 debugsetparents
75 debugstate
75 debugstate
76 debugsub
76 debugwalk
77 debugwalk
77
78
78 % Do not show the alias of a debug command if there are other candidates
79 % Do not show the alias of a debug command if there are other candidates
@@ -199,6 +200,7 b' debugrebuildstate: rev'
199 debugrename: rev
200 debugrename: rev
200 debugsetparents:
201 debugsetparents:
201 debugstate: nodates
202 debugstate: nodates
203 debugsub: rev
202 debugwalk: include, exclude
204 debugwalk: include, exclude
203 grep: print0, all, follow, ignore-case, files-with-matches, line-number, rev, user, date, include, exclude
205 grep: print0, all, follow, ignore-case, files-with-matches, line-number, rev, user, date, include, exclude
204 heads: rev, active, closed, style, template
206 heads: rev, active, closed, style, template
General Comments 0
You need to be logged in to leave comments. Login now