Show More
@@ -32,9 +32,18 b' class changectx(object):' | |||||
32 | self._node = self._repo.lookup(changeid) |
|
32 | self._node = self._repo.lookup(changeid) | |
33 | self._rev = self._repo.changelog.rev(self._node) |
|
33 | self._rev = self._repo.changelog.rev(self._node) | |
34 |
|
34 | |||
|
35 | def __str__(self): | |||
|
36 | return short(self.node()) | |||
|
37 | ||||
35 | def __repr__(self): |
|
38 | def __repr__(self): | |
36 | return "<changectx %s>" % short(self.node()) |
|
39 | return "<changectx %s>" % short(self.node()) | |
37 |
|
40 | |||
|
41 | def __eq__(self, other): | |||
|
42 | return self._rev == other._rev | |||
|
43 | ||||
|
44 | def __nonzero__(self): | |||
|
45 | return self._rev != -1 | |||
|
46 | ||||
38 | def changeset(self): |
|
47 | def changeset(self): | |
39 | try: |
|
48 | try: | |
40 | return self._changeset |
|
49 | return self._changeset | |
@@ -127,9 +136,18 b' class filectx(object):' | |||||
127 | else: |
|
136 | else: | |
128 | raise AttributeError, name |
|
137 | raise AttributeError, name | |
129 |
|
138 | |||
|
139 | def __nonzero__(self): | |||
|
140 | return self._filerev != nullid | |||
|
141 | ||||
|
142 | def __str__(self): | |||
|
143 | return "%s@%s" % (self.path(), short(self.node())) | |||
|
144 | ||||
130 | def __repr__(self): |
|
145 | def __repr__(self): | |
131 | return "<filectx %s@%s>" % (self.path(), short(self.node())) |
|
146 | return "<filectx %s@%s>" % (self.path(), short(self.node())) | |
132 |
|
147 | |||
|
148 | def __eq__(self, other): | |||
|
149 | return self._path == other._path and self._changeid == other._changeid | |||
|
150 | ||||
133 | def filerev(self): return self._filerev |
|
151 | def filerev(self): return self._filerev | |
134 | def filenode(self): return self._filenode |
|
152 | def filenode(self): return self._filenode | |
135 | def filelog(self): return self._filelog |
|
153 | def filelog(self): return self._filelog |
@@ -321,6 +321,19 b' class localrepository(repo.repository):' | |||||
321 | def changectx(self, changeid=None): |
|
321 | def changectx(self, changeid=None): | |
322 | return context.changectx(self, changeid) |
|
322 | return context.changectx(self, changeid) | |
323 |
|
323 | |||
|
324 | def parents(self, changeid=None): | |||
|
325 | ''' | |||
|
326 | get list of changectxs for parents of changeid or working directory | |||
|
327 | ''' | |||
|
328 | if changeid is None: | |||
|
329 | pl = self.dirstate.parents() | |||
|
330 | else: | |||
|
331 | n = self.changelog.lookup(changeid) | |||
|
332 | pl = self.changelog.parents(n) | |||
|
333 | if pl[1] == nullid: | |||
|
334 | return [self.changectx(pl[0])] | |||
|
335 | return [self.changectx(pl[0]), self.changectx(pl[1])] | |||
|
336 | ||||
324 | def filectx(self, path, changeid=None, fileid=None): |
|
337 | def filectx(self, path, changeid=None, fileid=None): | |
325 | """changeid can be a changeset revision, node, or tag. |
|
338 | """changeid can be a changeset revision, node, or tag. | |
326 | fileid can be a file revision or node.""" |
|
339 | fileid can be a file revision or node.""" |
@@ -320,12 +320,12 b' def update(repo, node, branchmerge=False' | |||||
320 |
|
320 | |||
321 | ### check phase |
|
321 | ### check phase | |
322 |
|
322 | |||
323 |
pl = repo. |
|
323 | pl = repo.parents() | |
324 |
if not overwrite and pl |
|
324 | if not overwrite and len(pl) > 1: | |
325 | raise util.Abort(_("outstanding uncommitted merges")) |
|
325 | raise util.Abort(_("outstanding uncommitted merges")) | |
326 |
|
326 | |||
327 | p1, p2 = pl[0], node |
|
327 | p1, p2 = pl[0], repo.changectx(node) | |
328 |
pa = |
|
328 | pa = p1.ancestor(p2) | |
329 |
|
329 | |||
330 | # are we going backwards? |
|
330 | # are we going backwards? | |
331 | backwards = (pa == p2) |
|
331 | backwards = (pa == p2) | |
@@ -345,17 +345,16 b' def update(repo, node, branchmerge=False' | |||||
345 | if modified or added or removed: |
|
345 | if modified or added or removed: | |
346 | raise util.Abort(_("outstanding uncommitted changes")) |
|
346 | raise util.Abort(_("outstanding uncommitted changes")) | |
347 |
|
347 | |||
348 |
m1 = |
|
348 | m1 = p1.manifest().copy() | |
349 |
m2 = |
|
349 | m2 = p2.manifest().copy() | |
350 |
ma = |
|
350 | ma = pa.manifest() | |
351 |
|
351 | |||
352 | # resolve the manifest to determine which files |
|
352 | # resolve the manifest to determine which files | |
353 | # we care about merging |
|
353 | # we care about merging | |
354 | repo.ui.note(_("resolving manifests\n")) |
|
354 | repo.ui.note(_("resolving manifests\n")) | |
355 | repo.ui.debug(_(" overwrite %s branchmerge %s partial %s\n") % |
|
355 | repo.ui.debug(_(" overwrite %s branchmerge %s partial %s\n") % | |
356 | (overwrite, branchmerge, bool(partial))) |
|
356 | (overwrite, branchmerge, bool(partial))) | |
357 | repo.ui.debug(_(" ancestor %s local %s remote %s\n") % |
|
357 | repo.ui.debug(_(" ancestor %s local %s remote %s\n") % (p1, p2, pa)) | |
358 | (short(p1), short(p2), short(pa))) |
|
|||
359 |
|
358 | |||
360 | action = [] |
|
359 | action = [] | |
361 | copy = {} |
|
360 | copy = {} | |
@@ -369,7 +368,7 b' def update(repo, node, branchmerge=False' | |||||
369 | if not branchmerge: |
|
368 | if not branchmerge: | |
370 | action += forgetremoved(m2, status) |
|
369 | action += forgetremoved(m2, status) | |
371 | if not (backwards or overwrite): |
|
370 | if not (backwards or overwrite): | |
372 |
copy = findcopies(repo, m1, m2, |
|
371 | copy = findcopies(repo, m1, m2, pa.rev()) | |
373 |
|
372 | |||
374 | action += manifestmerge(repo.ui, m1, m2, ma, overwrite, backwards) |
|
373 | action += manifestmerge(repo.ui, m1, m2, ma, overwrite, backwards) | |
375 | del m1, m2, ma |
|
374 | del m1, m2, ma | |
@@ -378,10 +377,10 b' def update(repo, node, branchmerge=False' | |||||
378 |
|
377 | |||
379 | if not branchmerge: |
|
378 | if not branchmerge: | |
380 | # we don't need to do any magic, just jump to the new rev |
|
379 | # we don't need to do any magic, just jump to the new rev | |
381 | p1, p2 = p2, nullid |
|
380 | p1, p2 = p2, repo.changectx(nullid) | |
382 |
|
381 | |||
383 |
xp1, xp2 = |
|
382 | xp1, xp2 = str(p1), str(p2) | |
384 |
if p2 |
|
383 | if not p2: xp2 = '' | |
385 |
|
384 | |||
386 | repo.hook('preupdate', throw=True, parent1=xp1, parent2=xp2) |
|
385 | repo.hook('preupdate', throw=True, parent1=xp1, parent2=xp2) | |
387 |
|
386 | |||
@@ -389,7 +388,7 b' def update(repo, node, branchmerge=False' | |||||
389 |
|
388 | |||
390 | # update dirstate |
|
389 | # update dirstate | |
391 | if not partial: |
|
390 | if not partial: | |
392 | repo.dirstate.setparents(p1, p2) |
|
391 | repo.dirstate.setparents(p1.node(), p2.node()) | |
393 | recordupdates(repo, action, branchmerge) |
|
392 | recordupdates(repo, action, branchmerge) | |
394 |
|
393 | |||
395 | if show_stats: |
|
394 | if show_stats: | |
@@ -406,8 +405,7 b' def update(repo, node, branchmerge=False' | |||||
406 | " you can redo the full merge using:\n" |
|
405 | " you can redo the full merge using:\n" | |
407 | " hg update -C %s\n" |
|
406 | " hg update -C %s\n" | |
408 | " hg merge %s\n" |
|
407 | " hg merge %s\n" | |
409 |
% ( |
|
408 | % (p1.rev(), p2.rev()))) | |
410 | repo.changelog.rev(p2)))) |
|
|||
411 | elif remind: |
|
409 | elif remind: | |
412 | repo.ui.status(_("(branch merge, don't forget to commit)\n")) |
|
410 | repo.ui.status(_("(branch merge, don't forget to commit)\n")) | |
413 | elif unresolved: |
|
411 | elif unresolved: |
@@ -62,10 +62,10 b' precommit hook: p1=8ea2ef7ad3e8cac946c72' | |||||
62 | precommit.forbid hook |
|
62 | precommit.forbid hook | |
63 | abort: precommit.forbid hook exited with status 1 |
|
63 | abort: precommit.forbid hook exited with status 1 | |
64 | 4:8ea2ef7ad3e8 |
|
64 | 4:8ea2ef7ad3e8 | |
65 |
preupdate hook: p1=b702efe96888 |
|
65 | preupdate hook: p1=b702efe96888 p2= | |
66 | 0 files updated, 0 files merged, 2 files removed, 0 files unresolved |
|
66 | 0 files updated, 0 files merged, 2 files removed, 0 files unresolved | |
67 |
preupdate hook: p1=8ea2ef7ad3e8 |
|
67 | preupdate hook: p1=8ea2ef7ad3e8 p2= | |
68 |
update hook: p1=8ea2ef7ad3e8 |
|
68 | update hook: p1=8ea2ef7ad3e8 p2= err=0 | |
69 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
69 | 2 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
70 | 3:4c52fb2e4022 |
|
70 | 3:4c52fb2e4022 | |
71 | prechangegroup.forbid hook |
|
71 | prechangegroup.forbid hook |
General Comments 0
You need to be logged in to leave comments.
Login now