##// END OF EJS Templates
merge: use new working context object in update
Matt Mackall -
r3218:8d4855fd default
parent child Browse files
Show More
@@ -342,7 +342,7 b' class workingctx(changectx):'
342 342 def _buildmanifest(self):
343 343 """generate a manifest corresponding to the working directory"""
344 344
345 man = self._parents[0].manifest().coy()
345 man = self._parents[0].manifest().copy()
346 346 copied = self._repo.dirstate.copies()
347 347 modified, added, removed, deleted, unknown = self._status[:5]
348 348 for i,l in (("a", added), ("m", modified), ("u", unknown)):
@@ -321,6 +321,9 b' class localrepository(repo.repository):'
321 321 def changectx(self, changeid=None):
322 322 return context.changectx(self, changeid)
323 323
324 def workingctx(self):
325 return context.workingctx(self)
326
324 327 def parents(self, changeid=None):
325 328 '''
326 329 get list of changectxs for parents of changeid or working directory
@@ -59,35 +59,17 b' def filemerge(repo, fw, fo, fd, my, othe'
59 59 os.unlink(c)
60 60 return r
61 61
62 def checkunknown(repo, m2, status):
62 def checkunknown(repo, m2, wctx):
63 63 """
64 64 check for collisions between unknown files and files in m2
65 65 """
66 modified, added, removed, deleted, unknown = status[:5]
67 for f in unknown:
66 for f in wctx.unknown():
68 67 if f in m2:
69 68 if repo.file(f).cmp(m2[f], repo.wread(f)):
70 69 raise util.Abort(_("'%s' already exists in the working"
71 70 " dir and differs from remote") % f)
72 71
73 def workingmanifest(repo, man, status):
74 """
75 Update manifest to correspond to the working directory
76 """
77
78 copied = repo.dirstate.copies()
79 modified, added, removed, deleted, unknown = status[:5]
80 for i,l in (("a", added), ("m", modified), ("u", unknown)):
81 for f in l:
82 man[f] = man.get(copied.get(f, f), nullid) + i
83 man.set(f, util.is_exec(repo.wjoin(f), man.execf(f)))
84
85 for f in deleted + removed:
86 del man[f]
87
88 return man
89
90 def forgetremoved(m2, status):
72 def forgetremoved(m2, wctx):
91 73 """
92 74 Forget removed files
93 75
@@ -98,10 +80,9 b' def forgetremoved(m2, status):'
98 80 manifest.
99 81 """
100 82
101 modified, added, removed, deleted, unknown = status[:5]
102 83 action = []
103 84
104 for f in deleted + removed:
85 for f in wctx.deleted() + wctx.removed():
105 86 if f not in m2:
106 87 action.append((f, "f"))
107 88
@@ -332,7 +313,8 b' def update(repo, node, branchmerge=False'
332 313
333 314 ### check phase
334 315
335 pl = repo.parents()
316 wc = repo.workingctx()
317 pl = wc.parents()
336 318 if not overwrite and len(pl) > 1:
337 319 raise util.Abort(_("outstanding uncommitted merges"))
338 320
@@ -351,13 +333,11 b' def update(repo, node, branchmerge=False'
351 333 raise util.Abort(_("update spans branches, use 'hg merge' "
352 334 "or 'hg update -C' to lose changes"))
353 335
354 status = repo.status()
355 modified, added, removed, deleted, unknown = status[:5]
356 336 if branchmerge and not forcemerge:
357 if modified or added or removed:
337 if wc.modified() or wc.added() or wc.removed():
358 338 raise util.Abort(_("outstanding uncommitted changes"))
359 339
360 m1 = p1.manifest().copy()
340 m1 = wc.manifest().copy()
361 341 m2 = p2.manifest().copy()
362 342 ma = pa.manifest()
363 343
@@ -371,14 +351,13 b' def update(repo, node, branchmerge=False'
371 351 action = []
372 352 copy = {}
373 353
374 m1 = workingmanifest(repo, m1, status)
375 354 filtermanifest(m1, partial)
376 355 filtermanifest(m2, partial)
377 356
378 357 if not force:
379 checkunknown(repo, m2, status)
358 checkunknown(repo, m2, wc)
380 359 if not branchmerge:
381 action += forgetremoved(m2, status)
360 action += forgetremoved(m2, wc)
382 361 if not (backwards or overwrite):
383 362 copy = findcopies(repo, m1, m2, pa.rev())
384 363
General Comments 0
You need to be logged in to leave comments. Login now