Patchwork D5907: copy: respect ui.relative-paths in copy/rename

login
register
mail settings
Submitter phabricator
Date Feb. 9, 2019, 10:25 p.m.
Message ID <5de55ee427450fe5c06efd9f10f7d455@localhost.localdomain>
Download mbox | patch
Permalink /patch/38622/
State Not Applicable
Headers show

Comments

phabricator - Feb. 9, 2019, 10:25 p.m.
martinvonz updated this revision to Diff 13977.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D5907?vs=13934&id=13977

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

AFFECTED FILES
  mercurial/cmdutil.py
  mercurial/scmutil.py
  tests/test-copy.t

CHANGE DETAILS




To: martinvonz, #hg-reviewers
Cc: mercurial-devel
Yuya Nishihara - Feb. 10, 2019, 3:37 a.m.
> --- a/mercurial/scmutil.py
> +++ b/mercurial/scmutil.py
> @@ -51,8 +51,10 @@
>  )
>  
>  if pycompat.iswindows:
> +    from . import windows as platform
>      from . import scmwindows as scmplatform
>  else:
> +    from . import posix as platform
>      from . import scmposix as scmplatform

It's `util.localpath()`.

> @@ -757,7 +759,7 @@
>          pathto = repo.pathto
>          return lambda f: pathto(f, cwd)
>      else:
> -        return lambda f: f
> +        return platform.localpath

I've removed this since it seemed unrelated to this specific patch. It might
break some Windows tests, but it should already be broken since a997163e7fae.
Some (or all?) `uipathfn()`s have to respect `ui.slash` config on Windows.
phabricator - Feb. 10, 2019, 3:45 a.m.
yuja added a comment.


  > - a/mercurial/scmutil.py +++ b/mercurial/scmutil.py @@ -51,8 +51,10 @@ )
  > 
  >   if pycompat.iswindows: +    from . import windows as platform from . import scmwindows as scmplatform else: +    from . import posix as platform from . import scmposix as scmplatform
  
  It's `util.localpath()`.
  
  > @@ -757,7 +759,7 @@
  > 
  >       pathto = repo.pathto
  >       return lambda f: pathto(f, cwd)
  >   else:
  > 
  > - return lambda f: f +        return platform.localpath
  
  I've removed this since it seemed unrelated to this specific patch. It might
  break some Windows tests, but it should already be broken since https://phab.mercurial-scm.org/rHGa997163e7fae2fe933f8d0c6d1013205befd1ee4.
  Some (or all?) `uipathfn()`s have to respect `ui.slash` config on Windows.

REPOSITORY
  rHG Mercurial

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

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

Patch

diff --git a/tests/test-copy.t b/tests/test-copy.t
--- a/tests/test-copy.t
+++ b/tests/test-copy.t
@@ -118,6 +118,23 @@ 
   [255]
   $ hg st -A
   ? foo
+respects ui.relative-paths
+  $ mkdir dir
+  $ cd dir
+  $ hg mv ../foo ../bar
+  ../foo: not copying - file is not managed
+  abort: no files to copy
+  [255]
+  $ hg mv ../foo ../bar --config ui.relative-paths=yes
+  ../foo: not copying - file is not managed
+  abort: no files to copy
+  [255]
+  $ hg mv ../foo ../bar --config ui.relative-paths=no
+  foo: not copying - file is not managed
+  abort: no files to copy
+  [255]
+  $ cd ..
+  $ rmdir dir
   $ hg add foo
 dry-run; print a warning that this is not a real copy; foo is added
   $ hg mv --dry-run foo bar
diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py
--- a/mercurial/scmutil.py
+++ b/mercurial/scmutil.py
@@ -51,8 +51,10 @@ 
 )
 
 if pycompat.iswindows:
+    from . import windows as platform
     from . import scmwindows as scmplatform
 else:
+    from . import posix as platform
     from . import scmposix as scmplatform
 
 parsers = policy.importmod(r'parsers')
@@ -757,7 +759,7 @@ 
         pathto = repo.pathto
         return lambda f: pathto(f, cwd)
     else:
-        return lambda f: f
+        return platform.localpath
 
 def subdiruipathfn(subpath, uipathfn):
     '''Create a new uipathfn that treats the file as relative to subpath.'''
diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -1135,6 +1135,7 @@ 
     dryrun = opts.get("dry_run")
     wctx = repo[None]
 
+    uipathfn = scmutil.getuipathfn(repo, legacyrelativevalue=True)
     def walkpat(pat):
         srcs = []
         if after:
@@ -1144,7 +1145,7 @@ 
         m = scmutil.match(wctx, [pat], opts, globbed=True)
         for abs in wctx.walk(m):
             state = repo.dirstate[abs]
-            rel = m.rel(abs)
+            rel = uipathfn(abs)
             exact = m.exact(abs)
             if state in badstates:
                 if exact and state == '?':