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