mercurial使用

Since we have presented a way to review the history of committed changes using Git, Team Foundation Server and Subversion, let’s check how the same can be achieved when working with the Mercurial source control system.

由于我们提供了一种使用Git , Team Foundation Server和Subversion来查看已提交更改的历史的方法,因此让我们检查一下在使用Mercurial源代码控制系统时如何实现相同的更改。

We’ll be using Tortoise Hg, free Mercurial client that comes with Windows shell integration. For the purpose of this article we’ll use a sample database called StoresDB whose objects are scripted in separate files and saved in a local folder called MercLocal. The same folder is initialized to be a local Mercurial repository. I won’t include details about initializing the repository and committing changes. The goal of the article is to cover the following: revision history of all committed changes, comparing two versions of the same object committed in two different changesets and getting specific version of an object from the commit history.

我们将使用Windows Shell集成随附的免费Mercurial客户端Tortoise Hg 。 就本文而言,我们将使用一个名为StoresDB的示例数据库,该数据库的对象被编写在单独的文件中,并保存在名为MercLocal的本地文件夹中。 相同的文件夹被初始化为本地Mercurial存储库。 我不会提供有关初始化存储库和提交更改的详细信息。 本文的目的是涵盖以下内容:所有已提交更改的修订历史记录,比较在两个不同变更集中提交的同一对象的两个版本,并从提交历史记录中获取对象的特定版本。

As a starting point, let’s assume that the following tasks were performed against previously scripted database object files:

