comparison mercurial/subrepo.py @ 13323:d8d478f9ee0f

merge with stable
author Martin Geisler <mg@aragost.com>
date Mon, 31 Jan 2011 13:38:00 +0100
parents 9c3bfba3f48d c19b9282d3a7
children e5617047c926
comparison
equal deleted inserted replaced
13315:0d1dca7d2a04 13323:d8d478f9ee0f
80 """rewrite .hgsubstate in (outer) repo with these subrepo states""" 80 """rewrite .hgsubstate in (outer) repo with these subrepo states"""
81 repo.wwrite('.hgsubstate', 81 repo.wwrite('.hgsubstate',
82 ''.join(['%s %s\n' % (state[s][1], s) 82 ''.join(['%s %s\n' % (state[s][1], s)
83 for s in sorted(state)]), '') 83 for s in sorted(state)]), '')
84 84
85 def submerge(repo, wctx, mctx, actx): 85 def submerge(repo, wctx, mctx, actx, overwrite):
86 """delegated from merge.applyupdates: merging of .hgsubstate file 86 """delegated from merge.applyupdates: merging of .hgsubstate file
87 in working context, merging context and ancestor context""" 87 in working context, merging context and ancestor context"""
88 if mctx == actx: # backwards? 88 if mctx == actx: # backwards?
89 actx = wctx.p1() 89 actx = wctx.p1()
90 s1 = wctx.substate 90 s1 = wctx.substate
112 if ld == r or r == a: # no change or local is newer 112 if ld == r or r == a: # no change or local is newer
113 sm[s] = l 113 sm[s] = l
114 continue 114 continue
115 elif ld == a: # other side changed 115 elif ld == a: # other side changed
116 debug(s, "other changed, get", r) 116 debug(s, "other changed, get", r)
117 wctx.sub(s).get(r) 117 wctx.sub(s).get(r, overwrite)
118 sm[s] = r 118 sm[s] = r
119 elif ld[0] != r[0]: # sources differ 119 elif ld[0] != r[0]: # sources differ
120 if repo.ui.promptchoice( 120 if repo.ui.promptchoice(
121 _(' subrepository sources for %s differ\n' 121 _(' subrepository sources for %s differ\n'
122 'use (l)ocal source (%s) or (r)emote source (%s)?') 122 'use (l)ocal source (%s) or (r)emote source (%s)?')
123 % (s, l[0], r[0]), 123 % (s, l[0], r[0]),
124 (_('&Local'), _('&Remote')), 0): 124 (_('&Local'), _('&Remote')), 0):
125 debug(s, "prompt changed, get", r) 125 debug(s, "prompt changed, get", r)
126 wctx.sub(s).get(r) 126 wctx.sub(s).get(r, overwrite)
127 sm[s] = r 127 sm[s] = r
128 elif ld[1] == a[1]: # local side is unchanged 128 elif ld[1] == a[1]: # local side is unchanged
129 debug(s, "other side changed, get", r) 129 debug(s, "other side changed, get", r)
130 wctx.sub(s).get(r) 130 wctx.sub(s).get(r, overwrite)
131 sm[s] = r 131 sm[s] = r
132 else: 132 else:
133 debug(s, "both sides changed, merge with", r) 133 debug(s, "both sides changed, merge with", r)
134 wctx.sub(s).merge(r) 134 wctx.sub(s).merge(r)
135 sm[s] = l 135 sm[s] = l
261 261
262 (should verify the dirstate is not dirty first) 262 (should verify the dirstate is not dirty first)
263 """ 263 """
264 raise NotImplementedError 264 raise NotImplementedError
265 265
266 def get(self, state): 266 def get(self, state, overwrite=False):
267 """run whatever commands are needed to put the subrepo into 267 """run whatever commands are needed to put the subrepo into
268 this state 268 this state
269 """ 269 """
270 raise NotImplementedError 270 raise NotImplementedError
271 271
272 def merge(self, state): 272 def merge(self, state, overwrite=False):
273 """merge currently-saved state with the new state.""" 273 """merge currently-saved state with the new state."""
274 raise NotImplementedError 274 raise NotImplementedError
275 275
276 def push(self, force): 276 def push(self, force):
277 """perform whatever action is analogous to 'hg push' 277 """perform whatever action is analogous to 'hg push'
429 self._repo.ui.status(_('pulling subrepo %s from %s\n') 429 self._repo.ui.status(_('pulling subrepo %s from %s\n')
430 % (subrelpath(self), srcurl)) 430 % (subrelpath(self), srcurl))
431 other = hg.repository(self._repo.ui, srcurl) 431 other = hg.repository(self._repo.ui, srcurl)
432 self._repo.pull(other) 432 self._repo.pull(other)
433 433
434 def get(self, state): 434 def get(self, state, overwrite=False):
435 self._get(state) 435 self._get(state)
436 source, revision, kind = state 436 source, revision, kind = state
437 self._repo.ui.debug("getting subrepo %s\n" % self._path) 437 self._repo.ui.debug("getting subrepo %s\n" % self._path)
438 hg.clean(self._repo, revision, False) 438 hg.clean(self._repo, revision, False)
439 439
597 try: 597 try:
598 os.removedirs(os.path.dirname(path)) 598 os.removedirs(os.path.dirname(path))
599 except OSError: 599 except OSError:
600 pass 600 pass
601 601
602 def get(self, state): 602 def get(self, state, overwrite=False):
603 if overwrite:
604 self._svncommand(['revert', '--recursive', self._path])
603 status = self._svncommand(['checkout', state[0], '--revision', state[1]]) 605 status = self._svncommand(['checkout', state[0], '--revision', state[1]])
604 if not re.search('Checked out revision [0-9]+.', status): 606 if not re.search('Checked out revision [0-9]+.', status):
605 raise util.Abort(status.splitlines()[-1]) 607 raise util.Abort(status.splitlines()[-1])
606 self._ui.status(status) 608 self._ui.status(status)
607 609
747 return True 749 return True
748 # check for staged changes or modified files; ignore untracked files 750 # check for staged changes or modified files; ignore untracked files
749 out, code = self._gitdir(['diff-index', '--quiet', 'HEAD']) 751 out, code = self._gitdir(['diff-index', '--quiet', 'HEAD'])
750 return code == 1 752 return code == 1
751 753
752 def get(self, state): 754 def get(self, state, overwrite=False):
753 source, revision, kind = state 755 source, revision, kind = state
754 self._fetch(source, revision) 756 self._fetch(source, revision)
755 # if the repo was set to be bare, unbare it 757 # if the repo was set to be bare, unbare it
756 if self._gitcommand(['config', '--bool', 'core.bare']) == 'true': 758 if self._gitcommand(['config', '--bool', 'core.bare']) == 'true':
757 self._gitcommand(['config', 'core.bare', 'false']) 759 self._gitcommand(['config', 'core.bare', 'false'])