comparison mercurial/subrepo.py @ 19811:5e10d41e7b9c

merge: let the user choose to merge, keep local or keep remote subrepo revisions When a subrepo has changed on the local and remote revisions, prompt the user whether it wants to merge those subrepo revisions, keep the local revision or keep the remote revision. Up until now mercurial would always perform a merge on a subrepo that had changed on the local and the remote revisions. This is often inconvenient. For example: - You may want to perform the actual subrepo merge after you have merged the parent subrepo files. - Some subrepos may be considered "read only", in the sense that you are not supposed to add new revisions to them. In those cases "merging a subrepo" means choosing which _existing_ revision you want to use on the merged revision. This is often the case for subrepos that contain binary dependencies (such as DLLs, etc). This new prompt makes mercurial better cope with those common scenarios. Notes: - The default behavior (which is the one that is used when ui is not interactive) remains unchanged (i.e. merge is the default action). - This prompt will be shown even if the ui --tool flag is set. - I don't know of a way to test the "keep local" and "keep remote" options (i.e. to force the test to choose those options). # HG changeset patch # User Angel Ezquerra <angel.ezquerra@gmail.com> # Date 1378420708 -7200 # Fri Sep 06 00:38:28 2013 +0200 # Node ID 2fb9cb0c7b26303ac3178b7739975e663075857d # Parent 50d721553198cea51c30f53b76d41dc919280097 merge: let the user choose to merge, keep local or keep remote subrepo revisions When a subrepo has changed on the local and remote revisions, prompt the user whether it wants to merge those subrepo revisions, keep the local revision or keep the remote revision. Up until now mercurial would always perform a merge on a subrepo that had changed on the local and the remote revisions. This is often inconvenient. For example: - You may want to perform the actual subrepo merge after you have merged the parent subrepo files. - Some subrepos may be considered "read only", in the sense that you are not supposed to add new revisions to them. In those cases "merging a subrepo" means choosing which _existing_ revision you want to use on the merged revision. This is often the case for subrepos that contain binary dependencies (such as DLLs, etc). This new prompt makes mercurial better cope with those common scenarios. Notes: - The default behavior (which is the one that is used when ui is not interactive) remains unchanged (i.e. merge is the default action). - This prompt will be shown even if the ui --tool flag is set. - I don't know of a way to test the "keep local" and "keep remote" options (i.e. to force the test to choose those options).
author Angel Ezquerra <angel.ezquerra@gmail.com>
date Fri, 06 Sep 2013 00:38:28 +0200
parents c26690fe5f08
children f962870712da 224e96078708
comparison
equal deleted inserted replaced
19810:c80feeb715d1 19811:5e10d41e7b9c
200 elif ld[1] == a[1]: # local side is unchanged 200 elif ld[1] == a[1]: # local side is unchanged
201 debug(s, "other side changed, get", r) 201 debug(s, "other side changed, get", r)
202 wctx.sub(s).get(r, overwrite) 202 wctx.sub(s).get(r, overwrite)
203 sm[s] = r 203 sm[s] = r
204 else: 204 else:
205 debug(s, "both sides changed, merge with", r) 205 debug(s, "both sides changed")
206 wctx.sub(s).merge(r) 206 option = repo.ui.promptchoice(
207 sm[s] = l 207 _(' subrepository %s diverged (local revision: %s, '
208 'remote revision: %s)\n'
209 '(M)erge, keep (l)ocal or keep (r)emote?'
210 '$$ &Merge $$ &Local $$ &Remote')
211 % (s, l[1][:12], r[1][:12]), 0)
212 if option == 0:
213 wctx.sub(s).merge(r)
214 sm[s] = l
215 debug(s, "merge with", r)
216 elif option == 1:
217 sm[s] = l
218 debug(s, "keep local subrepo revision", l)
219 else:
220 wctx.sub(s).get(r, overwrite)
221 sm[s] = r
222 debug(s, "get remote subrepo revision", r)
208 elif ld == a: # remote removed, local unchanged 223 elif ld == a: # remote removed, local unchanged
209 debug(s, "remote removed, remove") 224 debug(s, "remote removed, remove")
210 wctx.sub(s).remove() 225 wctx.sub(s).remove()
211 elif a == nullstate: # not present in remote or ancestor 226 elif a == nullstate: # not present in remote or ancestor
212 debug(s, "local added, keep") 227 debug(s, "local added, keep")