comparison mercurial/subrepo.py @ 13155:f02d7a562a21

subrepo: avoids empty commit when .hgsubstate is dirty (issue2403) This patch avoids empty commit when .hgsubstate is dirty. Empty commit was caused by .hgsubstate being updated back to the state of the working copy parent when committing, if a user had changed it manually and not made any changes in subrepositories. The subrepository state from the working copies parent is compared with the state calculated as a result of trying to commit the subrepositories. If the two states are the same, then return None otherwise the commit is just done. The line: "committing subrepository x" will be written if there is nothing committed, but .hgsubstate is dirty for x subrepository.
author Erik Zielke <ez@aragost.com>
date Mon, 29 Nov 2010 09:37:23 +0100
parents dca5488f0e4f
children 07d08c130892
comparison
equal deleted inserted replaced
13154:e11c14f14491 13155:f02d7a562a21
10 from i18n import _ 10 from i18n import _
11 import config, util, node, error, cmdutil 11 import config, util, node, error, cmdutil
12 hg = None 12 hg = None
13 13
14 nullstate = ('', '', 'empty') 14 nullstate = ('', '', 'empty')
15
16
17 def substate(ctx):
18 rev = {}
19 if '.hgsubstate' in ctx:
20 try:
21 for l in ctx['.hgsubstate'].data().splitlines():
22 revision, path = l.split(" ", 1)
23 rev[path] = revision
24 except IOError as err:
25 if err.errno != errno.ENOENT:
26 raise
27 return rev
15 28
16 def state(ctx, ui): 29 def state(ctx, ui):
17 """return a state dict, mapping subrepo paths configured in .hgsub 30 """return a state dict, mapping subrepo paths configured in .hgsub
18 to tuple: (source from .hgsub, revision from .hgsubstate, kind 31 to tuple: (source from .hgsub, revision from .hgsubstate, kind
19 (key in types dict)) 32 (key in types dict))
37 read('.hgsub') 50 read('.hgsub')
38 51
39 for path, src in ui.configitems('subpaths'): 52 for path, src in ui.configitems('subpaths'):
40 p.set('subpaths', path, src, ui.configsource('subpaths', path)) 53 p.set('subpaths', path, src, ui.configsource('subpaths', path))
41 54
42 rev = {} 55 rev = substate(ctx)
43 if '.hgsubstate' in ctx:
44 try:
45 for l in ctx['.hgsubstate'].data().splitlines():
46 revision, path = l.split(" ", 1)
47 rev[path] = revision
48 except IOError, err:
49 if err.errno != errno.ENOENT:
50 raise
51 56
52 state = {} 57 state = {}
53 for path, src in p[''].items(): 58 for path, src in p[''].items():
54 kind = 'hg' 59 kind = 'hg'
55 if src.startswith('['): 60 if src.startswith('['):