Kiln » largefiles » Unity
Clone URL:  

largefiles: minor readability cleanup

Changeset 4e1d17772b9e

Parent b5749d971187

by Profile picture of User 521Andrew Pritchard <andrewp@fogcreek.com>

Changes to 4 files · Browse files at 4e1d17772b9e Showing diff from parent b5749d971187 Diff from another changeset...

Change 1 of 3 Show Entire File lfcommands.py Stacked
 
138
139
140
141
142
143
144
145
146
 
147
148
149
 
219
220
221
222
223
224
225
226
227
 
228
229
230
 
296
297
298
299
300
 
301
302
303
 
138
139
140
 
 
 
 
 
 
141
142
143
144
 
214
215
216
 
 
 
 
 
 
217
218
219
220
 
286
287
288
 
 
289
290
291
292
@@ -138,12 +138,7 @@
  mc = ctx.manifest()   mp1 = ctx.parents()[0].manifest()   mp2 = ctx.parents()[1].manifest() - for f in mp1: - if f not in mc: - files.add(f) - for f in mp2: - if f not in mc: - files.add(f) + files |= (set(mp1) | set(mp2)) - set(mc)   for f in mc:   if mc[f] != mp1.get(f, None) or mc[f] != mp2.get(f, None):   files.add(f) @@ -219,12 +214,7 @@
  mc = ctx.manifest()   mp1 = ctx.parents()[0].manifest()   mp2 = ctx.parents()[1].manifest() - for f in mp1: - if f not in mc: - files.add(f) - for f in mp2: - if f not in mc: - files.add(f) + files |= (set(mp1) | set(mp2)) - set(mc)   for f in mc:   if mc[f] != mp1.get(f, None) or mc[f] != mp2.get(f, None):   files.add(f) @@ -296,8 +286,7 @@
  renamed = lfutil.standin(renamed[0])     return context.memfilectx(f, lfiletohash[srcfname], 'l' in - fctx.flags(), - 'x' in fctx.flags(), renamed) + fctx.flags(), 'x' in fctx.flags(), renamed)   else:   try:   fctx = ctx.filectx(f)
Change 1 of 4 Show Entire File lfutil.py Stacked
 
144
145
146
 
 
147
148
149
 
152
153
154
 
 
155
156
157
 
195
196
197
198
 
199
200
201
 
215
216
217
218
 
219
220
221
 
144
145
146
147
148
149
150
151
 
154
155
156
157
158
159
160
161
 
199
200
201
 
202
203
204
205
 
219
220
221
 
