##// END OF EJS Templates
merge with upstream
Thomas Arendsen Hein -
r3324:34f08b88 merge default
parent child Browse files
Show More
@@ -201,30 +201,55 b' def clone(ui, source, dest=None, pull=Fa'
201 201 dest_lock.release()
202 202
203 203 if update:
204 _merge.update(dest_repo, dest_repo.changelog.tip())
204 _update(dest_repo, dest_repo.changelog.tip())
205 205 if dir_cleanup:
206 206 dir_cleanup.close()
207 207
208 208 return src_repo, dest_repo
209 209
210 def _showstats(repo, stats):
211 stats = ((stats[0], _("updated")),
212 (stats[1], _("merged")),
213 (stats[2], _("removed")),
214 (stats[3], _("unresolved")))
215 note = ", ".join([_("%d files %s") % s for s in stats])
216 repo.ui.status("%s\n" % note)
217
218 def _update(repo, node): return update(repo, node)
219
210 220 def update(repo, node):
211 221 """update the working directory to node, merging linear changes"""
212 return _merge.update(repo, node)
222 stats = _merge.update(repo, node, False, False, None, None)
223 _showstats(repo, stats)
224 if stats[3]:
225 repo.ui.status(_("There are unresolved merges with"
226 " locally modified files.\n"))
227 return stats[3]
213 228
214 229 def clean(repo, node, wlock=None, show_stats=True):
215 230 """forcibly switch the working directory to node, clobbering changes"""
216 return _merge.update(repo, node, force=True, wlock=wlock,
217 show_stats=show_stats)
231 stats = _merge.update(repo, node, False, True, None, wlock)
232 if show_stats: _showstats(repo, stats)
233 return stats[3]
218 234
219 235 def merge(repo, node, force=None, remind=True, wlock=None):
220 236 """branch merge with node, resolving changes"""
221 return _merge.update(repo, node, branchmerge=True, force=force,
222 remind=remind, wlock=wlock)
237 stats = _merge.update(repo, node, True, force, False, wlock)
238 _showstats(repo, stats)
239 if stats[3]:
240 pl = repo.parents()
241 repo.ui.status(_("There are unresolved merges,"
242 " you can redo the full merge using:\n"
243 " hg update -C %s\n"
244 " hg merge %s\n"
245 % (pl[0].rev(), pl[1].rev())))
246 elif remind:
247 repo.ui.status(_("(branch merge, don't forget to commit)\n"))
248 return stats[3]
223 249
224 250 def revert(repo, node, choose, wlock):
225 251 """revert changes to revision in node without updating dirstate"""
226 return _merge.update(repo, node, force=True, partial=choose,
227 show_stats=False, wlock=wlock)
252 return _merge.update(repo, node, False, True, choose, wlock)[3]
228 253
229 254 def verify(repo):
230 255 """verify the consistency of a repository"""
@@ -13,13 +13,9 b' demandload(globals(), "errno util os tem'
13 13 def filemerge(repo, fw, fo, wctx, mctx):
14 14 """perform a 3-way merge in the working directory
15 15
16 fw = filename in the working directory and first parent
16 fw = filename in the working directory
17 17 fo = filename in other parent
18 18 wctx, mctx = working and merge changecontexts
19
20 TODO:
21 if fw is copied in the working directory, we get confused
22 implement move and fd
23 19 """
24 20
25 21 def temp(prefix, ctx):
@@ -64,9 +60,7 b' def filemerge(repo, fw, fo, wctx, mctx):'
64 60 return r
65 61
66 62 def checkunknown(wctx, mctx):
67 """
68 check for collisions between unknown files and files in m2
69 """
63 "check for collisions between unknown files and files in mctx"
70 64 man = mctx.manifest()
71 65 for f in wctx.unknown():
72 66 if f in man:
@@ -94,9 +88,7 b' def forgetremoved(wctx, mctx):'
94 88 return action
95 89
96 90 def nonoverlap(d1, d2):
97 """
98 Return list of elements in d1 not in d2
99 """
91 "Return list of elements in d1 not in d2"
100 92
101 93 l = []
102 94 for d in d1:
@@ -107,9 +99,7 b' def nonoverlap(d1, d2):'
107 99 return l
108 100
109 101 def findold(fctx, limit):
110 """
111 find files that path was copied from, back to linkrev limit
112 """
102 "find files that path was copied from, back to linkrev limit"
113 103
114 104 old = {}
115 105 orig = fctx.path()
@@ -174,7 +164,10 b' def findcopies(repo, m1, m2, limit):'
174 164
175 165 def manifestmerge(repo, p1, p2, pa, overwrite, partial):
176 166 """
177 Merge manifest m1 with m2 using ancestor ma and generate merge action list
167 Merge p1 and p2 with ancestor ma and generate merge action list
168
169 overwrite = whether we clobber working files
170 partial = function to filter file lists
178 171 """
179 172
180 173 repo.ui.note(_("resolving manifests\n"))
@@ -275,6 +268,8 b' def manifestmerge(repo, p1, p2, pa, over'
275 268 return action
276 269
277 270 def applyupdates(repo, action, wctx, mctx):
271 "apply the merge action list to the working directory"
272
278 273 updated, merged, removed, unresolved = 0, 0, 0, 0
279 274 action.sort()
280 275 for a in action:
@@ -296,15 +291,14 b' def applyupdates(repo, action, wctx, mct'
296 291 if filemerge(repo, f, f2, wctx, mctx):
297 292 unresolved += 1
298 293 else:
294 merged += 1
299 295 if f != fd:
300 296 repo.ui.debug(_("copying %s to %s\n") % (f, fd))
301 297 repo.wwrite(fd, repo.wread(f))
302 298 if move:
303 299 repo.ui.debug(_("removing %s\n") % f)
304 300 os.unlink(repo.wjoin(f))
305
306 301 util.set_exec(repo.wjoin(fd), flag)
307 merged += 1
308 302 elif m == "g": # get
309 303 flag = a[2]
310 304 repo.ui.note(_("getting %s\n") % f)
@@ -319,6 +313,8 b' def applyupdates(repo, action, wctx, mct'
319 313 return updated, merged, removed, unresolved
320 314
321 315 def recordupdates(repo, action, branchmerge, mctx):
316 "record merge actions to the dirstate"
317
322 318 for a in action:
323 319 f, m = a[:2]
324 320 if m == "r": # remove
@@ -355,8 +351,15 b' def recordupdates(repo, action, branchme'
355 351 else:
356 352 repo.dirstate.copy(f2, fd)
357 353
358 def update(repo, node, branchmerge=False, force=False, partial=None,
359 wlock=None, show_stats=True, remind=True):
354 def update(repo, node, branchmerge, force, partial, wlock):
355 """
356 Perform a merge between the working directory and the given node
357
358 branchmerge = whether to merge between branches
359 force = whether to force branch merging or file overwriting
360 partial = a function to filter file lists (dirstate not updated)
361 wlock = working dir lock, if already held
362 """
360 363
361 364 if not wlock:
362 365 wlock = repo.wlock()
@@ -397,32 +400,12 b' def update(repo, node, branchmerge=False'
397 400 if not partial:
398 401 repo.hook('preupdate', throw=True, parent1=xp1, parent2=xp2)
399 402
400 updated, merged, removed, unresolved = applyupdates(repo, action, wc, p2)
403 stats = applyupdates(repo, action, wc, p2)
401 404
402 if show_stats:
403 stats = ((updated, _("updated")),
404 (merged - unresolved, _("merged")),
405 (removed, _("removed")),
406 (unresolved, _("unresolved")))
407 note = ", ".join([_("%d files %s") % s for s in stats])
408 repo.ui.status("%s\n" % note)
409 405 if not partial:
410 406 recordupdates(repo, action, branchmerge, p2)
411 407 repo.dirstate.setparents(fp1, fp2)
412 repo.hook('update', parent1=xp1, parent2=xp2, error=unresolved)
408 repo.hook('update', parent1=xp1, parent2=xp2, error=stats[3])
413 409
414 if branchmerge:
415 if unresolved:
416 repo.ui.status(_("There are unresolved merges,"
417 " you can redo the full merge using:\n"
418 " hg update -C %s\n"
419 " hg merge %s\n"
420 % (p1.rev(), p2.rev())))
421 elif remind:
422 repo.ui.status(_("(branch merge, don't forget to commit)\n"))
423 elif unresolved:
424 repo.ui.status(_("There are unresolved merges with"
425 " locally modified files.\n"))
410 return stats
426 411
427 return unresolved
428
General Comments 0
You need to be logged in to leave comments. Login now