Kiln » largefiles » largefiles-kiln-truncated changes meant to be shipped in Kiln Extensions to aid migration path to Mercurial-bundled largefiles
Clone URL:  

Merge in changes from Unity3D branch.

Changeset c3f500e966ee

Parents 0ffe0fb9a2d3

Parents d0975634cee1

by David Golub

Changes to 5 files · Browse files at c3f500e966ee Showing diff from parent 0ffe0fb9a2d3 d0975634cee1 Diff from another changeset...

 
8
9
10
 
11
12
13
 
196
197
198
 
 
 
 
 
 
199
200
201
 
204
205
206
207
208
 
 
 
 
 
209
210
211
 
853
854
855
856
857
 
 
858
859
860
861
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
862
863
 
 
 
 
 
 
 
864
865
866
 
1114
1115
1116
 
 
 
 
 
 
 
1117
1118
1119
 
1166
1167
1168
 
 
 
 
1169
1170
 
8
9
10
11
12
13
14
 
197
198
199
200
201
202
203
204
205
206
207
208
 
211
212
213
 
 
214
215
216
217
218
219
220
221
 
863
864
865
 
 
866
867
868
 
869
 
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
 
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
 
1214
1215
1216
1217
1218
1219
1220
1221
1222
@@ -8,6 +8,7 @@
  match as match_, filemerge, node, archival, httprepo, error  from mercurial.i18n import _  from mercurial.node import hex +from hgext import rebase  import bfutil, bfcommands    try: @@ -196,6 +197,12 @@
    wlock = repo.wlock()   try: + if getattr(repo, "_are_rebasing", False): + # We have to take the time to pull down the new bfiles now. Otherwise + # if we are rebasing, any bfiles that were modified in the changesets we + # are rebasing on top of get overwritten either by the rebase or in the + # first commit after the rebase. + bfcommands.update_bfiles(repo.ui, repo)   # Case 1: user calls commit with no specific files or   # include/exclude patterns: refresh and commit everything.   if (match is None) or (not match.anypats() and not match.files()): @@ -204,8 +211,11 @@
  # this only loops through bfiles that exist (not removed/renamed)   for bfile in bfiles:   if os.path.exists(self.wjoin(bfutil.standin(bfile))): - bfutil.update_standin(self, bfutil.standin(bfile)) - bfdirstate.normal(bfutil.unixpath(bfile)) + # this handles the case where a rebase is being performed and the + # working copy is not updated yet. + if os.path.exists(self.wjoin(bfile)): + bfutil.update_standin(self, bfutil.standin(bfile)) + bfdirstate.normal(bfutil.unixpath(bfile))   for bfile in bfdirstate:   if not os.path.exists(repo.wjoin(bfutil.standin(bfile))):   path = bfutil.unixpath(bfile) @@ -853,14 +863,45 @@
  return result    # When we rebase a repository with remotely changed bfiles, we need -# to explicitly do a clean update so that the entries in .kbf are -# udpated and the new bfiles are pulled +# to take some extra care so that the bfiles are correctly updated +# in the working copy  def override_pull(orig, ui, repo, source="default", **opts): - result = orig(ui, repo, source, **opts)   if opts.get('rebase', False): - commands.update(repo.ui, repo, clean = True) + setattr(repo, "_are_rebasing", True) + try: + if opts.get('update'): + del opts['update'] + ui.debug('--update and --rebase are not compatible, ignoring ' + 'the update flag\n') + del opts['rebase'] + cmdutil.bail_if_changed(repo) + revsprepull = len(repo) + origpostincoming = commands.postincoming + def _dummy(*args, **kwargs): + pass + commands.postincoming = _dummy + try: + result = commands.pull(ui, repo, source, **opts) + finally: + commands.postincoming = origpostincoming + revspostpull = len(repo) + if revspostpull > revsprepull: + result = result or rebase.rebase(ui, repo) + branch = repo[None].branch() + dest = repo[branch].rev() + finally: + setattr(repo, "_are_rebasing", False) + else: + result = orig(ui, repo, source, **opts)   return result   +def override_rebase(orig, ui, repo, **opts): + setattr(repo, "_are_rebasing", True) + try: + orig(ui, repo, **opts) + finally: + setattr(repo, "_are_rebasing", False) +  def override_archive(orig, repo, dest, node, kind, decode=True, matchfn=None,   prefix=None, mtime=None, subrepos=None):   # No need to lock because we are only reading history and bfile caches @@ -1114,6 +1155,13 @@
    return orig(ui, repo, *pats, **opts)   +# Calling purge with --all will cause the kbfiles to be deleted, but doesn't +# re-populate them. We must do it explicitly. It doesn't hurt anything to +# be safe and update them the rest of the time after calling purge, either. +def override_purge(orig, ui, repo, *dirs, **opts): + orig(ui, repo, *dirs, **opts) + bfcommands.update_bfiles(repo.ui, repo) +  def uisetup(ui):   # Disable auto-status for some commands which assume that all   # files in the result are under Mercurial's control @@ -1166,5 +1214,9 @@
  for name, module in extensions.extensions():   if name == 'fetch':   extensions.wrapcommand(getattr(module, 'cmdtable'), 'fetch', override_fetch) + if name == 'purge': + extensions.wrapcommand(getattr(module, 'cmdtable'), 'purge', override_purge) + if name == 'rebase': + extensions.wrapcommand(getattr(module, 'cmdtable'), 'rebase', override_rebase)    