222
223
224
225
@@ -144,6 +144,8 @@
  return None    class largefiles_dirstate(dirstate.dirstate): + def __getitem__(self, key): + return super(largefiles_dirstate, self).__getitem__(unixpath(key))   def normal(self, f):   return super(largefiles_dirstate, self).normal(unixpath(f))   def remove(self, f): @@ -152,6 +154,8 @@
  return super(largefiles_dirstate, self).add(unixpath(f))   def drop(self, f):   return super(largefiles_dirstate, self).drop(unixpath(f)) + def forget(self, f): + return super(largefiles_dirstate, self).forget(unixpath(f))    def openlfdirstate(ui, repo):   ''' @@ -195,7 +199,7 @@
  raise   else:   if curhash == hash: - lfdirstate.normal(unixpath(bigfile)) + lfdirstate.normal(bigfile)   else:   lfdirstate.normallookup(bigfile)   @@ -215,7 +219,7 @@
  modified.append(lfile)   else:   clean.append(lfile) - lfdirstate.normal(unixpath(lfile)) + lfdirstate.normal(lfile)   lfdirstate.write()   finally:   wlock.release()
Change 1 of 8 Show Entire File overrides.py Stacked
 
33
34
35
36
 
37
38
 
 
39
40
41
42
43
44
45
46
47
48
49
50
51
52
 
53
54
55
 
80
81
82
83
 
84
85
86
 
100
101
102
103
104
 
 
105
106
 
107
108
109
 
219
220
221
222
 
223
224
225
 
244
245
246
247
 
248
249
250
251
252
 
253
254
255
 
275
276
277
278
 
279
280
281
 
479
480
481
482
483
 
 
484
485
486
487
 
 
488
489
490
 
848
849
850
851
852
 
 
853
854
 
855
856
857
 
33
34
35
 
36
37
38
39
40
41
42
43
44
 
 
 
 
 
 
 
 
 
 
45
46
47
48
 
73
74
75
 
76
77
78
79
 
93
94
95
 
 
96
97
98
 
99
100
101
102
 
212
213
214
 
215
216
217
218
 
237
238
239
 
240
241
242
243
244
 
245
246
247
248
 
268
269
270
 
271
272
273
274
 
472
473
474
 
 
475
476
477
478
 
 
479
480
481
482
483
 
841
842
843
 
 
844
845
846
 
847
848
849
850
@@ -33,23 +33,16 @@
 # matcher which matches only the normal files and running the original  # version of add.  def override_add(orig, ui, repo, *pats, **opts): - lf = opts.pop('large', None) + large = opts.pop('large', None)     lfsize = opts.pop('lfsize', None) + if not lfsize and lfutil.islfilesrepo(repo): + lfsize = ui.config(lfutil.longname, 'size', default='10')   if lfsize:   try:   lfsize = int(lfsize)   except ValueError: - raise util.Abort(_('size must be an integer, was %s\n') % lfsize) - else: - if os.path.exists(repo.wjoin(lfutil.shortname)): - lfsize = ui.config(lfutil.longname, 'size', default='10') - if lfsize: - try: - lfsize = int(lfsize) - except ValueError: - raise util.Abort(_('largefiles.size must be integer, was %s\n') - % lfsize) + raise util.Abort(_('largefiles: size must be an integer, was %s\n') % lfsize)     lfmatcher = None   if os.path.exists(repo.wjoin(lfutil.shortname)): @@ -80,7 +73,7 @@
  if exact and nfile:   continue   if exact or (not lfile and not nfile): - if lf or (lfsize and os.path.getsize(repo.wjoin(f)) >= \ + if large or (lfsize and os.path.getsize(repo.wjoin(f)) >= \   lfsize * 1024 * 1024) or (lfmatcher and lfmatcher(f)):   lfnames.append(f)   if ui.verbose or not exact: @@ -100,10 +93,10 @@
  lfutil.writestandin(repo, standinname, hash='',   executable=lfutil.getexecutable(repo.wjoin(f)))   standins.append(standinname) - if lfdirstate[lfutil.unixpath(f)] == 'r': - lfdirstate.normallookup(lfutil.unixpath(f)) + if lfdirstate[f] == 'r': + lfdirstate.normallookup(f)   else: - lfdirstate.add(lfutil.unixpath(f)) + lfdirstate.add(f)   lfdirstate.write()   bad += [lfutil.splitstandin(f) for f in lfutil.repo_add(repo,   standins) if f in m.files()] @@ -219,7 +212,7 @@
  while currentdir and not os.listdir(repo.wjoin(currentdir)):   os.rmdir(repo.wjoin(currentdir))   currentdir = os.path.split(currentdir)[0] - lfdirstate.remove(lfutil.unixpath(f)) + lfdirstate.remove(f)   lfdirstate.write()     forget = [lfutil.standin(f) for f in forget] @@ -244,12 +237,12 @@
  repo.lfstatus = False    def override_verify(orig, ui, repo, *pats, **opts): - lf = opts.pop('large', False) + large = opts.pop('large', False)   all = opts.pop('lfa', False)   contents = opts.pop('lfc', False)     result = orig(ui, repo, *pats, **opts) - if lf: + if large:   result = result or lfcommands.verifylfiles(ui, repo, all, contents)   return result   @@ -275,7 +268,7 @@
  lfutil.hashfile(repo.wjoin(lfile)):   mod = True   else: - lfdirstate.normal(lfutil.unixpath(lfile)) + lfdirstate.normal(lfile)   lfdirstate.write()   if mod:   raise util.Abort(_('uncommitted local changes')) @@ -479,12 +472,12 @@
  os.makedirs(destlfiledir)   if rename:   os.rename(srclfile, destlfile) - lfdirstate.remove(lfutil.unixpath(os.path.relpath(srclfile, - repo.root))) + lfdirstate.remove(os.path.relpath(srclfile, + repo.root))   else:   util.copyfile(srclfile, destlfile) - lfdirstate.add(lfutil.unixpath(os.path.relpath(destlfile, - repo.root))) + lfdirstate.add(os.path.relpath(destlfile, + repo.root))   lfdirstate.write()   except util.Abort, e:   if str(e) != 'no files to copy': @@ -848,10 +841,10 @@
  try:   lfdirstate = lfutil.openlfdirstate(ui, repo)   for f in forget: - if lfdirstate[lfutil.unixpath(f)] == 'a': - lfdirstate.drop(lfutil.unixpath(f)) + if lfdirstate[f] == 'a': + lfdirstate.drop(f)   else: - lfdirstate.remove(lfutil.unixpath(f)) + lfdirstate.remove(f)   lfdirstate.write()   lfutil.repo_remove(repo, [lfutil.standin(f) for f in forget],   unlink=True)
Change 1 of 3 Show Entire File reposetup.py Stacked
 
160
161
162
163
 
164
165
166
 
261
262
263
264
 
265
266
267
268
269
270
271
 
272
273
274
 
275
276
277
 
303
304
305
306
 
307
308
309
310
311
 
312
313
314
 
315
316
317
 
160
161
162
 
163
164
165
166
 
261
262
263
 
264
265
266
267
 
268
269
 
270
271
272
 
273
274
275
276
 
302
303
304
 
305
306
 
307
308
 
309
310
311
 
312
313
314
315
@@ -160,7 +160,7 @@
  modified.append(lfile)   else:   clean.append(lfile) - lfdirstate.normal(lfutil.unixpath(lfile)) + lfdirstate.normal(lfile)   lfdirstate.write()   else:   tocheck = unsure + modified + added + clean @@ -261,17 +261,16 @@
  if os.path.exists(self.wjoin(lfile)):   lfutil.updatestandin(self,   lfutil.standin(lfile)) - lfdirstate.normal(lfutil.unixpath(lfile)) + lfdirstate.normal(lfile)   for lfile in lfdirstate:   if not os.path.exists(   repo.wjoin(lfutil.standin(lfile))): - path = lfutil.unixpath(lfile)   try:   # Mercurial >= 1.9 - lfdirstate.drop(path) + lfdirstate.drop(lfile)   except AttributeError:   # Mercurial <= 1.8 - lfdirstate.forget(path) + lfdirstate.forget(lfile)   lfdirstate.write()     return orig(text=text, user=user, date=date, match=match, @@ -303,15 +302,14 @@
  lfile = lfutil.splitstandin(standin)   if lfdirstate[lfile] <> 'r':   lfutil.updatestandin(self, standin) - lfdirstate.normal(lfutil.unixpath(lfile)) + lfdirstate.normal(lfile)   else: - path = lfutil.unixpath(lfile)   try:   # Mercurial >= 1.9 - lfdirstate.drop(path) + lfdirstate.drop(lfile)   except AttributeError:   # Mercurial <= 1.8 - lfdirstate.forget(path) + lfdirstate.forget(lfile)   lfdirstate.write()     # Cook up a new matcher that only matches regular files or