keyword: make restrict mode False while updating files for rollback
authorFUJIWARA Katsunori <foozy@lares.dti.ne.jp>
Sun, 04 Oct 2015 21:33:29 +0900
changeset 26463 b3188339a772
parent 26462 3b0ec09192ae
child 26464 9a7fc6d48898
keyword: make restrict mode False while updating files for rollback This is a preparation for using 'repo.rollback()' instead of aborting a current running transaction for "shelve" and "unshelve". Before this patch, updating files as a part of 'repo.rollback()' overridden by keyword extension always follows 'restrict' mode of the command currently executed. "merge", "unshelve" and so on should be 'restrict'-ed, because keyword expansion may cause unexpected conflicts at merging while these commands. But, if 'repo.rollback()' is invoked while executing 'restrict'-ed commands, modified files in the working directory are marked as "CLEAN" unexpectedly by code path below: # 'lookup' below is True at updating modified files for rollback kwcmd = self.restrict and lookup # kwexpand/kwshrink : if kwcmd: self.repo.dirstate.normal(f) On the other hand, "rollback" command isn't 'restrict'-ed, because rollbacking itself doesn't imply merging. Therefore, disabling 'restrict' mode while updating files as a part of 'repo.rollback()' regardless of current 'restrict' mode should be reasonable.
hgext/keyword.py
--- a/hgext/keyword.py	Sun Oct 04 11:34:28 2015 -0700
+++ b/hgext/keyword.py	Sun Oct 04 21:33:29 2015 +0900
@@ -623,6 +623,7 @@
 
         def rollback(self, dryrun=False, force=False):
             wlock = self.wlock()
+            origrestrict = kwt.restrict
             try:
                 if not dryrun:
                     changed = self['.'].files()
@@ -630,10 +631,12 @@
                 if not dryrun:
                     ctx = self['.']
                     modified, added = _preselect(ctx.status(), changed)
+                    kwt.restrict = False
                     kwt.overwrite(ctx, modified, True, True)
                     kwt.overwrite(ctx, added, True, False)
                 return ret
             finally:
+                kwt.restrict = origrestrict
                 wlock.release()
 
     # monkeypatches