[PATCH] keyword: do not depend on kwtools for rollback detection

Christian Ebert blacktrash at gmx.net
Mon Sep 27 13:27:38 CDT 2010


# HG changeset patch
# User Christian Ebert <blacktrash at gmx.net>
# Date 1285611990 -7200
# Node ID 4752374c0d2e63923e9a3da55413eda55bdecf06
# Parent  4746a2e4b239b315420e7439da507013437a6817
keyword: do not depend on kwtools for rollback detection

rollback is wrapped on localrepo level, therefore detect it
on a lower level.

Simpler criterion for when to read filelog.
Rename "cfiles" variable to "changed" for clarity.

diff --git a/hgext/keyword.py b/hgext/keyword.py
--- a/hgext/keyword.py
+++ b/hgext/keyword.py
@@ -191,20 +191,20 @@
         Caveat: localrepository._link fails on Windows.'''
         return self.match(path) and not 'l' in flagfunc(path)
 
-    def overwrite(self, ctx, candidates, iswctx, expand, cfiles):
+    def overwrite(self, ctx, candidates, iswctx, expand, changed):
         '''Overwrites selected files expanding/shrinking keywords.'''
-        if cfiles is not None:
-            candidates = [f for f in candidates if f in cfiles]
+        if changed is not None:
+            candidates = [f for f in candidates if f in changed]
         candidates = [f for f in candidates if self.iskwfile(f, ctx.flags)]
         if candidates:
             restrict = self.restrict
             self.restrict = True        # do not expand when reading
-            rollback = kwtools['hgcmd'] == 'rollback'
+            rollback = changed is not None and not self.record
             mf = ctx.manifest()
             msg = (expand and _('overwriting %s expanding keywords\n')
                    or _('overwriting %s shrinking keywords\n'))
             for f in candidates:
-                if not self.record and not rollback:
+                if changed is None:      # commit, kwexpand, kwshrink
                     data = self.repo.file(f).read(mf[f])
                 else:
                     data = self.repo.wread(f)
@@ -510,13 +510,13 @@
             wlock = repo.wlock()
             try:
                 if not dryrun:
-                    cfiles = self['.'].files()
+                    changed = self['.'].files()
                 ret = super(kwrepo, self).rollback(dryrun)
                 if not dryrun:
                     ctx = self['.']
                     modified, added = super(kwrepo, self).status()[:2]
-                    kwt.overwrite(ctx, added, True, False, cfiles)
-                    kwt.overwrite(ctx, modified, True, True, cfiles)
+                    kwt.overwrite(ctx, added, True, False, changed)
+                    kwt.overwrite(ctx, modified, True, True, changed)
                 return ret
             finally:
                 wlock.release()


More information about the Mercurial-devel mailing list