comparison mercurial/subrepo.py @ 9779:58a6f3f4d553

subrepo: add some debug output to submerge
author Matt Mackall <mpm@selenic.com>
date Sat, 07 Nov 2009 16:29:49 -0600
parents a22cdd5e56b7
children 1ee085511b89
comparison
equal deleted inserted replaced
9778:6cb1808e5ae7 9779:58a6f3f4d553
50 s1 = wctx.substate 50 s1 = wctx.substate
51 s2 = mctx.substate 51 s2 = mctx.substate
52 sa = actx.substate 52 sa = actx.substate
53 sm = {} 53 sm = {}
54 54
55 def debug(s, msg, r=""):
56 if r:
57 r = "%s:%s" % r
58 repo.ui.debug(_(" subrepo %s: %s %s\n") % (s, msg, r))
59
55 for s, l in s1.items(): 60 for s, l in s1.items():
56 a = sa.get(s, nullstate) 61 a = sa.get(s, nullstate)
57 if s in s2: 62 if s in s2:
58 r = s2[s] 63 r = s2[s]
59 if l == r or r == a: # no change or local is newer 64 if l == r or r == a: # no change or local is newer
60 sm[s] = l 65 sm[s] = l
61 continue 66 continue
62 elif l == a: # other side changed 67 elif l == a: # other side changed
68 debug(s, _("other changed, get"), r)
63 wctx.sub(s).get(r) 69 wctx.sub(s).get(r)
64 sm[s] = r 70 sm[s] = r
65 elif l[0] != r[0]: # sources differ 71 elif l[0] != r[0]: # sources differ
66 if repo.ui.promptchoice( 72 if repo.ui.promptchoice(
67 _(' subrepository sources for %s differ\n' 73 _(' subrepository sources for %s differ\n'
68 'use (l)ocal source (%s) or (r)emote source (%s)?') 74 'use (l)ocal source (%s) or (r)emote source (%s)?')
69 % (s, l[0], r[0]), 75 % (s, l[0], r[0]),
70 (_('&Local'), _('&Remote')), 0): 76 (_('&Local'), _('&Remote')), 0):
77 debug(s, _("prompt changed, get"), r)
71 wctx.sub(s).get(r) 78 wctx.sub(s).get(r)
72 sm[s] = r 79 sm[s] = r
73 elif l[1] == a[1]: # local side is unchanged 80 elif l[1] == a[1]: # local side is unchanged
81 debug(s, _("other side changed, get"), r)
74 wctx.sub(s).get(r) 82 wctx.sub(s).get(r)
75 sm[s] = r 83 sm[s] = r
76 else: 84 else:
85 debug(s, _("both sides changed, merge with"), r)
77 wctx.sub(s).merge(r) 86 wctx.sub(s).merge(r)
78 sm[s] = l 87 sm[s] = l
79 elif l == a: # remote removed, local unchanged 88 elif l == a: # remote removed, local unchanged
89 debug(s, _("remote removed, remove"))
80 wctx.sub(s).remove() 90 wctx.sub(s).remove()
81 else: 91 else:
82 if repo.ui.promptchoice( 92 if repo.ui.promptchoice(
83 _(' local changed subrepository %s which remote removed\n' 93 _(' local changed subrepository %s which remote removed\n'
84 'use (c)hanged version or (d)elete?') % s, 94 'use (c)hanged version or (d)elete?') % s,
85 (_('&Changed'), _('&Delete')), 0): 95 (_('&Changed'), _('&Delete')), 0):
96 debug(s, _("prompt remove"))
86 wctx.sub(s).remove() 97 wctx.sub(s).remove()
87 98
88 for s, r in s2.items(): 99 for s, r in s2.items():
89 if s in s1: 100 if s in s1:
90 continue 101 continue
91 elif s not in sa: 102 elif s not in sa:
103 debug(s, _("remote added, get"), r)
92 wctx.sub(s).get(r) 104 wctx.sub(s).get(r)
93 sm[s] = r 105 sm[s] = r
94 elif r != sa[s]: 106 elif r != sa[s]:
95 if repo.ui.promptchoice( 107 if repo.ui.promptchoice(
96 _(' remote changed subrepository %s which local removed\n' 108 _(' remote changed subrepository %s which local removed\n'
97 'use (c)hanged version or (d)elete?') % s, 109 'use (c)hanged version or (d)elete?') % s,
98 (_('&Changed'), _('&Delete')), 0) == 0: 110 (_('&Changed'), _('&Delete')), 0) == 0:
111 debug(s, _("prompt recreate"), r)
99 wctx.sub(s).get(r) 112 wctx.sub(s).get(r)
100 sm[s] = r 113 sm[s] = r
101 114
102 # record merged .hgsubstate 115 # record merged .hgsubstate
103 writestate(repo, sm) 116 writestate(repo, sm)
196 209
197 self._repo.ui.status(_('pushing subrepo %s\n') % self._path) 210 self._repo.ui.status(_('pushing subrepo %s\n') % self._path)
198 dsturl = _abssource(self._repo, True) 211 dsturl = _abssource(self._repo, True)
199 other = hg.repository(self._repo.ui, dsturl) 212 other = hg.repository(self._repo.ui, dsturl)
200 self._repo.push(other, force) 213 self._repo.push(other, force)
201