158 import pickle |
158 import pickle |
159 import errno |
159 import errno |
160 import os |
160 import os |
161 import sys |
161 import sys |
162 |
162 |
|
163 from mercurial import bundle2 |
163 from mercurial import cmdutil |
164 from mercurial import cmdutil |
164 from mercurial import discovery |
165 from mercurial import discovery |
165 from mercurial import error |
166 from mercurial import error |
166 from mercurial import copies |
167 from mercurial import copies |
167 from mercurial import context |
168 from mercurial import context |
820 # Recover our old commits if necessary |
821 # Recover our old commits if necessary |
821 if not state.topmost in repo and state.backupfile: |
822 if not state.topmost in repo and state.backupfile: |
822 backupfile = repo.join(state.backupfile) |
823 backupfile = repo.join(state.backupfile) |
823 f = hg.openpath(ui, backupfile) |
824 f = hg.openpath(ui, backupfile) |
824 gen = exchange.readbundle(ui, f, backupfile) |
825 gen = exchange.readbundle(ui, f, backupfile) |
825 gen.apply(repo, 'histedit', 'bundle:' + backupfile) |
826 tr = repo.transaction('histedit.abort') |
|
827 try: |
|
828 if not isinstance(gen, bundle2.unbundle20): |
|
829 gen.apply(repo, 'histedit', 'bundle:' + backupfile) |
|
830 if isinstance(gen, bundle2.unbundle20): |
|
831 bundle2.applybundle(repo, gen, tr, |
|
832 source='histedit', |
|
833 url='bundle:' + backupfile) |
|
834 tr.close() |
|
835 finally: |
|
836 tr.release() |
|
837 |
826 os.remove(backupfile) |
838 os.remove(backupfile) |
827 |
839 |
828 # check whether we should update away |
840 # check whether we should update away |
829 if repo.unfiltered().revs('parents() and (%n or %ln::)', |
841 if repo.unfiltered().revs('parents() and (%n or %ln::)', |
830 state.parentctxnode, leafs | tmpnodes): |
842 state.parentctxnode, leafs | tmpnodes): |