Patchwork [1,of,8] largefiles: omit restoring standins if working parent is not rollbacked

login
register
mail settings
Submitter Katsunori FUJIWARA
Date Aug. 24, 2014, 2:54 p.m.
Message ID <7704d05858a4c56db12c.1408892087@feefifofum>
Download mbox | patch
Permalink /patch/5568/
State Accepted
Headers show

Comments

Katsunori FUJIWARA - Aug. 24, 2014, 2:54 p.m.
# HG changeset patch
# User FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
# Date 1408891645 -32400
#      Sun Aug 24 23:47:25 2014 +0900
# Node ID 7704d05858a4c56db12c28b90e7d2271192b8a83
# Parent  90cf454edd709c616d1e5ea4f30fb4d02f0c01a4
largefiles: omit restoring standins if working parent is not rollbacked

For efficiency, this patch omits restoring standins and updating
lfdirstate, if the parent of the working directory is not rollbacked.

This patch adds the test not to confirm whether restoring is skipped
or not, but to detect unexpected regression in the future: it is
difficult to distinguish between skipping and perfectly restoring.

Patch

diff --git a/hgext/largefiles/overrides.py b/hgext/largefiles/overrides.py
--- a/hgext/largefiles/overrides.py
+++ b/hgext/largefiles/overrides.py
@@ -1196,7 +1196,12 @@ 
 def overriderollback(orig, ui, repo, **opts):
     wlock = repo.wlock()
     try:
+        before = repo.dirstate.parents()
         result = orig(ui, repo, **opts)
+        after = repo.dirstate.parents()
+        if before == after:
+            return result # no need to restore standins
+
         merge.update(repo, node=None, branchmerge=False, force=True,
                      partial=lfutil.isstandin)
 
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
@@ -129,6 +129,29 @@ 
   $ hg status -A largeY
   ? largeY
 
+Test that "hg rollback" restores standins correctly
+
+  $ hg commit -m 'will be rollback-ed soon'
+  $ hg update -q -C 2
+  $ cat large1
+  large1
+  $ cat .hglf/large1
+  4669e532d5b2c093a78eca010077e708a071bb64
+  $ cat large2
+  large2 in #2
+  $ cat .hglf/large2
+  3cfce6277e7668985707b6887ce56f9f62f6ccd9
+
+  $ hg rollback -q -f
+  $ cat large1
+  large1
+  $ cat .hglf/large1
+  4669e532d5b2c093a78eca010077e708a071bb64
+  $ cat large2
+  large2 in #2
+  $ cat .hglf/large2
+  3cfce6277e7668985707b6887ce56f9f62f6ccd9
+
 Test that "hg status" shows status of largefiles correctly just after
 automated commit like rebase/transplant