Patchwork D1311: scmutil: don't try to delete origbackup symlinks to directories (issue5731)

login
register
mail settings
Submitter phabricator
Date Nov. 3, 2017, 4:25 p.m.
Message ID <differential-rev-PHID-DREV-skwwacaa5dghzsb23wxy-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/25375/
State Superseded
Headers show

Comments

phabricator - Nov. 3, 2017, 4:25 p.m.
mbthomas created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  When origbackuppath is set, when looking to see if a file we are backing up
  conflicts with a directory in the origbackuppath, we incorrectly match on
  symlinks to directories.  This means we try to call vfs.rmtree on the
  symlink, which fails.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D1311

AFFECTED FILES
  mercurial/scmutil.py
  tests/test-origbackup-conflict.t

CHANGE DETAILS




To: mbthomas, #hg-reviewers
Cc: mercurial-devel
phabricator - Nov. 9, 2017, 1:17 p.m.
yuja accepted this revision.
yuja added a comment.
This revision is now accepted and ready to land.


  Queued for stable, thanks.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D1311

To: mbthomas, #hg-reviewers, yuja
Cc: yuja, mercurial-devel

Patch

diff --git a/tests/test-origbackup-conflict.t b/tests/test-origbackup-conflict.t
--- a/tests/test-origbackup-conflict.t
+++ b/tests/test-origbackup-conflict.t
@@ -110,18 +110,12 @@ 
   creating directory: $TESTTMP/repo/.hg/origbackups/b (glob)
   removing conflicting file: $TESTTMP/repo/.hg/origbackups/b (glob)
   getting d
-  removing conflicting directory: $TESTTMP/repo/.hg/origbackups/d (glob)
-  abort: None
-  [255]
-
-Workaround issue by deleting d:
-
-  $ rm d
-  $ hg up c1
   2 files updated, 0 files merged, 0 files removed, 0 files unresolved
   (activating bookmark c1)
   $ cat .hg/origbackups/b/c
   c4
+  $ cat .hg/origbackups/d
+  d3
   $ ls ../sym-link-target
 
 Incorrectly configure origbackuppath to be under a file
diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py
--- a/mercurial/scmutil.py
+++ b/mercurial/scmutil.py
@@ -610,7 +610,7 @@ 
 
         origvfs.makedirs(origbackupdir)
 
-    if origvfs.isdir(filepathfromroot):
+    if origvfs.isdir(filepathfromroot) and not origvfs.islink(filepathfromroot):
         ui.note(_('removing conflicting directory: %s\n')
                 % origvfs.join(filepathfromroot))
         origvfs.rmtree(filepathfromroot, forcibly=True)