Kiln » Dependencies » Dulwich Read More
Clone URL:  
Pushed to one repository · View In Graph Contained in master, master-1, and master-0

Skip ^{} tags.

Changeset 669105af83a4

Parent 9df270a8044b

by Jelmer Vernooij

Changes to 3 files · Browse files at 669105af83a4 Showing diff from parent 9df270a8044b Diff from another changeset...

Change 1 of 4 Show Changes Only bin/​dulwich Stacked
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
 
32
33
34
35
36
37
38
39
 
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
 
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
 
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
 
156
157
158
159
160
161
162
163
164
165
166
 
167
168
169
 
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
 #!/usr/bin/python  # dul-daemon - Simple git smart server client  # Copyright (C) 2008 Jelmer Vernooij <jelmer@samba.org>  #  # This program is free software; you can redistribute it and/or  # modify it under the terms of the GNU General Public License  # as published by the Free Software Foundation; version 2  # or (at your option) a later version of the License.  #  # This program is distributed in the hope that it will be useful,  # but WITHOUT ANY WARRANTY; without even the implied warranty of  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the  # GNU General Public License for more details.  #  # You should have received a copy of the GNU General Public License  # along with this program; if not, write to the Free Software  # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,  # MA 02110-1301, USA.    import sys  from getopt import getopt    def get_transport_and_path(uri):   from dulwich.client import TCPGitClient, SSHGitClient, SubprocessGitClient   for handler, transport in (("git://", TCPGitClient), ("git+ssh://", SSHGitClient)):   if uri.startswith(handler):   host, path = uri[len(handler):].split("/", 1)   return transport(host), "/"+path   # if its not git or git+ssh, try a local url..   return SubprocessGitClient(), uri   +  def cmd_fetch_pack(args):   from dulwich.client import SimpleFetchGraphWalker   from dulwich.repo import Repo   opts, args = getopt(args, "", ["all"])   opts = dict(opts)   client, path = get_transport_and_path(args.pop(0))   if "--all" in opts: - determine_wants = lambda x: [y for y in x.values() if not y in r.object_store] + determine_wants = r.object_store.determine_wants_all   else:   determine_wants = lambda x: [y for y in args if not y in r.object_store]   r = Repo(".")   graphwalker = SimpleFetchGraphWalker(r.heads().values(), r.get_parents)   f, commit = r.object_store.add_pack()   try:   client.fetch_pack(path, determine_wants, graphwalker, f.write, sys.stdout.write)   f.close()   commit()   except:   f.close()   raise      def cmd_log(args):   from dulwich.repo import Repo   opts, args = getopt(args, "", [])   r = Repo(".")   todo = [r.head()]   done = set()   while todo:   sha = todo.pop()   assert isinstance(sha, str)   if sha in done:   continue   done.add(sha)   commit = r.commit(sha)   print "-" * 50   print "commit: %s" % sha   if len(commit.parents) > 1:   print "merge: %s" % "...".join(commit.parents[1:])   print "author: %s" % commit.author   print "committer: %s" % commit.committer   print ""   print commit.message   print ""   todo.extend([p for p in commit.parents if p not in done])      def cmd_dump_pack(args):   from dulwich.errors import ApplyDeltaError   from dulwich.pack import Pack, sha_to_hex   import os   import sys     opts, args = getopt(args, "", [])     if args == []:   print "Usage: dulwich dump-pack FILENAME"   sys.exit(1)     basename, _ = os.path.splitext(args[0])   x = Pack(basename)   print "Object names checksum: %s" % x.name()   print "Checksum: %s" % sha_to_hex(x.get_stored_checksum())   if not x.check():   print "CHECKSUM DOES NOT MATCH"   print "Length: %d" % len(x)   for name in x:   try:   print "\t%s" % x[name]   except KeyError, k:   print "\t%s: Unable to resolve base %s" % (name, k)   except ApplyDeltaError, e:   print "\t%s: Unable to apply delta: %r" % (name, e)      def cmd_dump_index(args):   from dulwich.index import Index     opts, args = getopt(args, "", [])     if args == []:   print "Usage: dulwich dump-pack FILENAME"   sys.exit(1)     filename = args[0]   idx = Index(filename)     for o in idx:   print o[0]      def cmd_init(args):   from dulwich.repo import Repo   import os   import sys   opts, args = getopt(args, "", ["--bare"])   opts = dict(opts)     if args == []:   path = os.getcwd()   else:   path = args[0]     if not os.path.exists(path):   os.mkdir(path)     if "--bare" in opts:   Repo.init_bare(path)   else:   Repo.init(path)      def cmd_clone(args):   from dulwich.client import SimpleFetchGraphWalker   from dulwich.repo import Repo   import os   import sys   opts, args = getopt(args, "", [])   opts = dict(opts)     if args == []:   print "usage: dulwich clone host:path [PATH]"   sys.exit(1) -   client, host_path = get_transport_and_path(args.pop(0))     if len(args) > 0:   path = args.pop(0)   else:   path = host_path.split("/")[-1]     if not os.path.exists(path):   os.mkdir(path)   Repo.init(path)   r = Repo(path) - determine_wants = lambda x: [y for y in x.values() if not y in r.object_store]   graphwalker = SimpleFetchGraphWalker(r.heads().values(), r.get_parents)   f, commit = r.object_store.add_pack()   try: - client.fetch_pack(host_path, determine_wants, graphwalker, f.write, + client.fetch_pack(host_path, r.object_store.determine_wants_all, graphwalker, f.write,   sys.stdout.write)   f.close()   commit()   except:   f.close()   raise      commands = {   "fetch-pack": cmd_fetch_pack,   "dump-pack": cmd_dump_pack,   "dump-index": cmd_dump_index,   "init": cmd_init,   "log": cmd_log,   "clone": cmd_clone,   }    if len(sys.argv) < 2:   print "Usage: %s <%s> [OPTIONS...]" % (sys.argv[0], "|".join(commands.keys()))   sys.exit(1)    cmd = sys.argv[1]  if not cmd in commands:   print "No such subcommand: %s" % cmd   sys.exit(1)  commands[cmd](sys.argv[2:])
Change 1 of 1 Show Entire File dulwich/​client.py Stacked
 
85
86
87
88
89
 
90
91
92
 
85
86
87
 
 
88
89
90
91
@@ -85,8 +85,7 @@
  (sha, ref) = pkt.rstrip("\n").split(" ", 1)   if server_capabilities is None:   (ref, server_capabilities) = extract_capabilities(ref) - if not (ref == "capabilities^{}" and sha == "0" * 40): - refs[ref] = sha + refs[ref] = sha   return refs, server_capabilities     def send_pack(self, path, generate_pack_contents):
 
42
43
44
 
 
 
45
46
47
 
42
43
44
45
46
47
48
49
50
@@ -42,6 +42,9 @@
  self.path = path   self._packs = None   + def determine_wants_all(self, refs): + return [sha for (ref, sha) in refs.iteritems() if not sha in self and not ref.endswith("^{}")] +   def iter_shas(self, shas):   return ObjectStoreIterator(self, shas)