annotate tests/test-lfs-pointer.py @ 38679:b3d0c97a0820

rebase: in --confirm option just abort if hit a conflict Before this patch, it was prompting the user in both cases 1) when there is no conflict 2) when there is at least one conflict. But for simplicity we can just abort if we hit a conflict and no need to prompt in that case. Differential Revision: https://phab.mercurial-scm.org/D3944
author Sushil khanchi <sushilkhanchi97@gmail.com>
date Sat, 14 Jul 2018 08:59:42 +0530
parents 7cd1e1adc471
children 8a08aefa9273
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
35098
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
1 from __future__ import absolute_import, print_function
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
2
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
3 import os
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
4 import sys
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
5
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
6 # make it runnable using python directly without run-tests.py
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
7 sys.path[0:0] = [os.path.join(os.path.dirname(__file__), '..')]
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
8
37928
7cd1e1adc471 tests: port test-lfs-pointer.py to Python 3
Augie Fackler <augie@google.com>
parents: 35098
diff changeset
9 # Import something from Mercurial, so the module loader gets initialized.
7cd1e1adc471 tests: port test-lfs-pointer.py to Python 3
Augie Fackler <augie@google.com>
parents: 35098
diff changeset
10 from mercurial import pycompat
7cd1e1adc471 tests: port test-lfs-pointer.py to Python 3
Augie Fackler <augie@google.com>
parents: 35098
diff changeset
11 del pycompat # unused for now
7cd1e1adc471 tests: port test-lfs-pointer.py to Python 3
Augie Fackler <augie@google.com>
parents: 35098
diff changeset
12
35098
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
13 from hgext.lfs import pointer
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
14
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
15 def tryparse(text):
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
16 r = {}
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
17 try:
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
18 r = pointer.deserialize(text)
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
19 print('ok')
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
20 except Exception as ex:
37928
7cd1e1adc471 tests: port test-lfs-pointer.py to Python 3
Augie Fackler <augie@google.com>
parents: 35098
diff changeset
21 print((b'%s' % ex).decode('ascii'))
35098
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
22 if r:
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
23 text2 = r.serialize()
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
24 if text2 != text:
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
25 print('reconstructed text differs')
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
26 return r
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
27
37928
7cd1e1adc471 tests: port test-lfs-pointer.py to Python 3
Augie Fackler <augie@google.com>
parents: 35098
diff changeset
28 t = (b'version https://git-lfs.github.com/spec/v1\n'
7cd1e1adc471 tests: port test-lfs-pointer.py to Python 3
Augie Fackler <augie@google.com>
parents: 35098
diff changeset
29 b'oid sha256:4d7a214614ab2935c943f9e0ff69d22eadbb8f32b1'
7cd1e1adc471 tests: port test-lfs-pointer.py to Python 3
Augie Fackler <augie@google.com>
parents: 35098
diff changeset
30 b'258daaa5e2ca24d17e2393\n'
7cd1e1adc471 tests: port test-lfs-pointer.py to Python 3
Augie Fackler <augie@google.com>
parents: 35098
diff changeset
31 b'size 12345\n'
7cd1e1adc471 tests: port test-lfs-pointer.py to Python 3
Augie Fackler <augie@google.com>
parents: 35098
diff changeset
32 b'x-foo extra-information\n')
35098
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
33
37928
7cd1e1adc471 tests: port test-lfs-pointer.py to Python 3
Augie Fackler <augie@google.com>
parents: 35098
diff changeset
34 tryparse(b'')
35098
66c5a8cf2868 lfs: import the Facebook git-lfs client extension
Matt Harbison <matt_harbison@yahoo.com>
parents:
diff changeset
35 tryparse(t)
37928
7cd1e1adc471 tests: port test-lfs-pointer.py to Python 3
Augie Fackler <augie@google.com>
parents: 35098
diff changeset
36 tryparse(t.replace(b'git-lfs', b'unknown'))
7cd1e1adc471 tests: port test-lfs-pointer.py to Python 3
Augie Fackler <augie@google.com>
parents: 35098
diff changeset
37 tryparse(t.replace(b'v1\n', b'v1\n\n'))
7cd1e1adc471 tests: port test-lfs-pointer.py to Python 3
Augie Fackler <augie@google.com>
parents: 35098
diff changeset
38 tryparse(t.replace(b'sha256', b'ahs256'))
7cd1e1adc471 tests: port test-lfs-pointer.py to Python 3
Augie Fackler <augie@google.com>
parents: 35098
diff changeset
39 tryparse(t.replace(b'sha256:', b''))
7cd1e1adc471 tests: port test-lfs-pointer.py to Python 3
Augie Fackler <augie@google.com>
parents: 35098
diff changeset
40 tryparse(t.replace(b'12345', b'0x12345'))
7cd1e1adc471 tests: port test-lfs-pointer.py to Python 3
Augie Fackler <augie@google.com>
parents: 35098
diff changeset
41 tryparse(t.replace(b'extra-information', b'extra\0information'))
7cd1e1adc471 tests: port test-lfs-pointer.py to Python 3
Augie Fackler <augie@google.com>
parents: 35098
diff changeset
42 tryparse(t.replace(b'extra-information', b'extra\ninformation'))
7cd1e1adc471 tests: port test-lfs-pointer.py to Python 3
Augie Fackler <augie@google.com>
parents: 35098
diff changeset
43 tryparse(t.replace(b'x-foo', b'x_foo'))
7cd1e1adc471 tests: port test-lfs-pointer.py to Python 3
Augie Fackler <augie@google.com>
parents: 35098
diff changeset
44 tryparse(t.replace(b'oid', b'blobid'))
7cd1e1adc471 tests: port test-lfs-pointer.py to Python 3
Augie Fackler <augie@google.com>
parents: 35098
diff changeset
45 tryparse(t.replace(b'size', b'size-bytes').replace(b'oid', b'object-id'))