##// END OF EJS Templates
transplant: restore dirstate correctly at unexpected failure...
FUJIWARA Katsunori -
r25879:99e88320 stable
parent child Browse files
Show More
@@ -125,9 +125,10 b' class transplanter(object):'
125 125 diffopts = patch.difffeatureopts(self.ui, opts)
126 126 diffopts.git = True
127 127
128 lock = wlock = tr = None
128 lock = wlock = tr = dsguard = None
129 129 try:
130 130 wlock = repo.wlock()
131 dsguard = cmdutil.dirstateguard(repo, 'transplant')
131 132 lock = repo.lock()
132 133 tr = repo.transaction('transplant')
133 134 for rev in revs:
@@ -200,6 +201,7 b' class transplanter(object):'
200 201 # Do not rollback, it is up to the user to
201 202 # fix the merge or cancel everything
202 203 tr.close()
204 dsguard.close()
203 205 raise
204 206 if n and domerge:
205 207 self.ui.status(_('%s merged at %s\n') % (revstr,
@@ -212,6 +214,7 b' class transplanter(object):'
212 214 if patchfile:
213 215 os.unlink(patchfile)
214 216 tr.close()
217 dsguard.close()
215 218 if pulls:
216 219 exchange.pull(repo, source.peer(), heads=pulls)
217 220 merge.update(repo, pulls[-1], False, False, None)
@@ -220,7 +223,10 b' class transplanter(object):'
220 223 self.transplants.write()
221 224 if tr:
222 225 tr.release()
226 if lock:
223 227 lock.release()
228 if dsguard:
229 dsguard.release()
224 230 wlock.release()
225 231
226 232 def filter(self, filter, node, changelog, patchfile):
@@ -867,6 +867,7 b" timestamp of them isn't changed on the f"
867 867 > [hooks]
868 868 > fakedirstatewritetime = !
869 869 > fakepatchtime = !
870 > [extensions]
870 871 > abort = !
871 872 > EOF
872 873
@@ -877,4 +878,41 b" timestamp of them isn't changed on the f"
877 878 $ hg status -A r1
878 879 M r1
879 880
881 Test that rollback by unexpected failure after transplanting the first
882 revision restores dirstate correctly.
883
884 $ hg rollback -q
885 $ rm -f abort
886 $ hg update -q -C d11e3596cc1a
887 $ hg parents -T "{node|short}\n"
888 d11e3596cc1a
889 $ hg status -A
890 C r1
891 C r2
892
893 $ cat >> .hg/hgrc <<EOF
894 > [hooks]
895 > # emulate failure at transplanting the 2nd revision
896 > pretxncommit.abort = test ! -f abort
897 > EOF
898 $ hg transplant "22c515968f13::"
899 applying 22c515968f13
900 22c515968f13 transplanted to * (glob)
901 applying e38700ba9dd3
902 transaction abort!
903 rollback completed
904 abort: pretxncommit.abort hook exited with status 1
905 [255]
906 $ cat >> .hg/hgrc <<EOF
907 > [hooks]
908 > pretxncommit.abort = !
909 > EOF
910
911 $ hg parents -T "{node|short}\n"
912 d11e3596cc1a
913 $ hg status -A
914 M r1
915 ? abort
916 C r2
917
880 918 $ cd ..
General Comments 0
You need to be logged in to leave comments. Login now