aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2013-06-25 17:23:21 -0400
committerRuss Cox <rsc@golang.org>2013-06-25 17:23:21 -0400
commit75aab1374196f454c9fa579863eaadbae2ac17c3 (patch)
tree885b155a6f9a94b03e83dd6e7a7bd6cd2d80e8ca /lib
parent7590e28d24d2dd50200808d2514656b6a440412f (diff)
downloadgo-75aab1374196f454c9fa579863eaadbae2ac17c3.tar.gz
go-75aab1374196f454c9fa579863eaadbae2ac17c3.zip
codereview: force hg update after hg pull -u during hg sync
If you hg update your client to an earlier CL, then hg sync will move you back to tip if it pulls anything in, but it will leave you where you are if it doesn't pull anything in. That's confusing: make hg sync always update to tip. R=golang-dev, bradfitz, r, dsymonds CC=golang-dev https://golang.org/cl/10456044
Diffstat (limited to 'lib')
-rw-r--r--lib/codereview/codereview.py33
1 files changed, 32 insertions, 1 deletions
diff --git a/lib/codereview/codereview.py b/lib/codereview/codereview.py
index 6cf99d8a3c..39cdc0f273 100644
--- a/lib/codereview/codereview.py
+++ b/lib/codereview/codereview.py
@@ -1168,6 +1168,25 @@ def hg_pull(ui, repo, **opts):
ui.write(line + '\n')
return err
+def hg_update(ui, repo, **opts):
+ w = uiwrap(ui)
+ ui.quiet = False
+ ui.verbose = True # for file list
+ err = hg_commands.update(ui, repo, **opts)
+ for line in w.output().split('\n'):
+ if isNoise(line):
+ continue
+ if line.startswith('moving '):
+ line = 'mv ' + line[len('moving '):]
+ if line.startswith('getting ') and line.find(' to ') >= 0:
+ line = 'mv ' + line[len('getting '):]
+ if line.startswith('getting '):
+ line = '+ ' + line[len('getting '):]
+ if line.startswith('removing '):
+ line = '- ' + line[len('removing '):]
+ ui.write(line + '\n')
+ return err
+
def hg_push(ui, repo, **opts):
w = uiwrap(ui)
ui.quiet = False
@@ -2019,7 +2038,19 @@ def sync(ui, repo, **opts):
raise hg_util.Abort(codereview_disabled)
if not opts["local"]:
- err = hg_pull(ui, repo, update=True)
+ # If there are incoming CLs, pull -u will do the update.
+ # If there are no incoming CLs, do hg update to make sure
+ # that an update always happens regardless. This is less
+ # surprising than update depending on incoming CLs.
+ # It is important not to do both hg pull -u and hg update
+ # in the same command, because the hg update will end
+ # up marking resolve conflicts from the hg pull -u as resolved,
+ # causing files with <<< >>> markers to not show up in
+ # hg resolve -l. Yay Mercurial.
+ if hg_incoming(ui, repo):
+ err = hg_pull(ui, repo, update=True)
+ else:
+ err = hg_update(ui, repo)
if err:
return err
sync_changes(ui, repo)