Change 1 of 4 Show Entire File kbfiles/​bfutil.py Stacked
 
5
6
7
8
9
10
11
 
263
264
265
266
 
267
268
269
 
334
335
336
337
338
339
 
 
 
 
340
341
342
 
366
367
368
 
 
369
370
371
 
5
6
7
 
8
9
10
 
262
263
264
 
265
266
267
268
 
333
334
335
 
 
 
336
337
338
339
340
341
342
 
366
367
368
369
370
371
372
373
@@ -5,7 +5,6 @@
 import inspect  import shutil  import stat -import re    from mercurial import \   util, dirstate, cmdutil, match as match_ @@ -263,7 +262,7 @@
  if pats:   # patterns supplied: search .hgbfiles relative to current dir   cwd = repo.getcwd() - if len(cwd) > 0 and (re.match(r'[a-zA-Z]:\\', cwd) or cwd[0] == '/'): + if (os.path.isabs(cwd)):   # cwd is an absolute path for hg -R <reponame>   # work relative to the repository root in this case   cwd = '' @@ -334,9 +333,10 @@
   def update_standin(repo, standin):   file = repo.wjoin(split_standin(standin)) - hash = hashfile(file) - executable = get_executable(file) - write_standin(repo, standin, hash, executable) + if(os.path.exists(file)): + hash = hashfile(file) + executable = get_executable(file) + write_standin(repo, standin, hash, executable)    def read_standin(repo, standin):   '''read hex hash from <repo.root>/<standin>''' @@ -366,6 +366,8 @@
  return hashfile(repo.wjoin(file))    def hashfile(file): + if not os.path.exists(file): + return '';   hasher = util.sha1('')   with open(file, 'rb') as fd:   for data in blockstream(fd):
Change 1 of 1 Show Entire File tests/​common.py Stacked
 
11
12
13
14
 
 
15
16
17
 
11
12
13
 
14
15
16
17
18
@@ -11,7 +11,8 @@
 STOREDIR = os.path.join(os.getcwd(), 'store')    DEFAULTRC = { - 'extensions': [('kbfiles', kilntest.KBFILESPATH)], + 'extensions': [('kbfiles', kilntest.KBFILESPATH), + ('rebase', '')],   'kilnbfiles': [('systemcache', os.path.join(os.getcwd(), 'bfilesstore')),],   }  
 
