Changeset b0916a4160dd…
Parent d0975634cee1…
by Na'Tosha Bard <natosha@unity3d.com>
Changes to 3 files · Browse files at b0916a4160dd Showing diff from parent d0975634cee1 Diff from another changeset...
@@ -700,6 +700,10 @@
return result
+# When the user calls revert, we have to be careful to not revert any changes to other
+# bfiles accidentally. This means we have to keep track of the bfiles that are
+# being reverted so we only pull down the necessary bfiles.
+#
# Standins are only updated (to match the hash of bfiles) before commits.
# Update the standins then run the original revert (changing the matcher to hit standins
# instead of bfiles). Based on the resulting standins update the bfiles. Then return the
@@ -730,7 +734,17 @@ orig_matchfn = m.matchfn
def matchfn(f):
if bfutil.is_standin(f):
- return orig_matchfn(bfutil.split_standin(f)) and (f in repo[None] or f in ctx)
+ # We need to keep track of what bfiles are being matched so we know which
+ # ones to update later (otherwise we revert changes to other bfiles
+ # accidentally). This is repo specific, so duckpunch the repo object to
+ # keep the list of bfiles for us later.
+ if(orig_matchfn(bfutil.split_standin(f)) and (f in repo[None] or f in ctx)):
+ bfiles_list = getattr(repo, "_bfiles_to_update", [])
+ bfiles_list.append(bfutil.split_standin(f))
+ repo._bfiles_to_update = bfiles_list;
+ return True
+ else:
+ return False
return orig_matchfn(f)
m.matchfn = matchfn
return m
@@ -738,10 +752,14 @@ orig(ui, repo, *pats, **opts)
finally:
cmdutil.match = oldmatch
- bfcommands.revert_bfiles(ui, repo)
+ bfiles_list = getattr(repo, "_bfiles_to_update", [])
+ bfcommands.revert_bfiles(ui, repo, bfiles_list)
+ # Empty out the bfiles list so we start fresh next time
+ repo._bfiles_to_update = []
for bfile in modified:
- if os.path.exists(repo.wjoin(bfutil.standin(bfile))) and bfile in repo['.']:
- bfutil.write_standin(repo, bfutil.standin(bfile), repo['.'][bfile].data().strip(), 'x' in repo['.'][bfile].flags())
+ if bfile in bfiles_list:
+ if os.path.exists(repo.wjoin(bfutil.standin(bfile))) and bfile in repo['.']:
+ bfutil.write_standin(repo, bfutil.standin(bfile), repo['.'][bfile].data().strip(), 'x' in repo['.'][bfile].flags())
finally:
wlock.release()
|
@@ -211,3 +211,34 @@ ? b2.txt.orig
? n2.txt.orig
''')
+# Test that modifying a normal file and a bfile, then reverting the normal file,
+# does not alter the bfile
+os.chdir('..')
+os.mkdir('repo2')
+os.chdir('repo2')
+hgt.hg(['init', '-q'])
+hgt.writefile('n1', 'n1')
+hgt.hg(['add', 'n1'])
+hgt.hg(['commit', '-m', 'added normal file'])
+hgt.writefile('b1', 'b1')
+hgt.hg(['add', '--bf', 'b1'])
+hgt.hg(['commit', '-m', 'added bfile'])
+hgt.writefile('n1', 'n11')
+hgt.writefile('b1', 'b11')
+hgt.hg(['revert', 'n1'])
+hgt.asserttrue(hgt.readfile('b1') == 'b11', 'file chnaged')
+# Test that modifying 2 bfiles and reverting one of the bfiles, does not alter the
+# second bfile
+os.chdir('..')
+os.mkdir('repo3')
+hgt.hg(['init', '-q'])
+hgt.writefile('b1', 'b1')
+hgt.hg(['add', '--bf', 'b1'])
+hgt.hg(['commit', '-m', 'added first bfile'])
+hgt.writefile('b2', 'b2')
+hgt.hg(['add', '--bf', 'b2'])
+hgt.hg(['commit', '-m', 'added second bfile'])
+hgt.writefile('b1', 'b11')
+hgt.writefile('b2', 'b22')
+hgt.hg(['revert', 'b1'])
+hgt.asserttrue(hgt.readfile('b2') == 'b22', 'file chnaged')
|
Loading...