首先,假设对先前编写脚本的数据库对象文件执行了以下任务:

  • Initial commit of all database objects

    初始提交所有数据库对象

  • Committing a new table called Balances using the following SQL script:

    使用以下SQL脚本提交一个名为Balances的新表:

    
    CREATE TABLE [dbo].[Balances]([BalanceID] [varchar](15) PRIMARY KEY NOT NULL,[Description] [varchar](255) NULL,[DocID] INT IDENTITY(1,1) NOT NULL)GO
  • In the next changeset the following changes are committed:

    在下一个变更集中,将进行以下更改:

    • New column called BalanceType is added to the Balances table using the following SQL script:

      使用以下SQL脚本,将称为BalanceType的新列添加到Balances表中:

      
      ALTER TABLE dbo.Balances ADD BalanceType NVARCHAR(50)
    • New stored procedure called BalancesList is created using the following script:

      使用以下脚本创建名为BalancesList的新存储过程:

      
      CREATE PROCEDURE dbo.BalancesList
      AS
      BEGIN
      SELECT BalanceID, Description, DocID FROM dbo.Balances
      END
      GO
    • New column added to the ProductCategory table:

      新列添加到ProductCategory表:

      
      ALTER TABLE Production.ProductCategoryADD CategoryDescription NVARCHAR (255)
  • The next changeset holds just a single edit. The previously created BalanceType column in the Balances table is renamed using the following script:

    下一个变更集仅包含一个编辑。 使用以下脚本重命名了Balances表中先前创建的BalanceType列:

    
    EXEC sp_rename 'dbo.Balances.BalanceType', 'BType', 'COLUMN'
  • The last change we committed is deleting the Sales.CreditCard table:

    我们提交的最后一个更改是删除Sales.CreditCard表:

    
    DROP TABLE Sales.ShoppingCartItem;
  • 修订记录 (Revision history)

    In order to review the entire history of committed changes, start the TortoiseHg Workbench application. It can be started from the right click menu inside the folder initialized as a local Mercurial repository (in this case the MercLocal folder):

    为了查看已提交更改的整个历史记录,请启动TortoiseHg Workbench应用程序。 可以从初始化为本地Mercurial存储库(在此情况下为MercLocal文件夹)的文件夹内的右键单击菜单中启动:

    Double-click the appropriate repository (in this case MercLocal) in the repository tree panel to the left, and the complete history of committed changes will load on the right panel:

    在左侧的存储库树面板中双击适当的存储库(在本例中为MercLocal ),然后将在右侧面板上加载已提交更改的完整历史记录:

    As shown in the above image, the history view presents the task workflow introduced in the article. The first commit (at the bottom of the list) shows initial commit of all database objects, followed by commits where the rest of changes are committed.

    如上图所示,历史视图显示了本文介绍的任务工作流程。 第一个提交(在列表的底部)显示所有数据库对象的初始提交,然后显示提交其余更改的提交。

    Each commit in the list contains the revision ID (the Rev column), branch where it is committed (currently all changes are committed to default branch), description – which is actually the commit message, the author of the commit (all commits are performed by the same user – ApexSQL Test). The Age column stores the time that passed after the commit is performed. The Changes column at the end, shows the exact number of changes included in the specific changeset, along with the appropriate colors that represents the actions performed against committed files:

    列表中的每个提交都包含修订ID(“ 修订”列),提交的分支(当前所有更改都提交给默认分支),描述(实际上是提交消息),提交的作者(执行所有提交)由同一用户-ApexSQL测试)。 “ 年龄”列存储执行提交后经过的时间。 最后的“ 更改”列显示特定更改集中包含的确切更改数量,以及代表针对已提交文件执行的操作的适当颜色:

    For instance, 131 highlighted in green for the first commit (Rev 0) indicates that 131 new objects are committed to the repository. The third changeset (Rev 2) that has 1 highlighted in green and 2 highlighted in orange indicates that one new file (object) is added, and two existing objects were updated/edited. The most recent commit shown on top of the list (Rev 4) where 1 is highlighted in orange indicates that one object is deleted from the repository which corresponds to deleting the ShoppingCartItem table in the last commit.

    例如,在第一次提交( Rev 0 )中以绿色突出显示的131表示有131个新对象已提交到存储库。 第三个变更集( Rev 2 )的绿色突出显示为1,橙色突出显示为2,表示已添加一个新文件(对象),并且已更新/编辑了两个现有对象。 列表( 修订版4 )顶部显示的最新提交(其中1以橙色突出显示)表示已从存储库中删除了一个对象,这与删除最后一个提交中的ShoppingCartItem表相对应。

    单个对象的修订历史 (Revision history for the single object)

    To review the history of the specific object only, navigate to the object in the local folder which is initialized as a Mercurial repository (in this case this is the MercLocal folder) and right click the specific object that you want to compare across revisions (in this case, we’ll review the revision history for the dbo.Balances table), and select the Revision History option:

    要仅查看特定对象的历史记录,请导航到本地文件夹中的对象,该文件夹已初始化为Mercurial存储库(在本例中为MercLocal文件夹),然后右键单击要在各个修订版本之间进行比较的特定对象(在在这种情况下,我们将查看dbo.Balances表的修订历史记录 ,然后选择“ 修订历史记录”选项:

    This initiates the Log file viewer form, that shows the list of changesets which contain the selected file. For the highlighted revision (in this case Rev 1) the version of an object committed in that revision will be shown in the section below:

    这将启动“ 日志文件查看器”表单,该表单显示包含所选文件的变更集的列表。 对于突出显示的修订版(在本例中为Rev 1),该版本中提交的对象的版本将在以下部分中显示:

    Selecting the next revision (Rev 2) from the list, shows that a new column (BalanceType) is added, which is indicated with the green highlighted line (line 18):

    从列表中选择下一个修订版(Rev 2),将显示添加了新列( BalanceType ),并以绿色突出显示的行(第18行)表示:

    Selecting the last revision (Rev 3) where the BalanceType column is renamed to BType will be highlighted in different color (line 18 where the actual change is shown will be highlighted in purple):

    选择将BalanceType列重命名为BType的最后一个修订版( Rev 3 )将以不同的颜色突出显示(显示实际更改的第18行将以紫色突出显示):

    比较两个修订版 (Compare between two revisions)

    To compare between two revisions, select the first one from the commit history, press and hold the CTRL key, select the second revision, and right click any of them. From the right click menu, select the Visual Diff option. In this case, we’ll compare Rev 3 with Rev 1:

    要在两个修订版本之间进行比较,请从提交历史记录中选择第一个修订版本,按住CTRL键,选择第二个修订版本,然后右键单击任何一个。 从右键单击菜单中,选择“ Visual Diff”选项。 在这种情况下,我们将比较Rev 3Rev 1

    This initiates a new form that lists all the differences between selected revisions. In order to show differences for the specific object, double-click that object from the list. We’ll do that for the dbo.Balances table:

    这将启动一个新表格,其中列出了所选修订之间的所有差异。 为了显示特定对象的差异,请从列表中双击该对象。 我们将对dbo.Balances表执行此操作

    比较各个版本中特定对象的版本 (Compare between versions of the specific object across revisions)

    The above described comparison between revisions gives a list of all objects that are compared, so the user can select which one to inspect in details, as we did for the dbo.Balances table. In case we need to inspect differences for the specific object across revision history, there is no need to compare all objects from one changeset with all objects from another changeset. To narrow down the comparison to a single object, select it from the list of objects in any changeset, and from the right click menu select the Compare File Revisions option. We’ll perform that against the dbo.Balances table from the Rev 2 revision:

    修订之间的上述比较给出了所有比较对象的列表,因此用户可以选择要详细检查的对象,就像我们对dbo.Balances表所做的那样 。 如果我们需要检查整个修订历史中特定对象的差异,则无需将一个变更集的所有对象与另一变更集的所有对象进行比较。 要将比较范围缩小到单个对象,请从任何变更集中的对象列表中选择它,然后从右键单击菜单中选择“ 比较文件修订”选项。 我们将针对Rev 2修订版中的dbo.Balances表执行该操作:

    This initiates the Log file viewer form for the selected object. Both sides, left and right, shows the same list of revisions related to specific object (in this case the Balances table). To compare between revisions, simply select one on the left side, and another one on the right (we’ll compare the version of the balances table from Rev 1 with the version from Rev 3):

    这将启动所选对象的日志文件查看器表单。 左右两侧都显示与特定对象相关的相同修订版本列表(在本例中为“ 余额”表)。 要在修订版本之间进行比较,只需在左侧选择一个,在右侧选择另一个(我们将比较Rev 1中的余额表版本和Rev 3中的版本):

    The above image shows that the BType we have introduced in Rev3 didn’t exist in Rev 1 when the Balances table was committed initially.

    上图显示的是BTYPE我们Rev3型已经介绍,当余额表最初承诺没有在版本1存在。

    恢复为特定的修订版 (Revert to the specific revision)

    In case the entire revision needs to be reverted, right click on it from the revision history and select the Revert All Files option:

    如果需要还原整个修订,请在修订历史中右键单击它,然后选择“ 还原所有文件”选项:

    Reverting to Rev 1 discards all changes committed after the Rev 1. This means that BalancesList stored procedure will be deleted, as well as BType column that was committed in the later revision. Checking the Balances table in the local repository gives the following result:

    恢复到修订版1会丢弃在修订版1之后提交的所有更改。 这意味着将删除BalancesList存储过程以及在更高版本中提交的BType列。 检查本地存储库中的余额表将得到以下结果:

    This confirms that the BalanceType column introduced in the next revision, and renamed to BType later, does not exist.

    这确认了在下一个修订版中引入并在以后重命名为BTypeBalanceType列不存在。

    从修订历史记录中获取对象的特定版本 (Get specific version of an object from the revision history)

    In case only specific object(s) need to be reverted, instead of the entire revision, navigate to the specific revision, select one (or multiple files using the CTRL key), and from the right click menu select the Revert to Revision option:

    如果只需要还原特定对象而不是整个修订版本,请导航至该特定修订版本,选择一个(或使用CTRL键的多个文件),然后从右键单击菜单中选择“ 还原为修订版本”选项:

    The above image represents reverting the version of the Balances table from Rev 2, without reverting other changes from the same revision. Selecting the Revert to Revision option from the right click menu gives a confirmation dialog, where optionally all object from the selected revision can be reverted (by checking the Revert all files to this revision option). In order to demonstrate reverting of a single object, this option will be unchecked:

    上面的图像表示从修订版2还原余额表的版本,而未还原同一修订版的其他更改。 从右键单击菜单中选择“ 还原到修订版本”选项,将显示一个确认对话框,在该对话框中,可以选择还原来自选定修订版本的所有对象(通过选中“将所有文件还原到此修订版本”选项)。 为了演示单个对象的还原,将不选中此选项:

    After clicking the OK button, to confirm reverting just the Balances table, let’s inspect the local repository.

    单击“ 确定”按钮后,要确认仅还原“ 余额”表,让我们检查本地存储库。

    The Balances table is shown as changed, and reviewing the actual script shows that BType column committed in Rev 4 is reverted back to BalanceType committed in Rev 2:

    余额表显示为已更改,并且查看实际脚本后发现, 修订版4中提交的BType列已还原为修订版2中提交的BalanceType

    Also, BalancesList stored procedure still exists in the local repository since we have reverted the Balances table only.

    另外,由于我们仅还原了Balances表,因此BalancesList存储过程仍存在于本地存储库中。

    Using this approach, any revision can be reverted, which will actually revert all files from the revision, or selecting specific object(s) from the revision can be reverted without affecting the rest of changes from the revision.

    使用此方法,可以还原任何修订,这实际上将还原该修订中的所有文件,或者可以还原从该修订中选择特定的对象,而不影响该修订的其余更改。

    To see the full version history of a SQL Server database object under source control, you can try ApexSQL Source Control, an SSMS add-in that allows you to put a database under version control, commit all changes to the repository and easily revert any committed change from the history.

    要查看在源代码管理下SQL Server数据库对象的完整版本历史记录 ,可以尝试ApexSQL Source Control,它是一种SSMS加载项,可让您将数据库置于版本控制下 ,将所有更改提交到存储库并轻松还原任何已提交改变历史。

翻译自: https://www.sqlshack.com/revision-history-object-change-sql-database-using-mercurial/

mercurial使用

mercurial使用_使用Mercurial在SQL数据库中对象更改的修订历史记录相关推荐

  1. subversion使用_使用Subversion在SQL数据库中对象更改的修订历史记录

    subversion使用 In previous articles, I have already covered the revision history for Git and Team Foun ...

  2. azure云数据库_在Azure SQL数据库中保护数据的五种方法

    azure云数据库 When storing data in the cloud the main concern companies generally have is whether or not ...

  3. azure云数据库_在Azure SQL数据库中配置电子邮件通知

    azure云数据库 In this article, we will review how to configure email notifications in the Azure SQL sing ...

  4. azure云数据库_在Azure SQL数据库中实现动态数据屏蔽

    azure云数据库 In this article, we will review Dynamic Data Masking in the Azure SQL database. Dynamic Da ...

  5. azure备份存储层分类_如何配置Azure SQL数据库长期保留(LTR)备份

    azure备份存储层分类 In this article, we will review default backup settings, long-term retention (LTR) back ...

  6. ssis导出数据性能_如何使用SSIS将数据从Excel导出到Azure SQL数据库中的多个表

    ssis导出数据性能 In this article, I am going to explain how we can split the data within the excel file an ...

  7. SQL数据库中临时表、临时变量和WITH AS关键词创建“临时表”的区别

    原文链接:https://www.cnblogs.com/zhaowei303/articles/4204805.html SQL数据库中数据处理时,有时候需要建立临时表,将查询后的结果集放到临时表中 ...

  8. Android学习笔记——保存数据到SQL数据库中(Saving Data in SQL Databases)

    知识点: 1.使用SQL Helper创建数据库 2.数据的增删查改(PRDU:Put.Read.Delete.Update) 背景知识: 上篇文章学习了保存文件,今天学习的是保存数据到SQL数据库中 ...

  9. 在SQL数据库中搜索对象的不同方法

    This article explores various ways to search for database objects in SQL database such as tables, st ...

最新文章

  1. 重磅丨We Are SocialHootsuite:2018全球数字报告
  2. 124. Leetcode 583. 两个字符串的删除操作 (动态规划- 字符串系列)
  3. python读什么类型文件最快的软件_使用python读取数据科学最常用的文件格式(转)...
  4. [Computation]集合、关系、语言
  5. 【qduoj】C语言_求整数各位数之和
  6. 关于mongodb的可视化工具:nosql manager for mongodb
  7. 将springboot打包成的jar文件做成windows服务
  8. 基于Netty模拟解析Binlog
  9. linux怎么加route到第一行,Linux下route命令操作实例汇总(2)
  10. 从xml数据集到FairMOT数据集转换
  11. Python 数据分析与挖掘概述
  12. 计算机与现代社会英语作文,高一英语作文,科技以下是题目:众所周知,科技在现代社会和生活中扮演着越来越重要的角色,但科技同时也是一把双刃剑,在它璀璨...
  13. SAS计算IV代码分享
  14. 作业五:结对项目-四则运算 “软件”之升级版
  15. 海尔计算机无法装win7系统,海尔Haier电脑预装win8换win7系统BIOS设置及安装教程
  16. Win10方便快捷键
  17. win10服务器网页打不开怎么办,win10系统ie浏览器有些网页打不开怎么回事
  18. android平板屏幕碎了触摸失灵,小白瞎折腾:从此手机与平板自己维修,拒绝被忽悠!...
  19. Validation框架的应用
  20. 电脑网络连接有个感叹号,连不上网

热门文章

  1. json字符串转成formdata_FormData 数据转化为 json 数据
  2. SSM整合 mybatis多条件查询与分页
  3. [HEOI2016/TJOI2016]求和(第二类斯特林数)
  4. 【LGP5161】WD与数列
  5. Docker管理工具-Swarm部署记录
  6. cut point and bridge总结
  7. 什么是灰度发布?灰度发布方式 系统的割接 灰度部署典型的框架架构
  8. x+=y与x=x+y有什么区别?
  9. 在64位机器上无法调用迅雷的问题
  10. webpack那些事:浅入深出-源码解析构建优化