##// END OF EJS Templates
largefiles: remove pre-1.9 code from extension first bundled with 1.9
Na'Tosha Bard -
r15224:7c604d8c default
parent child Browse files
Show More
@@ -466,12 +466,7 b' def _updatelfile(repo, lfdirstate, lfile'
466 elif state == 'a':
466 elif state == 'a':
467 lfdirstate.add(lfile)
467 lfdirstate.add(lfile)
468 elif state == '?':
468 elif state == '?':
469 try:
470 # Mercurial >= 1.9
471 lfdirstate.drop(lfile)
469 lfdirstate.drop(lfile)
472 except AttributeError:
473 # Mercurial <= 1.8
474 lfdirstate.forget(lfile)
475 return ret
470 return ret
476
471
477 # -- hg commands declarations ------------------------------------------------
472 # -- hg commands declarations ------------------------------------------------
@@ -10,13 +10,11 b''
10
10
11 import os
11 import os
12 import errno
12 import errno
13 import inspect
14 import shutil
13 import shutil
15 import stat
14 import stat
16 import hashlib
15 import hashlib
17
16
18 from mercurial import cmdutil, dirstate, httpconnection, match as match_, \
17 from mercurial import dirstate, httpconnection, match as match_, util
19 url as url_, util
20 from mercurial.i18n import _
18 from mercurial.i18n import _
21
19
22 try:
20 try:
@@ -30,35 +28,14 b" longname = 'largefiles'"
30
28
31 # -- Portability wrappers ----------------------------------------------
29 # -- Portability wrappers ----------------------------------------------
32
30
33 if 'subrepos' in inspect.getargspec(dirstate.dirstate.status)[0]:
34 # for Mercurial >= 1.5
35 def dirstate_walk(dirstate, matcher, unknown=False, ignored=False):
31 def dirstate_walk(dirstate, matcher, unknown=False, ignored=False):
36 return dirstate.walk(matcher, [], unknown, ignored)
32 return dirstate.walk(matcher, [], unknown, ignored)
37 else:
38 # for Mercurial <= 1.4
39 def dirstate_walk(dirstate, matcher, unknown=False, ignored=False):
40 return dirstate.walk(matcher, unknown, ignored)
41
33
42 def repo_add(repo, list):
34 def repo_add(repo, list):
43 try:
44 # Mercurial <= 1.5
45 add = repo.add
46 except AttributeError:
47 # Mercurial >= 1.6
48 add = repo[None].add
35 add = repo[None].add
49 return add(list)
36 return add(list)
50
37
51 def repo_remove(repo, list, unlink=False):
38 def repo_remove(repo, list, unlink=False):
52 try:
53 # Mercurial <= 1.5
54 remove = repo.remove
55 except AttributeError:
56 # Mercurial >= 1.6
57 try:
58 # Mercurial <= 1.8
59 remove = repo[None].remove
60 except AttributeError:
61 # Mercurial >= 1.9
62 def remove(list, unlink):
39 def remove(list, unlink):
63 wlock = repo.wlock()
40 wlock = repo.wlock()
64 try:
41 try:
@@ -72,29 +49,14 b' def repo_remove(repo, list, unlink=False'
72 repo[None].forget(list)
49 repo[None].forget(list)
73 finally:
50 finally:
74 wlock.release()
51 wlock.release()
75
76 return remove(list, unlink=unlink)
52 return remove(list, unlink=unlink)
77
53
78 def repo_forget(repo, list):
54 def repo_forget(repo, list):
79 try:
80 # Mercurial <= 1.5
81 forget = repo.forget
82 except AttributeError:
83 # Mercurial >= 1.6
84 forget = repo[None].forget
55 forget = repo[None].forget
85 return forget(list)
56 return forget(list)
86
57
87 def findoutgoing(repo, remote, force):
58 def findoutgoing(repo, remote, force):
88 # First attempt is for Mercurial <= 1.5 second is for >= 1.6
89 try:
90 return repo.findoutgoing(remote)
91 except AttributeError:
92 from mercurial import discovery
59 from mercurial import discovery
93 try:
94 # Mercurial <= 1.8
95 return discovery.findoutgoing(repo, remote, force=force)
96 except AttributeError:
97 # Mercurial >= 1.9
98 common, _anyinc, _heads = discovery.findcommonincoming(repo,
60 common, _anyinc, _heads = discovery.findcommonincoming(repo,
99 remote, force=force)
61 remote, force=force)
100 return repo.changelog.findmissing(common)
62 return repo.changelog.findmissing(common)
@@ -155,12 +117,7 b' def openlfdirstate(ui, repo):'
155 repo root, but it is saved in .hg/largefiles/dirstate.
117 repo root, but it is saved in .hg/largefiles/dirstate.
156 '''
118 '''
157 admin = repo.join(longname)
119 admin = repo.join(longname)
158 try:
159 # Mercurial >= 1.9
160 opener = scmutil.opener(admin)
120 opener = scmutil.opener(admin)
161 except ImportError:
162 # Mercurial <= 1.8
163 opener = util.opener(admin)
164 if util.safehasattr(repo.dirstate, '_validate'):
121 if util.safehasattr(repo.dirstate, '_validate'):
165 lfdirstate = largefiles_dirstate(opener, ui, repo.root,
122 lfdirstate = largefiles_dirstate(opener, ui, repo.root,
166 repo.dirstate._validate)
123 repo.dirstate._validate)
@@ -286,12 +243,7 b' def getmatcher(repo, pats=[], opts={}, s'
286 '''Wrapper around scmutil.match() that adds showbad: if false, neuter
243 '''Wrapper around scmutil.match() that adds showbad: if false, neuter
287 the match object\'s bad() method so it does not print any warnings
244 the match object\'s bad() method so it does not print any warnings
288 about missing files or directories.'''
245 about missing files or directories.'''
289 try:
290 # Mercurial >= 1.9
291 match = scmutil.match(repo[None], pats, opts)
246 match = scmutil.match(repo[None], pats, opts)
292 except ImportError:
293 # Mercurial <= 1.8
294 match = cmdutil.match(repo, pats, opts)
295
247
296 if not showbad:
248 if not showbad:
297 match.bad = lambda f, msg: None
249 match.bad = lambda f, msg: None
@@ -462,16 +414,7 b' def hexsha1(data):'
462 return h.hexdigest()
414 return h.hexdigest()
463
415
464 def httpsendfile(ui, filename):
416 def httpsendfile(ui, filename):
465 try:
466 # Mercurial >= 1.9
467 return httpconnection.httpsendfile(ui, filename, 'rb')
417 return httpconnection.httpsendfile(ui, filename, 'rb')
468 except ImportError:
469 if 'ui' in inspect.getargspec(url_.httpsendfile.__init__)[0]:
470 # Mercurial == 1.8
471 return url_.httpsendfile(ui, filename, 'rb')
472 else:
473 # Mercurial <= 1.7
474 return url_.httpsendfile(filename, 'rb')
475
418
476 # Convert a path to a unix style path. This is used to give a
419 # Convert a path to a unix style path. This is used to give a
477 # canonical path to the lfdirstate.
420 # canonical path to the lfdirstate.
@@ -43,19 +43,9 b' def installnormalfilesmatchfn(manifest):'
43 oldmatch = installmatchfn(override_match)
43 oldmatch = installmatchfn(override_match)
44
44
45 def installmatchfn(f):
45 def installmatchfn(f):
46 try:
47 # Mercurial >= 1.9
48 oldmatch = scmutil.match
46 oldmatch = scmutil.match
49 except ImportError:
50 # Mercurial <= 1.8
51 oldmatch = cmdutil.match
52 setattr(f, 'oldmatch', oldmatch)
47 setattr(f, 'oldmatch', oldmatch)
53 try:
54 # Mercurial >= 1.9
55 scmutil.match = f
48 scmutil.match = f
56 except ImportError:
57 # Mercurial <= 1.8
58 cmdutil.match = f
59 return oldmatch
49 return oldmatch
60
50
61 def restorematchfn():
51 def restorematchfn():
@@ -64,12 +54,7 b' def restorematchfn():'
64
54
65 Note that n calls to installnormalfilesmatchfn will require n calls to
55 Note that n calls to installnormalfilesmatchfn will require n calls to
66 restore matchfn to reverse'''
56 restore matchfn to reverse'''
67 try:
68 # Mercurial >= 1.9
69 scmutil.match = getattr(scmutil.match, 'oldmatch', scmutil.match)
57 scmutil.match = getattr(scmutil.match, 'oldmatch', scmutil.match)
70 except ImportError:
71 # Mercurial <= 1.8
72 cmdutil.match = getattr(cmdutil.match, 'oldmatch', cmdutil.match)
73
58
74 # -- Wrappers: modify existing commands --------------------------------
59 # -- Wrappers: modify existing commands --------------------------------
75
60
@@ -98,12 +83,7 b' def override_add(orig, ui, repo, *pats, '
98 lfmatcher = match_.match(repo.root, '', list(lfpats))
83 lfmatcher = match_.match(repo.root, '', list(lfpats))
99
84
100 lfnames = []
85 lfnames = []
101 try:
102 # Mercurial >= 1.9
103 m = scmutil.match(repo[None], pats, opts)
86 m = scmutil.match(repo[None], pats, opts)
104 except ImportError:
105 # Mercurial <= 1.8
106 m = cmdutil.match(repo, pats, opts)
107 m.bad = lambda x, y: None
87 m.bad = lambda x, y: None
108 wctx = repo[None]
88 wctx = repo[None]
109 for f in repo.walk(m):
89 for f in repo.walk(m):
@@ -165,12 +145,7 b' def override_remove(orig, ui, repo, *pat'
165 after, force = opts.get('after'), opts.get('force')
145 after, force = opts.get('after'), opts.get('force')
166 if not pats and not after:
146 if not pats and not after:
167 raise util.Abort(_('no files specified'))
147 raise util.Abort(_('no files specified'))
168 try:
169 # Mercurial >= 1.9
170 m = scmutil.match(repo[None], pats, opts)
148 m = scmutil.match(repo[None], pats, opts)
171 except ImportError:
172 # Mercurial <= 1.8
173 m = cmdutil.match(repo, pats, opts)
174 try:
149 try:
175 repo.lfstatus = True
150 repo.lfstatus = True
176 s = repo.status(match=m, clean=True)
151 s = repo.status(match=m, clean=True)
@@ -332,21 +307,11 b' def override_copy(orig, ui, repo, pats, '
332 return orig(ui, repo, pats, opts, rename)
307 return orig(ui, repo, pats, opts, rename)
333
308
334 def makestandin(relpath):
309 def makestandin(relpath):
335 try:
336 # Mercurial >= 1.9
337 path = scmutil.canonpath(repo.root, repo.getcwd(), relpath)
310 path = scmutil.canonpath(repo.root, repo.getcwd(), relpath)
338 except ImportError:
339 # Mercurial <= 1.8
340 path = util.canonpath(repo.root, repo.getcwd(), relpath)
341 return os.path.join(os.path.relpath('.', repo.getcwd()),
311 return os.path.join(os.path.relpath('.', repo.getcwd()),
342 lfutil.standin(path))
312 lfutil.standin(path))
343
313
344 try:
345 # Mercurial >= 1.9
346 fullpats = scmutil.expandpats(pats)
314 fullpats = scmutil.expandpats(pats)
347 except ImportError:
348 # Mercurial <= 1.8
349 fullpats = cmdutil.expandpats(pats)
350 dest = fullpats[-1]
315 dest = fullpats[-1]
351
316
352 if os.path.isdir(dest):
317 if os.path.isdir(dest):
@@ -520,13 +485,8 b' def override_revert(orig, ui, repo, *pat'
520 m.matchfn = matchfn
485 m.matchfn = matchfn
521 return m
486 return m
522 oldmatch = installmatchfn(override_match)
487 oldmatch = installmatchfn(override_match)
523 try:
524 # Mercurial >= 1.9
525 scmutil.match
488 scmutil.match
526 matches = override_match(repo[None], pats, opts)
489 matches = override_match(repo[None], pats, opts)
527 except ImportError:
528 # Mercurial <= 1.8
529 matches = override_match(repo, pats, opts)
530 orig(ui, repo, *pats, **opts)
490 orig(ui, repo, *pats, **opts)
531 finally:
491 finally:
532 restorematchfn()
492 restorematchfn()
@@ -547,12 +507,7 b' def override_revert(orig, ui, repo, *pat'
547 standin = lfutil.standin(lfile)
507 standin = lfutil.standin(lfile)
548 if standin not in ctx and (standin in matches or opts.get('all')):
508 if standin not in ctx and (standin in matches or opts.get('all')):
549 if lfile in lfdirstate:
509 if lfile in lfdirstate:
550 try:
551 # Mercurial >= 1.9
552 lfdirstate.drop(lfile)
510 lfdirstate.drop(lfile)
553 except AttributeError:
554 # Mercurial <= 1.8
555 lfdirstate.forget(lfile)
556 util.unlinkpath(repo.wjoin(standin))
511 util.unlinkpath(repo.wjoin(standin))
557 lfdirstate.write()
512 lfdirstate.write()
558 finally:
513 finally:
@@ -586,12 +541,7 b' def override_pull(orig, ui, repo, source'
586 ui.debug('--update and --rebase are not compatible, ignoring '
541 ui.debug('--update and --rebase are not compatible, ignoring '
587 'the update flag\n')
542 'the update flag\n')
588 del opts['rebase']
543 del opts['rebase']
589 try:
590 # Mercurial >= 1.9
591 cmdutil.bailifchanged(repo)
544 cmdutil.bailifchanged(repo)
592 except AttributeError:
593 # Mercurial <= 1.8
594 cmdutil.bail_if_changed(repo)
595 revsprepull = len(repo)
545 revsprepull = len(repo)
596 origpostincoming = commands.postincoming
546 origpostincoming = commands.postincoming
597 def _dummy(*args, **kwargs):
547 def _dummy(*args, **kwargs):
@@ -635,21 +585,6 b' def override_archive(orig, repo, dest, n'
635
585
636 ctx = repo[node]
586 ctx = repo[node]
637
587
638 # In Mercurial <= 1.5 the prefix is passed to the archiver so try that
639 # if that doesn't work we are probably in Mercurial >= 1.6 where the
640 # prefix is not handled by the archiver
641 try:
642 archiver = archival.archivers[kind](dest, prefix, mtime or \
643 ctx.date()[0])
644
645 def write(name, mode, islink, getdata):
646 if matchfn and not matchfn(name):
647 return
648 data = getdata()
649 if decode:
650 data = repo.wwritedata(name, data)
651 archiver.addfile(name, mode, islink, data)
652 except TypeError:
653 if kind == 'files':
588 if kind == 'files':
654 if prefix:
589 if prefix:
655 raise util.Abort(
590 raise util.Abort(
@@ -739,12 +674,7 b' def override_forget(orig, ui, repo, *pat'
739 installnormalfilesmatchfn(repo[None].manifest())
674 installnormalfilesmatchfn(repo[None].manifest())
740 orig(ui, repo, *pats, **opts)
675 orig(ui, repo, *pats, **opts)
741 restorematchfn()
676 restorematchfn()
742 try:
743 # Mercurial >= 1.9
744 m = scmutil.match(repo[None], pats, opts)
677 m = scmutil.match(repo[None], pats, opts)
745 except ImportError:
746 # Mercurial <= 1.8
747 m = cmdutil.match(repo, pats, opts)
748
678
749 try:
679 try:
750 repo.lfstatus = True
680 repo.lfstatus = True
@@ -787,10 +717,6 b' def getoutgoinglfiles(ui, repo, dest=Non'
787 if revs:
717 if revs:
788 revs = [repo.lookup(rev) for rev in revs]
718 revs = [repo.lookup(rev) for rev in revs]
789
719
790 # Mercurial <= 1.5 had remoteui in cmdutil, then it moved to hg
791 try:
792 remoteui = cmdutil.remoteui
793 except AttributeError:
794 remoteui = hg.remoteui
720 remoteui = hg.remoteui
795
721
796 try:
722 try:
@@ -140,11 +140,7 b' def sshproto_refuseclient(self, message)'
140
140
141 def heads(repo, proto):
141 def heads(repo, proto):
142 if lfutil.islfilesrepo(repo):
142 if lfutil.islfilesrepo(repo):
143 try:
144 # Mercurial >= f4522df38c65
145 return wireproto.ooberror(LARGEFILES_REQUIRED_MSG)
143 return wireproto.ooberror(LARGEFILES_REQUIRED_MSG)
146 except AttributeError:
147 return proto.refuseclient(LARGEFILES_REQUIRED_MSG)
148 return wireproto.heads(repo, proto)
144 return wireproto.heads(repo, proto)
149
145
150 def sshrepo_callstream(self, cmd, **args):
146 def sshrepo_callstream(self, cmd, **args):
@@ -267,12 +267,7 b' def reposetup(ui, repo):'
267 for lfile in lfdirstate:
267 for lfile in lfdirstate:
268 if not os.path.exists(
268 if not os.path.exists(
269 repo.wjoin(lfutil.standin(lfile))):
269 repo.wjoin(lfutil.standin(lfile))):
270 try:
271 # Mercurial >= 1.9
272 lfdirstate.drop(lfile)
270 lfdirstate.drop(lfile)
273 except AttributeError:
274 # Mercurial <= 1.8
275 lfdirstate.forget(lfile)
276 lfdirstate.write()
271 lfdirstate.write()
277
272
278 return orig(text=text, user=user, date=date, match=match,
273 return orig(text=text, user=user, date=date, match=match,
@@ -306,12 +301,7 b' def reposetup(ui, repo):'
306 lfutil.updatestandin(self, standin)
301 lfutil.updatestandin(self, standin)
307 lfdirstate.normal(lfile)
302 lfdirstate.normal(lfile)
308 else:
303 else:
309 try:
310 # Mercurial >= 1.9
311 lfdirstate.drop(lfile)
304 lfdirstate.drop(lfile)
312 except AttributeError:
313 # Mercurial <= 1.8
314 lfdirstate.forget(lfile)
315 lfdirstate.write()
305 lfdirstate.write()
316
306
317 # Cook up a new matcher that only matches regular files or
307 # Cook up a new matcher that only matches regular files or
@@ -386,12 +376,8 b' def reposetup(ui, repo):'
386 toupload = toupload.union(set([ctx[f].data().strip() for f\
376 toupload = toupload.union(set([ctx[f].data().strip() for f\
387 in files if lfutil.isstandin(f) and f in ctx]))
377 in files if lfutil.isstandin(f) and f in ctx]))
388 lfcommands.uploadlfiles(ui, self, remote, toupload)
378 lfcommands.uploadlfiles(ui, self, remote, toupload)
389 # Mercurial >= 1.6 takes the newbranch argument, try that first.
390 try:
391 return super(lfiles_repo, self).push(remote, force, revs,
379 return super(lfiles_repo, self).push(remote, force, revs,
392 newbranch)
380 newbranch)
393 except TypeError:
394 return super(lfiles_repo, self).push(remote, force, revs)
395
381
396 repo.__class__ = lfiles_repo
382 repo.__class__ = lfiles_repo
397
383
General Comments 0
You need to be logged in to leave comments. Login now