Kiln » Unity3D Unity 3D's proposed fixes and extensions to Kiln BFiles
Clone URL:  

Fix rebasing once and for all.

Changeset ea4a93f9f8d0

Parent e9febbf6d1d9

by Profile picture of User 496Na'Tosha Bard <natosha@unity3d.com>

Changes to 5 files · Browse files at ea4a93f9f8d0 Showing diff from parent e9febbf6d1d9 Diff from another changeset...

 
8
9
10
 
11
12
13
 
196
197
198
 
 
 
 
 
 
199
200
201
 
204
205
206
207
208
 
 
 
 
 
209
210
211
 
752
753
754
755
756
 
 
757
758
759
760
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
761
762
 
 
 
 
 
 
 
763
764
765
 
1040
1041
1042
 
 
1043
1044
 
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
 
762
763
764
 
 
765
766
767
 
768
 
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
 
1081
1082
1083
1084
1085
1086
1087
@@ -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    def hgversion(): @@ -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))):   bfdirstate.forget(bfutil.unixpath(bfile)) @@ -752,14 +762,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 @@ -1040,5 +1081,7 @@
  for name, module in extensions.extensions():   if name == 'fetch':   extensions.wrapcommand(getattr(module, 'cmdtable'), 'fetch', override_fetch) + if name == 'rebase': + extensions.wrapcommand(getattr(module, 'cmdtable'), 'rebase', override_rebase)    
