Patchwork [2,of,5] vfs: make it possible to pass multiple path elements to join

login
register
mail settings
Submitter Matt Harbison
Date April 5, 2015, 2:34 a.m.
Message ID <35aa561e59e68e951eba.1428201260@Envy>
Download mbox | patch
Permalink /patch/8500/
State Accepted
Headers show

Comments

Matt Harbison - April 5, 2015, 2:34 a.m.
# HG changeset patch
# User Matt Harbison <matt_harbison@yahoo.com>
# Date 1428182356 14400
#      Sat Apr 04 17:19:16 2015 -0400
# Node ID 35aa561e59e68e951ebac081a9c7f6a5e64b0ace
# Parent  978813e773a6cbc75a9942e01e5b21dba69faf96
vfs: make it possible to pass multiple path elements to join

os.path.join(), localrepo.join() and localrepo.wjoin() allow passing multiple
path elements; vfs.join() should be as convenient.

Patch

diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py
--- a/mercurial/scmutil.py
+++ b/mercurial/scmutil.py
@@ -445,9 +445,9 @@ 
         else:
             self.write(dst, src)
 
-    def join(self, path):
+    def join(self, path, *insidef):
         if path:
-            return os.path.join(self.base, path)
+            return os.path.join(self.base, path, *insidef)
         else:
             return self.base
 
@@ -475,9 +475,9 @@ 
     def __call__(self, path, *args, **kwargs):
         return self.vfs(self._filter(path), *args, **kwargs)
 
-    def join(self, path):
+    def join(self, path, *insidef):
         if path:
-            return self.vfs.join(self._filter(path))
+            return self.vfs.join(self._filter(self.vfs.reljoin(path, *insidef)))
         else:
             return self.vfs.join(path)