55
56
57
 
 
 
 
 
 
55
56
57
58
59
60
61
62
@@ -55,3 +55,8 @@
 ''')  hgt.hg(['commit', '-m', 'adding', 'dir/b2', 'dir/n2'])  hgt.hg(['status']) +hgt.writefile('b1', 'b11') +hgt.hg(['status'], + stdout='M b1\n') +hgt.hg(['commit', '-m', 'modifying b1']) +hgt.asserttrue(hgt.readfile('b1') == 'b11', 'file contents dont match')
Change 1 of 1 Show Entire File tests/​test-rebase.py 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
@@ -0,0 +1,158 @@
+#!/usr/bin/python +# +# Test rebasing +# + +import os +import common + + +hgt = common.BfilesTester() + +hgt.updaterc() +hgt.announce('test') +os.mkdir('repo1') +os.chdir('repo1') +hgt.hg(['init']) +hgt.writefile('n1', 'n1') +hgt.hg(['add'], + stdout=('adding n1\n')) +hgt.hg(['commit', '-m', 'Add n1 repo1']) +hgt.writefile('b1', 'b1') +hgt.hg(['add', '--bf', 'b1']) +hgt.hg(['commit', '-m', 'Add bfile b1 in repo1']) +os.chdir('..') +hgt.hg(['clone', 'repo1', 'repo2'], + stdout=('updating to branch default\n' + '2 files updated, 0 files merged, 0 files removed, 0 files unresolved\n' + 'Getting changed bfiles\n' + '1 big files updated, 0 removed\n')) +os.chdir('repo1') +hgt.writefile('b1', 'b11') +hgt.hg(['commit', '-m', 'Modify bfile b1 in repo1']) +os.chdir('../repo2') +hgt.writefile('n1', 'n11') +hgt.hg(['commit', '-m', 'Modify n1 in repo2']) +hgt.hg(['pull', '--rebase'], + stdout=('pulling from $HGTMP/test-rebase.py/repo1\n' + 'searching for changes\n' + 'adding changesets\n' + 'adding manifests\n' + 'adding file changes\n' + 'added 1 changesets with 1 changes to 1 files (+1 heads)\n' + 'Getting changed bfiles\n' + '1 big files updated, 0 removed\n' + 'saved backup bundle to $HGTMP/test-rebase.py/repo2/.hg/strip-backup/5d80f03f644c-backup.hg\n' + 'nothing to rebase\n')) +hgt.hg(['out', '--bf'], + stdout=('comparing with $HGTMP/test-rebase.py/repo1\n' + 'searching for changes\n' + 'changeset: 3:168bfc518870\n' + 'tag: tip\n' + 'user: test\n' + 'date: Thu Jan 01 00:00:00 1970 +0000\n' + 'summary: Modify n1 in repo2\n' + '\n' + 'searching for changes\n' + 'kbfiles to upload:\n' + '\n')) +hgt.writefile('n1', 'n111'); +hgt.hg(['commit', '-m', 'Modify n1']) +hgt.hg(['out', '--bf'], + stdout=('comparing with $HGTMP/test-rebase.py/repo1\n' + 'searching for changes\n' + 'changeset: 3:168bfc518870\n' + 'user: test\n' + 'date: Thu Jan 01 00:00:00 1970 +0000\n' + 'summary: Modify n1 in repo2\n' + '\n' + 'changeset: 4:76fa4c6125bc\n' + 'tag: tip\n' + 'user: test\n' + 'date: Thu Jan 01 00:00:00 1970 +0000\n' + 'summary: Modify n1\n' + '\n' + 'searching for changes\n' + 'kbfiles to upload:\n' + '\n')) +hgt.hg(['update', '--clean'], + stdout=('0 files updated, 0 files merged, 0 files removed, 0 files unresolved\n' + 'Getting changed bfiles\n' + '0 big files updated, 0 removed\n')) +hgt.asserttrue(hgt.readfile('b1') == 'b11', "file contents don't match") + +# Now do the exact same thing with the rebase command instead of pull --rebase +os.chdir('..') +os.mkdir('repo3') +os.chdir('repo3') +hgt.hg(['init']) +hgt.writefile('n1', 'n1') +hgt.hg(['add'], + stdout=('adding n1\n')) +hgt.hg(['commit', '-m', 'Add n1 repo3']) +hgt.writefile('b1', 'b1') +hgt.hg(['add', '--bf', 'b1']) +hgt.hg(['commit', '-m', 'Add bfile b1 in repo3']) +os.chdir('..') +hgt.hg(['clone', 'repo3', 'repo4'], + stdout=('updating to branch default\n' + '2 files updated, 0 files merged, 0 files removed, 0 files unresolved\n' + 'Getting changed bfiles\n' + '1 big files updated, 0 removed\n')) +os.chdir('repo3') +hgt.writefile('b1', 'b11') +hgt.hg(['commit', '-m', 'Modify bfile b1 in repo3']) +os.chdir('../repo4') +hgt.writefile('n1', 'n11') +hgt.hg(['commit', '-m', 'Modify n1 in repo4']) +hgt.hg(['pull'], + stdout=('pulling from $HGTMP/test-rebase.py/repo3\n' + 'searching for changes\n' + 'adding changesets\n' + 'adding manifests\n' + 'adding file changes\n' + 'added 1 changesets with 1 changes to 1 files (+1 heads)\n' + '(run \'hg heads\' to see heads, \'hg merge\' to merge)\n')) + + +hgt.hg(['rebase'], + stdout=('Getting changed bfiles\n' + '1 big files updated, 0 removed\n' + 'saved backup bundle to $HGTMP/test-rebase.py/repo4/.hg/strip-backup/589266dab166-backup.hg\n')) +hgt.hg(['out', '--bf'], + stdout=('comparing with $HGTMP/test-rebase.py/repo3\n' + 'searching for changes\n' + 'changeset: 3:e4dbf8fdf868\n' + 'tag: tip\n' + 'user: test\n' + 'date: Thu Jan 01 00:00:00 1970 +0000\n' + 'summary: Modify n1 in repo4\n' + '\n' + 'searching for changes\n' + 'kbfiles to upload:\n' + '\n')) +hgt.writefile('n1', 'n111'); +hgt.hg(['commit', '-m', 'Modify n1']) +hgt.hg(['out', '--bf'], + stdout=('comparing with $HGTMP/test-rebase.py/repo3\n' + 'searching for changes\n' + 'changeset: 3:e4dbf8fdf868\n' + 'user: test\n' + 'date: Thu Jan 01 00:00:00 1970 +0000\n' + 'summary: Modify n1 in repo4\n' + '\n' + 'changeset: 4:26ba7897b44d\n' + 'tag: tip\n' + 'user: test\n' + 'date: Thu Jan 01 00:00:00 1970 +0000\n' + 'summary: Modify n1\n' + '\n' + 'searching for changes\n' + 'kbfiles to upload:\n' + '\n')) +hgt.hg(['update', '--clean'], + stdout=('0 files updated, 0 files merged, 0 files removed, 0 files unresolved\n' + 'Getting changed bfiles\n' + '0 big files updated, 0 removed\n')) + +hgt.asserttrue(hgt.readfile('b1') == 'b11', "file contents don't match")