[PATCH 2 of 7 PoC] largefiles: use standintolargefiles decorator for rollback

Mads Kiilerich mads at kiilerich.com
Mon Sep 22 04:13:35 CDT 2014


# HG changeset patch
# User Mads Kiilerich <madski at unity3d.com>
# Date 1411377060 -7200
#      Mon Sep 22 11:11:00 2014 +0200
# Node ID 5d277c50fc0e0b9788634518671b7afbd15611bb
# Parent  0a6268c1e3ef11406fbaf186f5941069a08e2073
largefiles: use standintolargefiles decorator for rollback

diff --git a/hgext/largefiles/overrides.py b/hgext/largefiles/overrides.py
--- a/hgext/largefiles/overrides.py
+++ b/hgext/largefiles/overrides.py
@@ -1134,45 +1134,9 @@ def overridepurge(orig, ui, repo, *dirs,
     orig(ui, repo, *dirs, **opts)
     repo.status = oldstatus
 
+ at lfutil.standintolargefiles(printmessage=False)
 def overriderollback(orig, ui, repo, **opts):
-    wlock = repo.wlock()
-    try:
-        before = repo.dirstate.parents()
-        orphans = set(f for f in repo.dirstate
-                      if lfutil.isstandin(f) and repo.dirstate[f] != 'r')
-        result = orig(ui, repo, **opts)
-        after = repo.dirstate.parents()
-        if before == after:
-            return result # no need to restore standins
-
-        pctx = repo['.']
-        for f in repo.dirstate:
-            if lfutil.isstandin(f):
-                orphans.discard(f)
-                if repo.dirstate[f] == 'r':
-                    repo.wvfs.unlinkpath(f, ignoremissing=True)
-                elif f in pctx:
-                    fctx = pctx[f]
-                    repo.wwrite(f, fctx.data(), fctx.flags())
-                else:
-                    # content of standin is not so important in 'a',
-                    # 'm' or 'n' (coming from the 2nd parent) cases
-                    lfutil.writestandin(repo, f, '', False)
-        for standin in orphans:
-            repo.wvfs.unlinkpath(standin, ignoremissing=True)
-
-        lfdirstate = lfutil.openlfdirstate(ui, repo)
-        orphans = set(lfdirstate)
-        lfiles = lfutil.listlfiles(repo)
-        for file in lfiles:
-            lfutil.synclfdirstate(repo, lfdirstate, file, True)
-            orphans.discard(file)
-        for lfile in orphans:
-            lfdirstate.drop(lfile)
-        lfdirstate.write()
-    finally:
-        wlock.release()
-    return result
+    return orig(ui, repo, **opts)
 
 @lfutil.standintolargefiles(printmessage=True)
 def overridetransplant(orig, ui, repo, *revs, **opts):
diff --git a/tests/test-largefiles-update.t b/tests/test-largefiles-update.t
--- a/tests/test-largefiles-update.t
+++ b/tests/test-largefiles-update.t
@@ -126,6 +126,7 @@ Test that "hg rollback" restores status 
   $ hg rollback
   repository tip rolled back to revision 3 (undo commit)
   working directory now based on revision 3
+(largeY as added was incorrectly lost ... and other weird things happens)
   $ hg status -A large1
   R large1
   $ test -f .hglf/large1
@@ -137,11 +138,10 @@ Test that "hg rollback" restores status 
   $ hg status -A largeX
   A largeX
   $ cat .hglf/largeX
-  
+  fa44618ea25181aff4f48b70428294790cec9f61
   $ hg status -A largeY
   ? largeY
   $ test -f .hglf/largeY
-  [1]
 
 Test that "hg rollback" restores standins correctly
 


More information about the Mercurial-devel mailing list