git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v3 7/7] remote-bzr: add support to push special modes

From
Felipe Contreras <felipe.contreras@gmail.com>
Date
Nov 11, 2012, 14:19 UTC
Message-ID
<1352643598-8500-8-git-send-email-felipe.contreras@gmail.com>
In-Reply-To
<1352643598-8500-1-git-send-email-felipe.contreras@gmail.com>
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 contrib/remote-helpers/git-remote-bzr | 60 +++++++++++++++++++++++++----------
 1 file changed, 43 insertions(+), 17 deletions(-)
diff --git a/contrib/remote-helpers/git-remote-bzr b/contrib/remote-helpers/git-remote-bzr
index 2bae5d0..f8919f4 100755
--- a/contrib/remote-helpers/git-remote-bzr
+++ b/contrib/remote-helpers/git-remote-bzr
@@ -370,7 +370,7 @@ class CustomTree():
         self.repo = repo
         self.revid = revid
         self.parents = parents
-        self.updates = files
+        self.updates = {}
 
         def copy_tree(revid):
             files = files_cache[revid] = {}
@@ -394,6 +394,13 @@ class CustomTree():
 
         self.files = files_cache[revid] = self.base_files.copy()
 
+        for path, f in files.iteritems():
+            fid = self.files.get(path, None)
+            if not fid:
+                fid = bzrlib.generate_ids.gen_file_id(path)
+            f['path'] = path
+            self.updates[fid] = f
+
     def last_revision(self):
         return self.base_id
 
@@ -409,13 +416,20 @@ class CustomTree():
                 return parent_fid
             if basename == '':
                 return None
-            d = add_entry(dirname, 'directory')
-            return d[0]
+            fid = bzrlib.generate_ids.gen_file_id(path)
+            d = add_entry(fid, dirname, 'directory')
+            return fid
 
-        def add_entry(path, kind):
+        def add_entry(fid, path, kind, mode = None):
             dirname, basename = os.path.split(path)
             parent_fid = get_parent(dirname, basename)
-            fid = bzrlib.generate_ids.gen_file_id(path)
+
+            executable = False
+            if mode == '100755':
+                executable = True
+            elif mode == '120000':
+                kind = 'symlink'
+
             change = (fid,
                     (None, path),
                     True,
@@ -423,15 +437,21 @@ class CustomTree():
                     (None, parent_fid),
                     (None, basename),
                     (None, kind),
-                    (None, False))
+                    (None, executable))
             self.files[path] = change[0]
             changes.append(change)
             return change
 
-        def update_entry(path, kind):
+        def update_entry(fid, path, kind, mode = None):
             dirname, basename = os.path.split(path)
-            fid = self.base_files[path]
             parent_fid = get_parent(dirname, basename)
+
+            executable = False
+            if mode == '100755':
+                executable = True
+            elif mode == '120000':
+                kind = 'symlink'
+
             change = (fid,
                     (path, path),
                     True,
@@ -439,14 +459,13 @@ class CustomTree():
                     (None, parent_fid),
                     (None, basename),
                     (None, kind),
-                    (None, False))
+                    (None, executable))
             self.files[path] = change[0]
             changes.append(change)
             return change
 
-        def remove_entry(path, kind):
+        def remove_entry(fid, path, kind):
             dirname, basename = os.path.split(path)
-            fid = self.base_files[path]
             parent_fid = get_parent(dirname, basename)
             change = (fid,
                     (path, None),
@@ -460,18 +479,25 @@ class CustomTree():
             changes.append(change)
             return change
 
-        for path, f in self.updates.iteritems():
+        for fid, f in self.updates.iteritems():
+            path = f['path']
+
             if 'deleted' in f:
-                remove_entry(path, 'file')
-            elif path in self.base_files:
-                update_entry(path, 'file')
+                remove_entry(fid, path, 'file')
+                continue
+
+            if path in self.base_files:
+                update_entry(fid, path, 'file', f['mode'])
             else:
-                add_entry(path, 'file')
+                add_entry(fid, path, 'file', f['mode'])
 
         return changes
 
     def get_file_with_stat(self, file_id, path=None):
-        return (StringIO.StringIO(self.updates[path]['data']), None)
+        return (StringIO.StringIO(self.updates[file_id]['data']), None)
+
+    def get_symlink_target(self, file_id):
+        return self.updates[file_id]['data']
 
 def parse_commit(parser):
     global marks, blob_marks, bmarks, parsed_refs
-- 
1.8.0
Previous: Felipe ContrerasNext: Felipe Contreras
Message 14 of 26 in “New remote-bzr remote helper”
  1. 0/7 New remote-bzr remote helperFelipe Contreras, Nov 11, 2012
  2. 1/7 Add new remote-bzr transport helperFelipe Contreras, Nov 11, 2012
  3. 2/7 remote-bzr: add support for pushingFelipe Contreras, Nov 11, 2012
  4. 3/7 remote-bzr: add support for remote repositoriesFelipe Contreras, Nov 11, 2012
  5. 4/7 remote-bzr: update working treeFelipe Contreras, Nov 11, 2012
  6. Junio C HamanoNov 28, 2012
  7. Felipe ContrerasDec 13, 2012
  8. Junio C HamanoDec 13, 2012
  9. Junio C HamanoDec 13, 2012
  10. Felipe ContrerasDec 14, 2012
  11. 5/7 remote-bzr: add simple testsFelipe Contreras, Nov 11, 2012
  12. Junio C HamanoNov 28, 2012
  13. 6/7 remote-bzr: add support for fecthing special modesFelipe Contreras, Nov 11, 2012
  14. 7/7 remote-bzr: add support to push special modesFelipe Contreras, Nov 11, 2012
  15. Felipe ContrerasNov 24, 2012
  16. Junio C HamanoNov 26, 2012
  17. Felipe ContrerasNov 26, 2012
  18. Junio C HamanoNov 27, 2012
  19. Felipe ContrerasNov 28, 2012
  20. Junio C HamanoNov 28, 2012
  21. Felipe ContrerasNov 28, 2012
  22. Junio C HamanoNov 28, 2012
  23. Felipe ContrerasNov 28, 2012
  24. Junio C HamanoNov 28, 2012
  25. Felipe ContrerasNov 28, 2012
  26. Felipe ContrerasNov 28, 2012

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.