Commits

Henrik Stuart  committed d1d4de3

undo: fix possible corruption due to stale undo data in global metadata

review: Sune Foldager

  • Participants
  • Parent commits 6da05e6

Comments (0)

Files changed (3)

File repoman/commands.py

     if mergecommit:
         if util.commit(f.gmd_repo, 'Fast-forward of branch %s' % f.branch, [f.branch_relpath(f.branch)], date=date):
             undo.append(f.GMD)
-            for hg_undo, repo_undo in f.get_gmd_undo_files():
-                mercurial.util.rename(hg_undo, repo_undo)
         message = True
         mergetext = ['Merge %s to %s' % tuple(f.state.data)]
 
                         util.docmd_encoding(lambda: repo.commit('merge'))
                         heads = [x for x in repo.heads() if repo[x].rev() != repo['.'].rev()]
 
+                    for hg_undo, repo_undo in f.get_gmd_undo_files():
+                        mercurial.util.rename(repo_undo, hg_undo)
+
                 # no need to explicitly update metadata, already done by the rebase after pull
         except util.LookupError, e:
             if not bundle:
         ui.write(modstr % ('(metadata)' if md else mod))
         repo = f[mod]
         repo.ui.filter = ui.filter
-        if md:
-            if os.path.exists(repo.sjoin('repoman.undo')):
-                for hg_undo, repo_undo in f.get_gmd_undo_files():
-                    mercurial.util.rename(repo_undo, hg_undo)
         repo.rollback()
         if md and operation != 'pull':
             # Clean-update and purge metadata

File tests/output/undo.py

     with Quiet():
         run('branch -c core/test')
     run('info')
+    print 'undo in .root/.hg/store:', 'undo' in os.listdir('.root/.hg/store')
+    print 'repoman.undo not in .root/.hg/store:', 'repoman.undo' not in os.listdir('.root/.hg/store')
     run('undo --yes')
     run('info')
     

File tests/output/undo.py.out

 Repository forest in directory <TESTROOT>/undof
 Working branch: core/test
 Modules: a, b
+undo in .root/.hg/store: True
+repoman.undo not in .root/.hg/store: True
 operation: Created branch core/test
 involved modules: (metadata)
 (metadata)  repository tip rolled back to revision 2 (undo commit)