Change 1 of 2 Show Changes Only kbfiles/​bfutil.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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
 
 
 
 
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
 
 
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
 
 
 
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
 '''bfiles utility code: must not import other modules in this package.'''    import os  import errno  import inspect  import shutil  import stat    from mercurial import \   util, dirstate, cmdutil, match as match_  from mercurial.i18n import _    short_name = '.kbf'  long_name = 'kilnbfiles'      # -- Portability wrappers ----------------------------------------------    if 'subrepos' in inspect.getargspec(dirstate.dirstate.status)[0]:   # for Mercurial >= 1.5   def dirstate_walk(dirstate, matcher, unknown=False, ignored=False):   return dirstate.walk(matcher, [], unknown, ignored)  else:   # for Mercurial <= 1.4   def dirstate_walk(dirstate, matcher, unknown=False, ignored=False):   return dirstate.walk(matcher, unknown, ignored)    def repo_add(repo, list):   try:   # Mercurial <= 1.5   add = repo.add   except AttributeError:   # Mercurial >= 1.6   add = repo[None].add   return add(list)    def repo_remove(repo, list, unlink=False):   try:   # Mercurial <= 1.5   remove = repo.remove   except AttributeError:   # Mercurial >= 1.6   remove = repo[None].remove   return remove(list, unlink=unlink)    def repo_forget(repo, list):   try:   # Mercurial <= 1.5   forget = repo.forget   except AttributeError:   # Mercurial >= 1.6   forget = repo[None].forget   return forget(list)    def dirstate_normaldirty(dirstate, file):   try:   normaldirty = dirstate.normaldirty   except AttributeError:   # Mercurial >= 1.6: HAAAACK: I should not be using normaldirty()   # (now called otherparent()), and dirstate in 1.6 prevents me   # from doing so. So reimplement it here until I figure out the   # right fix.   def normaldirty(f):   dirstate._dirty = True   dirstate._addpath(f)   dirstate._map[f] = ('n', 0, -2, -1)   if f in dirstate._copymap:   del dirstate._copymap[f]   normaldirty(file)    def findoutgoing(repo, remote, force):   # First attempt is for Mercurial <= 1.5 second is for >= 1.6   try:   return repo.findoutgoing(remote)   except AttributeError:   from mercurial import discovery   return discovery.findoutgoing(repo, remote, force=force)    # -- Private worker functions ------------------------------------------    if os.name == 'nt':   from mercurial import win32   linkfn = win32.os_link  else:   linkfn = os.link    def link(src, dest):   try:   linkfn(src, dest)   except OSError:   # If hardlinks fail fall back on copy   shutil.copyfile(src, dest)   os.chmod(dest, os.stat(src).st_mode)    def system_cache_path(ui, hash):   path = ui.config(long_name, 'systemcache', None)   if path:   path = os.path.join(path, hash)   else:   if os.name == 'nt':   path = os.path.join(os.getenv('LOCALAPPDATA') or os.getenv('APPDATA'), long_name, hash)   elif os.name == 'posix':   path = os.path.join(os.getenv('HOME'), '.' + long_name, hash)   else:   raise util.Abort(_('Unknown operating system: %s\n') % os.name)   return path    def in_system_cache(ui, hash):   return os.path.exists(system_cache_path(ui, hash))    def find_file(repo, hash):   if in_cache(repo, hash):   repo.ui.note(_('Found %s in cache\n') % hash)   return cache_path(repo, hash)   if in_system_cache(repo.ui, hash):   repo.ui.note(_('Found %s in system cache\n') % hash)   return system_cache_path(repo.ui, hash)   return None    def open_bfdirstate(ui, repo):   '''   Return a dirstate object that tracks big files: i.e. its root is the   repo root, but it is saved in .hg/bfiles/dirstate.   '''   admin = repo.join(long_name)   opener = util.opener(admin)   if hasattr(repo.dirstate, '_validate'):   bfdirstate = dirstate.dirstate(opener, ui, repo.root, repo.dirstate._validate)   else:   bfdirstate = dirstate.dirstate(opener, ui, repo.root)     # If the bfiles dirstate does not exist, populate and create it. This   # ensures that we create it on the first meaningful bfiles operation in   # a new clone. It also gives us an easy way to forcibly rebuild bfiles   # state:   # rm .hg/bfiles/dirstate && hg bfstatus   # Or even, if things are really messed up:   # rm -rf .hg/bfiles && hg bfstatus   # (although that can lose data, e.g. pending big file revisions in   # .hg/bfiles/{pending,committed}).   if not os.path.exists(os.path.join(admin, 'dirstate')):   util.makedirs(admin)   matcher = get_standin_matcher(repo)   for standin in dirstate_walk(repo.dirstate, matcher):   bigfile = split_standin(standin)   hash = read_standin(repo, standin)   try:   curhash = hashfile(bigfile)   except IOError, err:   if err.errno == errno.ENOENT:   dirstate_normaldirty(bfdirstate, bigfile)   else:   raise   else:   if curhash == hash:   bfdirstate.normal(unixpath(bigfile))   else:   dirstate_normaldirty(bfdirstate, bigfile)     bfdirstate.write()     return bfdirstate    def bfdirstate_status(bfdirstate, repo, rev):   wlock = repo.wlock()   try:   match = match_.always(repo.root, repo.getcwd())   s = bfdirstate.status(match, [], False, False, False)   (unsure, modified, added, removed, missing, unknown, ignored, clean) = s   for bfile in unsure:   if repo[rev][standin(bfile)].data().strip() != hashfile(repo.wjoin(bfile)):   modified.append(bfile)   else:   clean.append(bfile)   bfdirstate.normal(unixpath(bfile))   bfdirstate.write()   finally:   wlock.release()   return (modified, added, removed, missing, unknown, ignored, clean)    def list_bfiles(repo, rev=None, matcher=None):   '''list big files in the working copy or specified changeset'''     if matcher is None:   matcher = get_standin_matcher(repo)     bfiles = []   if rev:   cctx = repo[rev]   for standin in cctx.walk(matcher):   filename = split_standin(standin)   bfiles.append(filename)   else:   for standin in sorted(dirstate_walk(repo.dirstate, matcher)):   filename = split_standin(standin)   bfiles.append(filename)   return bfiles    def in_cache(repo, hash):   return os.path.exists(cache_path(repo, hash))    def create_dir(dir):   if not os.path.exists(dir):   os.makedirs(dir)    def cache_path(repo, hash):   return repo.join(os.path.join(long_name, hash))    def copy_to_cache(repo, rev, file, uploaded=False):   hash = read_standin(repo, standin(file))   if in_cache(repo, hash):   return   create_dir(os.path.dirname(cache_path(repo, hash)))   if in_system_cache(repo.ui, hash):   link(system_cache_path(repo.ui, hash), cache_path(repo, hash))   else:   shutil.copyfile(repo.wjoin(file), cache_path(repo, hash))   os.chmod(cache_path(repo, hash), os.stat(repo.wjoin(file)).st_mode)   create_dir(os.path.dirname(system_cache_path(repo.ui, hash)))   link(cache_path(repo, hash), system_cache_path(repo.ui, hash))    def get_standin_matcher(repo, pats=[], opts={}):   '''Return a match object that applies pats to <repo>/.kbf.'''   standin_dir = repo.pathto(short_name)   if pats:   # patterns supplied: search .hgbfiles relative to current dir   cwd = repo.getcwd()   pats = [os.path.join(standin_dir, cwd, pat) for pat in pats]   elif os.path.isdir(standin_dir):   # no patterns: relative to repo root   pats = [standin_dir]   else:   # no patterns and no .hgbfiles dir: return matcher that matches nothing   match = match_.match(repo.root, None, [], exact=True)   match.matchfn = lambda f: False   return match   return get_matcher(repo, pats, opts, showbad=False)    def get_matcher(repo, pats=[], opts={}, showbad=True):   '''Wrapper around cmdutil.match() that adds showbad: if false, neuter   the match object\'s bad() method so it does not print any warnings   about missing files or directories.'''   match = cmdutil.match(repo, pats, opts)   if not showbad:   match.bad = lambda f, msg: None   return match    def compose_standin_matcher(repo, rmatcher):   '''Return a matcher that accepts standins corresponding to the files   accepted by rmatcher. Pass the list of files in the matcher as the   paths specified by the user.'''   smatcher = get_standin_matcher(repo, rmatcher.files())   isstandin = smatcher.matchfn   def composed_matchfn(f):   return isstandin(f) and rmatcher.matchfn(split_standin(f))   smatcher.matchfn = composed_matchfn     return smatcher    def standin(filename):   '''Return the repo-relative path to the standin for the specified big   file.'''   # Notes:   # 1) Most callers want an absolute path, but _create_standin() needs   # it repo-relative so bfadd() can pass it to repo_add(). So leave   # it up to the caller to use repo.wjoin() to get an absolute path.   # 2) Join with '/' because that's what dirstate always uses, even on   # Windows. Change existing separator to '/' first in case we are   # passed filenames from an external source (like the command line).   return short_name + '/' + filename.replace(os.sep, '/')    def is_standin(filename):   '''Return true if filename is a big file standin. filename must   be in Mercurial\'s internal form (slash-separated).'''   return filename.startswith(short_name+'/')    def split_standin(filename):   # Split on / because that's what dirstate always uses, even on Windows.   # Change local separator to / first just in case we are passed filenames   # from an external source (like the command line).   bits = filename.replace(os.sep, '/').split('/', 1)   if len(bits) == 2 and bits[0] == short_name:   return bits[1]   else:   return None    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>'''   return read_hash(repo.wjoin(standin))    def write_standin(repo, standin, hash, executable):   '''write hhash to <repo.root>/<standin>'''   write_hash(hash, repo.wjoin(standin), executable)    def copy_and_hash(instream, outfile):   '''Read bytes from instream (iterable) and write them to outfile,   computing the SHA-1 hash of the data along the way. Close outfile   when done and return the binary hash.'''   hasher = util.sha1('')   for data in instream:   hasher.update(data)   outfile.write(data)     # Blecch: closing a file that somebody else opened is rude and   # wrong. But it's so darn convenient and practical! After all,   # outfile was opened just to copy and hash.   outfile.close()     return hasher.digest()    def hashrepofile(repo, file):   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):   hasher.update(data)   return hasher.hexdigest()    def blockstream(infile, blocksize=128*1024):   """Generator that yields blocks of data from infile and closes infile."""   while True:   data = infile.read(blocksize)   if not data:   break   yield data   # Same blecch as above.   infile.close()    def read_hash(filename):   rfile = open(filename, 'rb')   hash = rfile.read(40)   rfile.close()   if len(hash) < 40:   raise util.Abort(_('bad hash in \'%s\' (only %d bytes long)')   % (filename, len(hash)))   return hash    def write_hash(hash, filename, executable):   util.makedirs(os.path.dirname(filename))   if os.path.exists(filename):   os.unlink(filename)   if os.name == 'posix':   # Yuck: on Unix, go through open(2) to ensure that the caller's mode is   # filtered by umask() in the kernel, where it's supposed to be done.   wfile = os.fdopen(os.open(filename, os.O_WRONLY|os.O_CREAT, get_mode(executable)), 'wb')   else:   # But on Windows, use open() directly, since passing mode='wb' to os.fdopen()   # does not work. (Python bug?)   wfile = open(filename, 'wb')     try:   wfile.write(hash)   wfile.write('\n')   finally:   wfile.close()    def get_executable(filename):   mode = os.stat(filename).st_mode   return (mode & stat.S_IXUSR) and (mode & stat.S_IXGRP) and (mode & stat.S_IXOTH)    def get_mode(executable):   if executable:   return 0755   else:   return 0644    def urljoin(first, second, *arg):   def join(left, right):   if not left.endswith('/'):   left += '/'   if right.startswith('/'):   right = right[1:]   return left + right     url = join(first, second)   for a in arg:   url = join(url, a)   return url    # Convert a path to a unix style path. This is used to give a  # canonical path to the bfdirstate.  def unixpath(path):   return os.path.normpath(path).replace(os.sep, '/')
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', '%s/../kbfiles' % TESTDIR),], + 'extensions': [('kbfiles', '%s/../kbfiles' % TESTDIR), + ('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")